rspec-padrino 0.0.1 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ # http://about.travis-ci.org/docs/user/build-configuration/
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3-p0
6
+ notifications:
7
+ email:
8
+ - udzura@udzura.jp
data/Gemfile CHANGED
@@ -4,12 +4,13 @@ source "http://rubygems.org"
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
  gem "sinatra"
6
6
  gem "padrino-core", ">= 0.10.2"
7
- gem "rspec", "~> 2.3.0"
7
+ gem "rspec", ">= 2.3"
8
8
  gem "rack-test", ">= 0"
9
9
 
10
10
  # Add dependencies to develop your gem here.
11
11
  # Include everything needed to run rake, tests, features, etc.
12
12
  group :development do
13
+ gem 'rdoc'
13
14
  gem "bundler", "~> 1.0.0"
14
15
  gem "jeweler", "~> 1.6.4"
15
16
  gem "rcov", ">= 0"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (3.1.0)
4
+ activesupport (3.1.3)
5
5
  multi_json (~> 1.0)
6
6
  diff-lcs (1.1.3)
7
7
  git (1.2.5)
@@ -12,29 +12,35 @@ GEM
12
12
  bundler (~> 1.0)
13
13
  git (>= 1.2.5)
14
14
  rake
15
- multi_json (1.0.3)
16
- padrino-core (0.10.2)
15
+ json (1.6.3)
16
+ multi_json (1.0.4)
17
+ padrino-core (0.10.5)
17
18
  activesupport (~> 3.1.0)
18
19
  http_router (~> 0.10.2)
19
- sinatra (~> 1.2.6)
20
+ sinatra (~> 1.3.1)
20
21
  thor (~> 0.14.3)
21
22
  tilt (~> 1.3.0)
22
- rack (1.3.4)
23
+ rack (1.3.5)
24
+ rack-protection (1.1.4)
25
+ rack
23
26
  rack-test (0.6.1)
24
27
  rack (>= 1.0)
25
- rake (0.9.2)
26
- rcov (0.9.10)
27
- rspec (2.3.0)
28
- rspec-core (~> 2.3.0)
29
- rspec-expectations (~> 2.3.0)
30
- rspec-mocks (~> 2.3.0)
31
- rspec-core (2.3.1)
32
- rspec-expectations (2.3.0)
28
+ rake (0.9.2.2)
29
+ rcov (0.9.11)
30
+ rdoc (3.11)
31
+ json (~> 1.4)
32
+ rspec (2.7.0)
33
+ rspec-core (~> 2.7.0)
34
+ rspec-expectations (~> 2.7.0)
35
+ rspec-mocks (~> 2.7.0)
36
+ rspec-core (2.7.1)
37
+ rspec-expectations (2.7.0)
33
38
  diff-lcs (~> 1.1.2)
34
- rspec-mocks (2.3.0)
35
- sinatra (1.2.7)
36
- rack (~> 1.1)
37
- tilt (>= 1.2.2, < 2.0)
39
+ rspec-mocks (2.7.0)
40
+ sinatra (1.3.1)
41
+ rack (~> 1.3, >= 1.3.4)
42
+ rack-protection (~> 1.1, >= 1.1.2)
43
+ tilt (~> 1.3, >= 1.3.3)
38
44
  thor (0.14.6)
39
45
  tilt (1.3.3)
40
46
  url_mount (0.2.1)
@@ -49,5 +55,6 @@ DEPENDENCIES
49
55
  padrino-core (>= 0.10.2)
50
56
  rack-test
51
57
  rcov
52
- rspec (~> 2.3.0)
58
+ rdoc
59
+ rspec (>= 2.3)
53
60
  sinatra
data/README.rdoc CHANGED
@@ -1,6 +1,38 @@
1
1
  = rspec-padrino
2
2
 
3
- Description goes here.
3
+ rspec-padrino is a gem including helpers for testing a Padrino app using RSpec. Taking much from rspec-rails.
4
+
5
+ == Install
6
+
7
+ gem install rspec-padrino
8
+
9
+ Depends on padrino-core >= 0.10.2, sinatra, rack-test, and RSpec 2.
10
+
11
+ == Usage
12
+
13
+ Create a Padrino project with option <tt>-t rspec</tt>. Required files will be generated.
14
+
15
+ Then edit <tt>spec_helper.rb</tt> like:
16
+
17
+ RSpec.configure do |conf|
18
+ conf.include Rack::Test::Methods
19
+ conf.include RSpec::Padrino # add this
20
+ end
21
+
22
+ def app
23
+ ##
24
+ # You should point toplevel #app method to:
25
+ Padrino.application
26
+ end
27
+
28
+ more usage on RDoc: [http://rubydoc.info/github/udzura/rspec-padrino/v0.0.1/frames]
29
+
30
+ == Related Sites
31
+
32
+ * {rubygems.org}[https://rubygems.org/gems/rspec-padrino]
33
+ * {github}[https://github.com/udzura/rspec-padrino]
34
+ * {travis-ci}[http://travis-ci.org/udzura/rspec-padrino] {<img src="https://secure.travis-ci.org/udzura/rspec-padrino.png" alt="build status" />}[http://travis-ci.org/udzura/rspec-padrino]
35
+ * {author's blog}[http://blog.udzura.jp] # Japanese
4
36
 
5
37
  == Contributing to rspec-padrino
6
38
 
@@ -14,6 +46,6 @@ Description goes here.
14
46
 
15
47
  == Copyright
16
48
 
17
- Copyright (c) 2011 Uchio Kondo. See LICENSE.txt for
49
+ Copyright (c) 2011 Uchio Kondo <udzura@udzura.jp>. See LICENSE.txt for
18
50
  further details.
19
51
 
data/Rakefile CHANGED
@@ -32,6 +32,11 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
32
32
  spec.rspec_opts = "-fs --color"
33
33
  end
34
34
 
35
+ RSpec::Core::RakeTask.new(:"spec:integrations") do |spec|
36
+ spec.pattern = FileList['spec/integrations/**/*_spec.rb']
37
+ spec.rspec_opts = "-fs --color"
38
+ end
39
+
35
40
  RSpec::Core::RakeTask.new(:rcov) do |spec|
36
41
  spec.pattern = 'spec/**/*_spec.rb'
37
42
  spec.rcov = true
@@ -39,8 +44,8 @@ end
39
44
 
40
45
  task :default => :spec
41
46
 
42
- require 'rake/rdoctask'
43
- Rake::RDocTask.new do |rdoc|
47
+ require 'rdoc/task'
48
+ RDoc::Task.new do |rdoc|
44
49
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
50
 
46
51
  rdoc.rdoc_dir = 'rdoc'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.4
@@ -4,7 +4,6 @@ require 'rack/test'
4
4
  last_app = nil
5
5
 
6
6
  Sinatra::Base.class_eval do
7
- attr_reader :last_app
8
7
  undef :call
9
8
  define_method :call do |env|
10
9
  _dup = dup
@@ -1,15 +1,26 @@
1
1
  require 'sinatra/base'
2
2
  require 'padrino-core'
3
+
3
4
  module RSpec::Padrino::Matchers
4
5
  module RoutingMatchers
5
6
  last_params = nil
6
7
  last_name = nil
7
- Padrino::Application.class_eval do
8
- before do
9
- last_params = params
10
- last_name = request.route_obj.named rescue nil
8
+
9
+ @_routing_matchers_hook = lambda do
10
+ apps = Padrino.mounted_apps.map(&:app_obj)
11
+ apps.each do |the_app|
12
+ the_app.class_eval do
13
+ after do
14
+ last_params = params
15
+ last_name = request.route_obj && request.route_obj.named
16
+ end
17
+ end
11
18
  end
12
19
  end
20
+
21
+ def self.hook!
22
+ @_routing_matchers_hook.call
23
+ end
13
24
 
14
25
  extend RSpec::Matchers::DSL
15
26
 
@@ -24,8 +35,9 @@ module RSpec::Padrino::Matchers
24
35
  query = Rack::Utils::parse_query(query)
25
36
  method = verb_to_path_map.keys.first
26
37
  begin
27
- Padrino.application.call(Rack::MockRequest.env_for(verb_to_path_map.values.first, :method => method.to_s.upcase))
38
+ ret = Padrino.application.call(Rack::MockRequest.env_for(verb_to_path_map.values.first, :method => method.to_s.upcase))
28
39
  rescue
40
+ puts "something wrong"
29
41
  end
30
42
  last_name == expected_names.join("_").to_sym &&
31
43
  last_params.symbolize_keys == expected_params.symbolize_keys
@@ -54,6 +66,7 @@ module RSpec::Padrino::Matchers
54
66
  method = verb_to_path_map.keys.first.to_s.upcase
55
67
  @routed_to = Padrino.mounted_apps.map(&:app_obj).
56
68
  map{|a| a.router.recognize(Rack::MockRequest.env_for(path, :method => method))}.first
69
+ @routed_to
57
70
  end
58
71
 
59
72
  failure_message_for_should_not do |path|
@@ -3,6 +3,11 @@ module RSpec::Padrino
3
3
  require 'rspec/padrino/matchers/routing_matchers'
4
4
  def self.included(base)
5
5
  base.send :include, RSpec::Padrino::Matchers::RoutingMatchers
6
+ RSpec.configure do |c|
7
+ c.before {
8
+ RSpec::Padrino::Matchers::RoutingMatchers.hook!
9
+ }
10
+ end
6
11
  end
7
12
  end
8
13
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rspec-padrino"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Uchio Kondo"]
12
- s.date = "2011-10-03"
12
+ s.date = "2011-12-10"
13
13
  s.description = "rspec-padrino is a gem including helpers for testing a Padrino app using RSpec. Taking much from rspec-rails."
14
14
  s.email = "udzura@udzura.jp"
15
15
  s.extra_rdoc_files = [
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".document",
21
21
  ".rspec",
22
- ".rvmrc",
22
+ ".travis.yml",
23
23
  "Gemfile",
24
24
  "Gemfile.lock",
25
25
  "LICENSE.txt",
@@ -52,16 +52,18 @@ Gem::Specification.new do |s|
52
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
53
  s.add_runtime_dependency(%q<sinatra>, [">= 0"])
54
54
  s.add_runtime_dependency(%q<padrino-core>, [">= 0.10.2"])
55
- s.add_runtime_dependency(%q<rspec>, ["~> 2.3.0"])
55
+ s.add_runtime_dependency(%q<rspec>, [">= 2.3"])
56
56
  s.add_runtime_dependency(%q<rack-test>, [">= 0"])
57
+ s.add_development_dependency(%q<rdoc>, [">= 0"])
57
58
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
58
59
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
59
60
  s.add_development_dependency(%q<rcov>, [">= 0"])
60
61
  else
61
62
  s.add_dependency(%q<sinatra>, [">= 0"])
62
63
  s.add_dependency(%q<padrino-core>, [">= 0.10.2"])
63
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
64
+ s.add_dependency(%q<rspec>, [">= 2.3"])
64
65
  s.add_dependency(%q<rack-test>, [">= 0"])
66
+ s.add_dependency(%q<rdoc>, [">= 0"])
65
67
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
66
68
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
67
69
  s.add_dependency(%q<rcov>, [">= 0"])
@@ -69,8 +71,9 @@ Gem::Specification.new do |s|
69
71
  else
70
72
  s.add_dependency(%q<sinatra>, [">= 0"])
71
73
  s.add_dependency(%q<padrino-core>, [">= 0.10.2"])
72
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
74
+ s.add_dependency(%q<rspec>, [">= 2.3"])
73
75
  s.add_dependency(%q<rack-test>, [">= 0"])
76
+ s.add_dependency(%q<rdoc>, [">= 0"])
74
77
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
75
78
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
76
79
  s.add_dependency(%q<rcov>, [">= 0"])
@@ -7,6 +7,10 @@ describe "Integrations" do
7
7
  {:get => "/foo"}.should route_to(:foo, :index)
8
8
  end
9
9
 
10
+ it "should not route to /bar" do
11
+ {:get => "/bar"}.should_not route_to(:bar, :index)
12
+ end
13
+
10
14
  it "routes to /foo/create" do
11
15
  {:post => "/foo/create"}.should route_to(:foo, :create)
12
16
  end
@@ -15,8 +19,16 @@ describe "Integrations" do
15
19
  {:get => "/foo/assign"}.should route_to(:foo, :assign)
16
20
  end
17
21
 
18
- it "routes to /foo/assign?hoge=1234" do
19
- {:get => "/foo/assign?hoge=1234"}.should route_to(:foo, :assign, :hoge => "1234")
22
+ it "routes to /foo/show/1" do
23
+ {:get => "/foo/show/1"}.should route_to(:foo, :show, :id => "1")
24
+ end
25
+
26
+ it "routes to /custom/123/path" do
27
+ {:get => "/custom/123/path"}.should route_to(:foo, :show2, :id => "123")
28
+ end
29
+
30
+ it "routes to /foo/assign?par=ams" do
31
+ {:get => "/foo/assign?par=ams"}.should route_to(:foo, :assign, :par => "ams")
20
32
  end
21
33
 
22
34
  it "is not routeble on /" do
@@ -27,6 +39,18 @@ describe "Integrations" do
27
39
  {:get => "/foo"}.should be_routable
28
40
  end
29
41
 
42
+ it "is routable on /foo/show/1" do
43
+ {:get => "/foo/show/1"}.should be_routable
44
+ end
45
+
46
+ it "is routable on /custom/123/path" do
47
+ {:get => "/custom/123/path"}.should be_routable
48
+ end
49
+
50
+ it "is routable on /foo?par=ams" do
51
+ {:get => "/foo?par=ams"}.should be_routable
52
+ end
53
+
30
54
  it "is routable on /foo/create with method POST" do
31
55
  {:post => "/foo/create"}.should be_routable
32
56
  end
@@ -12,6 +12,14 @@ class TestApp < Padrino::Application
12
12
  "foo"
13
13
  end
14
14
 
15
+ get :show, :with => :id do
16
+ "foo"
17
+ end
18
+
19
+ get :show2, '/custom/:id/path' do
20
+ "foo"
21
+ end
22
+
15
23
  post :create do
16
24
  "foo"
17
25
  end
@@ -26,8 +34,10 @@ end
26
34
  Padrino.mount("TestApp").to('/')
27
35
  Padrino.load!
28
36
 
29
- include Rack::Test::Methods
30
- include RSpec::Padrino
37
+ RSpec.configure do |c|
38
+ c.include Rack::Test::Methods
39
+ c.include RSpec::Padrino
40
+ end
31
41
 
32
42
  def app
33
43
  Padrino.application
@@ -1,8 +1,8 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe Rspec::Padrino do
3
+ describe RSpec::Padrino do
4
4
  it "can be included" do
5
- lambda { include Rspec::Padrino }.should_not raise_error
5
+ lambda { include RSpec::Padrino }.should_not raise_error
6
6
  end
7
7
 
8
8
  it "includes RSpec::Padrino::* automatically" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-padrino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-03 00:00:00.000000000Z
12
+ date: 2011-12-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &13069780 !ruby/object:Gem::Requirement
16
+ requirement: &89263400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *13069780
24
+ version_requirements: *89263400
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: padrino-core
27
- requirement: &13069240 !ruby/object:Gem::Requirement
27
+ requirement: &89263130 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,21 +32,21 @@ dependencies:
32
32
  version: 0.10.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *13069240
35
+ version_requirements: *89263130
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &13068660 !ruby/object:Gem::Requirement
38
+ requirement: &89262890 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
- - - ~>
41
+ - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
- version: 2.3.0
43
+ version: '2.3'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *13068660
46
+ version_requirements: *89262890
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rack-test
49
- requirement: &13068060 !ruby/object:Gem::Requirement
49
+ requirement: &89262640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,21 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *13068060
57
+ version_requirements: *89262640
58
+ - !ruby/object:Gem::Dependency
59
+ name: rdoc
60
+ requirement: &89262320 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *89262320
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: bundler
60
- requirement: &13067460 !ruby/object:Gem::Requirement
71
+ requirement: &89239830 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ~>
@@ -65,10 +76,10 @@ dependencies:
65
76
  version: 1.0.0
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *13067460
79
+ version_requirements: *89239830
69
80
  - !ruby/object:Gem::Dependency
70
81
  name: jeweler
71
- requirement: &13066840 !ruby/object:Gem::Requirement
82
+ requirement: &89239420 !ruby/object:Gem::Requirement
72
83
  none: false
73
84
  requirements:
74
85
  - - ~>
@@ -76,10 +87,10 @@ dependencies:
76
87
  version: 1.6.4
77
88
  type: :development
78
89
  prerelease: false
79
- version_requirements: *13066840
90
+ version_requirements: *89239420
80
91
  - !ruby/object:Gem::Dependency
81
92
  name: rcov
82
- requirement: &12936420 !ruby/object:Gem::Requirement
93
+ requirement: &89239060 !ruby/object:Gem::Requirement
83
94
  none: false
84
95
  requirements:
85
96
  - - ! '>='
@@ -87,7 +98,7 @@ dependencies:
87
98
  version: '0'
88
99
  type: :development
89
100
  prerelease: false
90
- version_requirements: *12936420
101
+ version_requirements: *89239060
91
102
  description: rspec-padrino is a gem including helpers for testing a Padrino app using
92
103
  RSpec. Taking much from rspec-rails.
93
104
  email: udzura@udzura.jp
@@ -99,7 +110,7 @@ extra_rdoc_files:
99
110
  files:
100
111
  - .document
101
112
  - .rspec
102
- - .rvmrc
113
+ - .travis.yml
103
114
  - Gemfile
104
115
  - Gemfile.lock
105
116
  - LICENSE.txt
@@ -134,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
145
  version: '0'
135
146
  segments:
136
147
  - 0
137
- hash: 3951091987802476587
148
+ hash: -531388223
138
149
  required_rubygems_version: !ruby/object:Gem::Requirement
139
150
  none: false
140
151
  requirements:
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm 1.9.2@padrino-rspec