rspec-rails 2.5.0 → 2.6.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/.gitignore +9 -4
  2. data/.travis.yml +11 -0
  3. data/README_DEV.md +43 -0
  4. data/Rakefile +54 -27
  5. data/Thorfile +6 -21
  6. data/features/Autotest.md +7 -0
  7. data/features/Changelog.md +17 -2
  8. data/features/Upgrade.md +13 -12
  9. data/features/controller_specs/README.md +18 -10
  10. data/features/controller_specs/anonymous_controller.feature +5 -5
  11. data/features/controller_specs/controller_spec.feature +1 -1
  12. data/features/controller_specs/isolation_from_views.feature +2 -2
  13. data/features/controller_specs/render_views.feature +3 -3
  14. data/features/helper_specs/helper_spec.feature +3 -3
  15. data/features/mailer_specs/url_helpers.feature +2 -2
  16. data/features/matchers/new_record_matcher.feature +2 -2
  17. data/features/matchers/redirect_to_matcher.feature +1 -1
  18. data/features/matchers/render_template_matcher.feature +1 -1
  19. data/features/mocks/mock_model.feature +21 -5
  20. data/features/mocks/stub_model.feature +2 -2
  21. data/features/model_specs/errors_on.feature +1 -1
  22. data/features/model_specs/transactional_examples.feature +10 -5
  23. data/features/routing_specs/README.md +2 -1
  24. data/features/routing_specs/be_routable_matcher.feature +5 -5
  25. data/features/routing_specs/named_routes.feature +1 -1
  26. data/features/routing_specs/route_to_matcher.feature +28 -8
  27. data/features/step_definitions/additional_cli_steps.rb +1 -1
  28. data/features/support/env.rb +7 -18
  29. data/features/view_specs/inferred_controller_path.feature +3 -3
  30. data/features/view_specs/stub_template.feature +2 -2
  31. data/features/view_specs/view_spec.feature +8 -8
  32. data/gemfiles/base.rb +45 -0
  33. data/gemfiles/rails-3-0-stable +7 -0
  34. data/gemfiles/rails-3.0.0 +5 -0
  35. data/gemfiles/rails-3.0.1 +5 -0
  36. data/gemfiles/rails-3.0.2 +5 -0
  37. data/gemfiles/rails-3.0.3 +5 -0
  38. data/gemfiles/rails-3.0.4 +5 -0
  39. data/gemfiles/rails-3.0.5 +5 -0
  40. data/gemfiles/rails-3.0.6 +5 -0
  41. data/gemfiles/rails-master +7 -0
  42. data/lib/generators/rspec/scaffold/scaffold_generator.rb +20 -2
  43. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +23 -23
  44. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +7 -7
  45. data/lib/generators/rspec/scaffold/templates/index_spec.rb +2 -2
  46. data/lib/generators/rspec/scaffold/templates/new_spec.rb +5 -5
  47. data/lib/generators/rspec/scaffold/templates/routing_spec.rb +14 -14
  48. data/lib/generators/rspec/scaffold/templates/show_spec.rb +2 -2
  49. data/lib/rspec/rails/example/controller_example_group.rb +9 -1
  50. data/lib/rspec/rails/example/routing_example_group.rb +1 -0
  51. data/lib/rspec/rails/matchers/routing_matchers.rb +23 -2
  52. data/lib/rspec/rails/mocks.rb +3 -0
  53. data/lib/rspec/rails/tasks/rspec.rake +1 -1
  54. data/lib/rspec/rails/version.rb +1 -1
  55. data/rspec-rails.gemspec +5 -36
  56. data/spec/autotest/rails_rspec2_spec.rb +2 -7
  57. data/spec/rspec/rails/example/controller_example_group_spec.rb +25 -0
  58. data/spec/rspec/rails/matchers/route_to_spec.rb +15 -0
  59. data/spec/rspec/rails/mocks/ar_classes.rb +5 -2
  60. data/spec/rspec/rails/view_rendering_spec.rb +0 -6
  61. data/templates/generate_stuff.rb +2 -1
  62. data/templates/run_specs.rb +2 -2
  63. metadata +54 -77
  64. data/Gemfile-3-0-stable +0 -6
  65. data/Gemfile-3.0.0 +0 -3
  66. data/Gemfile-3.0.3 +0 -3
  67. data/Gemfile-base +0 -38
  68. data/Gemfile-master +0 -5
  69. data/specs.watchr +0 -59
  70. data/templates/Gemfile-base +0 -17
@@ -2,10 +2,21 @@ module RSpec::Rails::Matchers
2
2
  module RoutingMatchers
3
3
  extend RSpec::Matchers::DSL
4
4
 
5
- matcher :route_to do |route_options|
5
+ matcher :route_to do |*route_options|
6
6
  match_unless_raises ActiveSupport::TestCase::Assertion do |path|
7
7
  assertion_path = { :method => path.keys.first, :path => path.values.first }
8
- assert_recognizes(route_options, assertion_path)
8
+
9
+ path, options = *route_options
10
+
11
+ if path.is_a?(String)
12
+ controller, action = path.split("#")
13
+ options ||= {}
14
+ options.merge!(:controller => controller, :action => action)
15
+ else
16
+ options = path
17
+ end
18
+
19
+ assert_recognizes(options, assertion_path)
9
20
  end
10
21
 
11
22
  failure_message_for_should do
@@ -24,5 +35,15 @@ module RSpec::Rails::Matchers
24
35
  "expected #{path.inspect} not to be routable, but it routes to #{@routing_options.inspect}"
25
36
  end
26
37
  end
38
+
39
+ module RouteHelpers
40
+
41
+ %w(get post put delete options head).each do |method|
42
+ define_method method do |path|
43
+ { method.to_sym => path }
44
+ end
45
+ end
46
+
47
+ end
27
48
  end
28
49
  end
@@ -1,3 +1,6 @@
1
+ require 'active_support/core_ext'
2
+ require 'active_model'
3
+
1
4
  module RSpec
2
5
  module Rails
3
6
 
@@ -41,7 +41,7 @@ namespace :spec do
41
41
  ::CodeStatistics::TEST_TYPES << "Controller specs" if File.exist?('spec/controllers')
42
42
  ::CodeStatistics::TEST_TYPES << "Helper specs" if File.exist?('spec/helpers')
43
43
  ::CodeStatistics::TEST_TYPES << "Library specs" if File.exist?('spec/lib')
44
- ::CodeStatistics::TEST_TYPES << "Mailer specs" if File.exist?('spec/mailer')
44
+ ::CodeStatistics::TEST_TYPES << "Mailer specs" if File.exist?('spec/mailers')
45
45
  ::CodeStatistics::TEST_TYPES << "Routing specs" if File.exist?('spec/routing')
46
46
  ::CodeStatistics::TEST_TYPES << "Request specs" if File.exist?('spec/requests')
47
47
  end
@@ -1,7 +1,7 @@
1
1
  module RSpec # :nodoc:
2
2
  module Rails # :nodoc:
3
3
  module Version # :nodoc:
4
- STRING = '2.5.0'
4
+ STRING = '2.6.0.rc2'
5
5
  end
6
6
  end
7
7
  end
@@ -22,44 +22,13 @@ Gem::Specification.new do |s|
22
22
  s.rdoc_options = ["--charset=UTF-8"]
23
23
  s.require_path = "lib"
24
24
 
25
- s.post_install_message = %Q{**************************************************
26
-
27
- Thank you for installing #{s.summary}!
28
-
29
- This version of rspec-rails only works with versions of rails >= 3.0.0
30
-
31
- To configure your app to use rspec-rails, add a declaration to your Gemfile.
32
- If you are using Bundler's grouping feature in your Gemfile, be sure to include
33
- rspec-rails in the :development group as well as the :test group so that you
34
- can access its generators and rake tasks.
35
-
36
- group :development, :test do
37
- gem "rspec-rails", ">= #{RSpec::Rails::Version::STRING}"
38
- end
39
-
40
- Be sure to run the following command in each of your Rails apps if you're
41
- upgrading:
42
-
43
- script/rails generate rspec:install
44
-
45
- Even if you've run it before, this ensures that you have the latest updates
46
- to spec/spec_helper.rb and any other support files.
47
-
48
- Beta versions of rspec-rails-2 installed files that are no longer being used,
49
- so please remove these files if you have them:
50
-
51
- lib/tasks/rspec.rake
52
- config/initializers/rspec_generator.rb
53
-
54
- Lastly, be sure to look at Upgrade.markdown to see what might have changed
55
- since the last release.
56
-
57
- **************************************************
58
- }
59
-
60
25
  s.add_runtime_dependency(%q<activesupport>, ["~> 3.0"])
61
26
  s.add_runtime_dependency(%q<actionpack>, ["~> 3.0"])
62
27
  s.add_runtime_dependency(%q<railties>, ["~> 3.0"])
63
- s.add_runtime_dependency "rspec", "~> #{RSpec::Rails::Version::STRING.split('.')[0..1].concat(['0']).join('.')}"
28
+ if RSpec::Rails::Version::STRING =~ /[a-zA-Z]+/
29
+ s.add_runtime_dependency "rspec", "= #{RSpec::Rails::Version::STRING}"
30
+ else
31
+ s.add_runtime_dependency "rspec", "~> #{RSpec::Rails::Version::STRING.split('.')[0..1].concat(['0']).join('.')}"
32
+ end
64
33
  end
65
34
 
@@ -26,16 +26,11 @@ describe Autotest::RailsRspec2 do
26
26
  end
27
27
 
28
28
  describe 'mappings' do
29
- before do
30
- rails_rspec2_autotest.find_order = %w(
31
- spec/models/user_spec.rb
32
- spec/support/blueprints.rb
33
- )
34
- end
35
-
36
29
  it 'runs model specs when support files change' do
30
+ rails_rspec2_autotest.find_order = %w(spec/models/user_spec.rb spec/support/blueprints.rb)
37
31
  rails_rspec2_autotest.test_files_for('spec/support/blueprints.rb').should(
38
32
  include('spec/models/user_spec.rb'))
39
33
  end
40
34
  end
35
+
41
36
  end
@@ -35,5 +35,30 @@ module RSpec::Rails
35
35
  example.subject.should == 'explicit'
36
36
  end
37
37
  end
38
+
39
+ describe "with anonymous controller" do
40
+ before do
41
+ group.class_eval do
42
+ controller(Class.new) { }
43
+ end
44
+ end
45
+
46
+ it "delegates named route helpers to the underlying controller" do
47
+ controller = double('controller')
48
+ controller.stub(:foos_url).and_return('http://test.host/foos')
49
+
50
+ example = group.new
51
+ example.stub(:controller => controller)
52
+
53
+ # As in the routing example spec, this is pretty invasive, but not sure
54
+ # how to do it any other way as the correct operation relies on before
55
+ # hooks
56
+ routes = ActionDispatch::Routing::RouteSet.new
57
+ routes.draw { resources :foos }
58
+ example.instance_variable_set(:@orig_routes, routes)
59
+
60
+ example.foos_url.should eq('http://test.host/foos')
61
+ end
62
+ end
38
63
  end
39
64
  end
@@ -2,12 +2,27 @@ require "spec_helper"
2
2
 
3
3
  describe "route_to" do
4
4
  include RSpec::Rails::Matchers::RoutingMatchers
5
+ include RSpec::Rails::Matchers::RoutingMatchers::RouteHelpers
5
6
 
6
7
  it "delegates to assert_recognizes" do
7
8
  self.should_receive(:assert_recognizes).with({ "these" => "options" }, { :method=> :get, :path=>"path" })
8
9
  {:get => "path"}.should route_to("these" => "options")
9
10
  end
10
11
 
12
+ context "with shortcut syntax" do
13
+
14
+ it "routes with extra options" do
15
+ self.should_receive(:assert_recognizes).with({ :controller => "controller", :action => "action", :extra => "options"}, { :method=> :get, :path=>"path" })
16
+ get("path").should route_to("controller#action", :extra => "options")
17
+ end
18
+
19
+ it "routes without extra options" do
20
+ self.should_receive(:assert_recognizes).with({ :controller => "controller", :action => "action"}, { :method=> :get, :path=>"path" })
21
+ get("path").should route_to("controller#action")
22
+ end
23
+
24
+ end
25
+
11
26
  context "with should" do
12
27
  context "when assert_recognizes passes" do
13
28
  it "passes" do
@@ -1,7 +1,10 @@
1
+ ActiveRecord::Base.establish_connection(
2
+ :adapter => 'sqlite3',
3
+ :database => ':memory:'
4
+ )
5
+
1
6
  module Connections
2
7
  def self.extended(host)
3
- host.establish_connection :adapter => 'sqlite3',
4
- :database => ':memory:'
5
8
 
6
9
  host.connection.execute <<-eosql
7
10
  CREATE TABLE #{host.table_name} (
@@ -2,12 +2,6 @@ require "spec_helper"
2
2
 
3
3
  module RSpec::Rails
4
4
  describe ViewRendering do
5
- let(:controller) do
6
- double("controller").tap do |controller|
7
- controller.stub_chain("class.respond_to?").and_return(true)
8
- end
9
- end
10
-
11
5
  let(:group) do
12
6
  RSpec::Core::ExampleGroup.describe do
13
7
  def controller
@@ -5,9 +5,10 @@ generate('integration_test widgets')
5
5
  generate('mailer Notifications signup')
6
6
  generate('model thing name:string')
7
7
  generate('helper things')
8
- generate('scaffold widget name:string category:string instock:boolean')
8
+ generate('scaffold widget name:string category:string instock:boolean --force')
9
9
  generate('observer widget')
10
10
  generate('scaffold gadget') # scaffold with no attributes
11
+ generate('scaffold admin/accounts name:string') # scaffold with nested resource
11
12
 
12
13
  run('rake db:migrate')
13
14
  run('rake db:test:prepare')
@@ -1,4 +1,4 @@
1
- run('bundle exec rspec spec -cfdoc')
1
+ run('rspec spec -cfdoc')
2
2
  run('rake spec')
3
3
  run('rake spec:requests')
4
4
  run('rake spec:models')
@@ -6,4 +6,4 @@ run('rake spec:views')
6
6
  run('rake spec:controllers')
7
7
  run('rake spec:helpers')
8
8
  run('rake spec:mailers')
9
- run('rake stats')
9
+ run("rake stats")
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
4
+ hash: 15424049
5
+ prerelease: 6
6
6
  segments:
7
7
  - 2
8
- - 5
8
+ - 6
9
9
  - 0
10
- version: 2.5.0
10
+ - rc
11
+ - 2
12
+ version: 2.6.0.rc2
11
13
  platform: ruby
12
14
  authors:
13
15
  - David Chelimsky
@@ -15,11 +17,14 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2011-02-05 00:00:00 -06:00
20
+ date: 2011-04-18 00:00:00 -05:00
19
21
  default_executable:
20
22
  dependencies:
21
23
  - !ruby/object:Gem::Dependency
22
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ type: :runtime
26
+ name: activesupport
27
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
28
  none: false
24
29
  requirements:
25
30
  - - ~>
@@ -29,12 +34,12 @@ dependencies:
29
34
  - 3
30
35
  - 0
31
36
  version: "3.0"
32
- type: :runtime
33
- name: activesupport
34
- prerelease: false
35
- version_requirements: *id001
37
+ requirement: *id001
36
38
  - !ruby/object:Gem::Dependency
37
- requirement: &id002 !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ type: :runtime
41
+ name: actionpack
42
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
43
  none: false
39
44
  requirements:
40
45
  - - ~>
@@ -44,12 +49,12 @@ dependencies:
44
49
  - 3
45
50
  - 0
46
51
  version: "3.0"
47
- type: :runtime
48
- name: actionpack
49
- prerelease: false
50
- version_requirements: *id002
52
+ requirement: *id002
51
53
  - !ruby/object:Gem::Dependency
52
- requirement: &id003 !ruby/object:Gem::Requirement
54
+ prerelease: false
55
+ type: :runtime
56
+ name: railties
57
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
58
  none: false
54
59
  requirements:
55
60
  - - ~>
@@ -59,26 +64,25 @@ dependencies:
59
64
  - 3
60
65
  - 0
61
66
  version: "3.0"
62
- type: :runtime
63
- name: railties
64
- prerelease: false
65
- version_requirements: *id003
67
+ requirement: *id003
66
68
  - !ruby/object:Gem::Dependency
67
- requirement: &id004 !ruby/object:Gem::Requirement
69
+ prerelease: false
70
+ type: :runtime
71
+ name: rspec
72
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
73
  none: false
69
74
  requirements:
70
- - - ~>
75
+ - - "="
71
76
  - !ruby/object:Gem::Version
72
- hash: 27
77
+ hash: 15424049
73
78
  segments:
74
79
  - 2
75
- - 5
80
+ - 6
76
81
  - 0
77
- version: 2.5.0
78
- type: :runtime
79
- name: rspec
80
- prerelease: false
81
- version_requirements: *id004
82
+ - rc
83
+ - 2
84
+ version: 2.6.0.rc2
85
+ requirement: *id004
82
86
  description: RSpec-2 for Rails-3
83
87
  email: dchelimsky@gmail.com
84
88
  executables: []
@@ -91,14 +95,11 @@ files:
91
95
  - .document
92
96
  - .gitignore
93
97
  - .rspec
94
- - Gemfile-3-0-stable
95
- - Gemfile-3.0.0
96
- - Gemfile-3.0.3
97
- - Gemfile-base
98
- - Gemfile-master
98
+ - .travis.yml
99
99
  - History.md
100
100
  - License.txt
101
101
  - README.md
102
+ - README_DEV.md
102
103
  - Rakefile
103
104
  - Thorfile
104
105
  - Upgrade.md
@@ -136,6 +137,16 @@ files:
136
137
  - features/view_specs/inferred_controller_path.feature
137
138
  - features/view_specs/stub_template.feature
138
139
  - features/view_specs/view_spec.feature
140
+ - gemfiles/base.rb
141
+ - gemfiles/rails-3-0-stable
142
+ - gemfiles/rails-3.0.0
143
+ - gemfiles/rails-3.0.1
144
+ - gemfiles/rails-3.0.2
145
+ - gemfiles/rails-3.0.3
146
+ - gemfiles/rails-3.0.4
147
+ - gemfiles/rails-3.0.5
148
+ - gemfiles/rails-3.0.6
149
+ - gemfiles/rails-master
139
150
  - lib/autotest/rails_rspec2.rb
140
151
  - lib/generators/rspec.rb
141
152
  - lib/generators/rspec/controller/controller_generator.rb
@@ -222,49 +233,13 @@ files:
222
233
  - spec/rspec/rails/view_rendering_spec.rb
223
234
  - spec/spec_helper.rb
224
235
  - spec/support/helpers.rb
225
- - specs.watchr
226
- - templates/Gemfile-base
227
236
  - templates/generate_stuff.rb
228
237
  - templates/run_specs.rb
229
238
  has_rdoc: true
230
239
  homepage: http://github.com/rspec/rspec-rails
231
240
  licenses: []
232
241
 
233
- post_install_message: |
234
- **************************************************
235
-
236
- Thank you for installing rspec-rails-2.5.0!
237
-
238
- This version of rspec-rails only works with versions of rails >= 3.0.0
239
-
240
- To configure your app to use rspec-rails, add a declaration to your Gemfile.
241
- If you are using Bundler's grouping feature in your Gemfile, be sure to include
242
- rspec-rails in the :development group as well as the :test group so that you
243
- can access its generators and rake tasks.
244
-
245
- group :development, :test do
246
- gem "rspec-rails", ">= 2.5.0"
247
- end
248
-
249
- Be sure to run the following command in each of your Rails apps if you're
250
- upgrading:
251
-
252
- script/rails generate rspec:install
253
-
254
- Even if you've run it before, this ensures that you have the latest updates
255
- to spec/spec_helper.rb and any other support files.
256
-
257
- Beta versions of rspec-rails-2 installed files that are no longer being used,
258
- so please remove these files if you have them:
259
-
260
- lib/tasks/rspec.rake
261
- config/initializers/rspec_generator.rb
262
-
263
- Lastly, be sure to look at Upgrade.markdown to see what might have changed
264
- since the last release.
265
-
266
- **************************************************
267
-
242
+ post_install_message:
268
243
  rdoc_options:
269
244
  - --charset=UTF-8
270
245
  require_paths:
@@ -281,19 +256,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
256
  required_rubygems_version: !ruby/object:Gem::Requirement
282
257
  none: false
283
258
  requirements:
284
- - - ">="
259
+ - - ">"
285
260
  - !ruby/object:Gem::Version
286
- hash: 3
261
+ hash: 25
287
262
  segments:
288
- - 0
289
- version: "0"
263
+ - 1
264
+ - 3
265
+ - 1
266
+ version: 1.3.1
290
267
  requirements: []
291
268
 
292
269
  rubyforge_project: rspec
293
- rubygems_version: 1.3.7
270
+ rubygems_version: 1.5.2
294
271
  signing_key:
295
272
  specification_version: 3
296
- summary: rspec-rails-2.5.0
273
+ summary: rspec-rails-2.6.0.rc2
297
274
  test_files:
298
275
  - features/Autotest.md
299
276
  - features/Changelog.md