rspec-rails 2.99.0.beta1 → 2.99.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +8 -8
  2. data/Changelog.md +18 -0
  3. data/features/controller_specs/capybara.feature +44 -0
  4. data/features/controller_specs/render_views.feature +1 -1
  5. data/lib/autotest/rails_rspec2.rb +1 -0
  6. data/lib/generators/rspec/install/templates/spec/spec_helper.rb.tt +0 -1
  7. data/lib/generators/rspec/integration/integration_generator.rb +3 -2
  8. data/lib/generators/rspec/scaffold/scaffold_generator.rb +3 -2
  9. data/lib/rspec/rails/adapters.rb +12 -5
  10. data/lib/rspec/rails/example/controller_example_group.rb +2 -1
  11. data/lib/rspec/rails/example/view_example_group.rb +3 -0
  12. data/lib/rspec/rails/matchers/have_extension.rb +1 -0
  13. data/lib/rspec/rails/matchers/relation_match_array.rb +1 -1
  14. data/lib/rspec/rails/matchers/routing_matchers.rb +4 -0
  15. data/lib/rspec/rails/mocks.rb +22 -0
  16. data/lib/rspec/rails/vendor/capybara.rb +35 -4
  17. data/lib/rspec/rails/version.rb +1 -1
  18. data/spec/autotest/rails_rspec2_spec.rb +5 -5
  19. data/spec/generators/rspec/controller/controller_generator_spec.rb +16 -16
  20. data/spec/generators/rspec/helper/helper_generator_spec.rb +4 -4
  21. data/spec/generators/rspec/install/install_generator_spec.rb +4 -4
  22. data/spec/generators/rspec/integration/integration_generator_spec.rb +18 -5
  23. data/spec/generators/rspec/mailer/mailer_generator_spec.rb +11 -11
  24. data/spec/generators/rspec/model/model_generator_spec.rb +7 -7
  25. data/spec/generators/rspec/observer/observer_generator_spec.rb +3 -3
  26. data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +46 -34
  27. data/spec/generators/rspec/view/view_generator_spec.rb +6 -6
  28. data/spec/rspec/rails/assertion_adapter_spec.rb +3 -3
  29. data/spec/rspec/rails/configuration_spec.rb +2 -2
  30. data/spec/rspec/rails/deprecations_spec.rb +1 -1
  31. data/spec/rspec/rails/example/controller_example_group_spec.rb +47 -21
  32. data/spec/rspec/rails/example/feature_example_group_spec.rb +2 -2
  33. data/spec/rspec/rails/example/helper_example_group_spec.rb +12 -12
  34. data/spec/rspec/rails/example/mailer_example_group_spec.rb +3 -3
  35. data/spec/rspec/rails/example/model_example_group_spec.rb +3 -3
  36. data/spec/rspec/rails/example/request_example_group_spec.rb +5 -5
  37. data/spec/rspec/rails/example/routing_example_group_spec.rb +5 -5
  38. data/spec/rspec/rails/example/view_example_group_spec.rb +44 -29
  39. data/spec/rspec/rails/extensions/active_model/errors_on_spec.rb +3 -3
  40. data/spec/rspec/rails/fixture_support_spec.rb +3 -3
  41. data/spec/rspec/rails/matchers/be_a_new_spec.rb +17 -17
  42. data/spec/rspec/rails/matchers/be_new_record_spec.rb +2 -2
  43. data/spec/rspec/rails/matchers/be_routable_spec.rb +8 -8
  44. data/spec/rspec/rails/matchers/be_valid_spec.rb +3 -4
  45. data/spec/rspec/rails/matchers/errors_on_spec.rb +12 -12
  46. data/spec/rspec/rails/matchers/has_spec.rb +1 -1
  47. data/spec/rspec/rails/matchers/have_rendered_spec.rb +3 -3
  48. data/spec/rspec/rails/matchers/redirect_to_spec.rb +7 -6
  49. data/spec/rspec/rails/matchers/relation_match_array_spec.rb +5 -5
  50. data/spec/rspec/rails/matchers/route_to_spec.rb +21 -21
  51. data/spec/rspec/rails/minitest_lifecycle_adapter_spec.rb +9 -0
  52. data/spec/rspec/rails/mocks/mock_model_spec.rb +80 -57
  53. data/spec/rspec/rails/mocks/stub_model_spec.rb +23 -23
  54. data/spec/rspec/rails/setup_and_teardown_adapter_spec.rb +4 -4
  55. data/spec/rspec/rails/view_rendering_spec.rb +14 -14
  56. data/spec/spec_helper.rb +1 -0
  57. data/spec/support/helpers.rb +15 -1
  58. metadata +29 -13
@@ -8,7 +8,7 @@ describe "stub_model" do
8
8
  model = stub_model(model_class) do |block_arg|
9
9
  @block_arg = block_arg
10
10
  end
11
- model.should be(@block_arg)
11
+ expect(model).to be(@block_arg)
12
12
  end
13
13
  end
14
14
 
@@ -16,14 +16,14 @@ describe "stub_model" do
16
16
  context "default" do
17
17
  it "returns true" do
18
18
  model = stub_model(model_class)
19
- model.should be_persisted
19
+ expect(model).to be_persisted
20
20
  end
21
21
  end
22
22
 
23
23
  context "with as_new_record" do
24
24
  it "returns false" do
25
25
  model = stub_model(model_class).as_new_record
26
- model.should_not be_persisted
26
+ expect(model).not_to be_persisted
27
27
  end
28
28
  end
29
29
  end
@@ -31,12 +31,12 @@ describe "stub_model" do
31
31
  it "increments the value returned by to_param" do
32
32
  first = stub_model(model_class)
33
33
  second = stub_model(model_class)
34
- second.to_param.to_i.should == (first.to_param.to_i + 1)
34
+ expect(second.to_param.to_i).to eq(first.to_param.to_i + 1)
35
35
  end
36
36
 
37
37
  describe "#blank?" do
38
38
  it "is false" do
39
- stub_model(model_class).should_not be_blank
39
+ expect(stub_model(model_class)).not_to be_blank
40
40
  end
41
41
  end
42
42
  end
@@ -58,79 +58,79 @@ describe "stub_model" do
58
58
  context "default" do
59
59
  it "returns false" do
60
60
  model = stub_model(model_class)
61
- model.new_record?.should be_falsey
61
+ expect(model.new_record?).to be_falsey
62
62
  end
63
63
  end
64
64
 
65
65
  context "with as_new_record" do
66
66
  it "returns true" do
67
67
  model = stub_model(model_class).as_new_record
68
- model.new_record?.should be_truthy
68
+ expect(model.new_record?).to be_truthy
69
69
  end
70
70
  end
71
71
  end
72
72
 
73
73
  describe "defaults" do
74
74
  it "has an id" do
75
- stub_model(MockableModel).id.should be > 0
75
+ expect(stub_model(MockableModel).id).to be > 0
76
76
  end
77
77
 
78
78
  it "says it is not a new record" do
79
- stub_model(MockableModel).should_not be_new_record
79
+ expect(stub_model(MockableModel)).not_to be_new_record
80
80
  end
81
81
  end
82
82
 
83
83
  describe "#as_new_record" do
84
84
  it "has a nil id" do
85
- stub_model(MockableModel).as_new_record.id.should be(nil)
85
+ expect(stub_model(MockableModel).as_new_record.id).to be(nil)
86
86
  end
87
87
  end
88
88
 
89
89
  it "raises when hitting the db" do
90
- lambda do
90
+ expect do
91
91
  stub_model(MockableModel).connection
92
- end.should raise_error(RSpec::Rails::IllegalDataAccessException, /stubbed models are not allowed to access the database/)
92
+ end.to raise_error(RSpec::Rails::IllegalDataAccessException, /stubbed models are not allowed to access the database/)
93
93
  end
94
94
 
95
95
  it "increments the id" do
96
96
  first = stub_model(model_class)
97
97
  second = stub_model(model_class)
98
- second.id.should == (first.id + 1)
98
+ expect(second.id).to eq(first.id + 1)
99
99
  end
100
100
 
101
101
  it "accepts a stub id" do
102
- stub_model(MockableModel, :id => 37).id.should == 37
102
+ expect(stub_model(MockableModel, :id => 37).id).to eq(37)
103
103
  end
104
104
 
105
105
  it "says it is a new record when id is set to nil" do
106
- stub_model(MockableModel, :id => nil).should be_new_record
106
+ expect(stub_model(MockableModel, :id => nil)).to be_new_record
107
107
  end
108
108
 
109
109
  it "accepts a stub for save" do
110
- stub_model(MockableModel, :save => false).save.should be(false)
110
+ expect(stub_model(MockableModel, :save => false).save).to be(false)
111
111
  end
112
112
 
113
113
  describe "alternate primary key" do
114
114
  it "has the correct primary_key name" do
115
- stub_model(AlternatePrimaryKeyModel).class.primary_key.to_s.should eq('my_id')
115
+ expect(stub_model(AlternatePrimaryKeyModel).class.primary_key.to_s).to eq('my_id')
116
116
  end
117
117
 
118
118
  it "has a primary_key" do
119
- stub_model(AlternatePrimaryKeyModel).my_id.should be > 0
119
+ expect(stub_model(AlternatePrimaryKeyModel).my_id).to be > 0
120
120
  end
121
121
 
122
122
  it "says it is not a new record" do
123
123
  stub_model(AlternatePrimaryKeyModel) do |m|
124
- m.should_not be_new_record
124
+ expect(m).not_to be_new_record
125
125
  end
126
126
  end
127
127
 
128
128
  it "says it is a new record if primary_key is nil" do
129
- stub_model(AlternatePrimaryKeyModel, :my_id => nil).should be_new_record
129
+ expect(stub_model(AlternatePrimaryKeyModel, :my_id => nil)).to be_new_record
130
130
  end
131
131
 
132
132
  it "accepts a stub for the primary_key" do
133
- stub_model(AlternatePrimaryKeyModel, :my_id => 5).my_id.should == 5
133
+ expect(stub_model(AlternatePrimaryKeyModel, :my_id => 5).my_id).to eq(5)
134
134
  end
135
135
  end
136
136
 
@@ -142,11 +142,11 @@ describe "stub_model" do
142
142
  end
143
143
 
144
144
  it "passes associated_model == mock" do
145
- @stub_model.should == @real.mockable_model
145
+ expect(@stub_model).to eq(@real.mockable_model)
146
146
  end
147
147
 
148
148
  it "passes mock == associated_model" do
149
- @real.mockable_model.should == @stub_model
149
+ expect(@real.mockable_model).to eq(@stub_model)
150
150
  end
151
151
  end
152
152
 
@@ -8,8 +8,8 @@ describe RSpec::Rails::SetupAndTeardownAdapter do
8
8
  def self.foo; "foo"; end
9
9
  def self.bar; "bar"; end
10
10
  end
11
- klass.should_receive(:before).ordered { |&block| block.call.should eq "foo" }
12
- klass.should_receive(:before).ordered { |&block| block.call.should eq "bar" }
11
+ expect(klass).to receive(:before).ordered { |&block| expect(block.call).to eq "foo" }
12
+ expect(klass).to receive(:before).ordered { |&block| expect(block.call).to eq "bar" }
13
13
 
14
14
  klass.setup :foo
15
15
  klass.setup :bar
@@ -22,8 +22,8 @@ describe RSpec::Rails::SetupAndTeardownAdapter do
22
22
  def self.setup_controller_request_and_response; "setup controller" end
23
23
  end
24
24
 
25
- klass.should_receive(:prepend_before) { |&block| block.call.should eq "setup fixtures" }
26
- klass.should_receive(:prepend_before) { |&block| block.call.should eq "setup controller" }
25
+ expect(klass).to receive(:prepend_before) { |&block| expect(block.call).to eq "setup fixtures" }
26
+ expect(klass).to receive(:prepend_before) { |&block| expect(block.call).to eq "setup controller" }
27
27
 
28
28
  klass.setup :setup_fixtures
29
29
  klass.setup :setup_controller_request_and_response
@@ -14,11 +14,11 @@ module RSpec::Rails
14
14
  context "default" do
15
15
  context "ActionController::Base" do
16
16
  it "does not render views" do
17
- group.new.render_views?.should be_falsey
17
+ expect(group.new.render_views?).to be_falsey
18
18
  end
19
19
 
20
20
  it "does not render views in a nested group" do
21
- group.describe{}.new.render_views?.should be_falsey
21
+ expect(group.describe{}.new.render_views?).to be_falsey
22
22
  end
23
23
  end
24
24
 
@@ -28,7 +28,7 @@ module RSpec::Rails
28
28
  def example.controller
29
29
  ActionController::Metal.new
30
30
  end
31
- example.render_views?.should be_truthy
31
+ expect(example.render_views?).to be_truthy
32
32
  end
33
33
  end
34
34
  end
@@ -38,27 +38,27 @@ module RSpec::Rails
38
38
  context "with no args" do
39
39
  it "tells examples to render views" do
40
40
  group.render_views
41
- group.new.render_views?.should be_truthy
41
+ expect(group.new.render_views?).to be_truthy
42
42
  end
43
43
  end
44
44
 
45
45
  context "with true" do
46
46
  it "tells examples to render views" do
47
47
  group.render_views true
48
- group.new.render_views?.should be_truthy
48
+ expect(group.new.render_views?).to be_truthy
49
49
  end
50
50
  end
51
51
 
52
52
  context "with false" do
53
53
  it "tells examples not to render views" do
54
54
  group.render_views false
55
- group.new.render_views?.should be_falsey
55
+ expect(group.new.render_views?).to be_falsey
56
56
  end
57
57
 
58
58
  it "overrides the global config if render_views is enabled there" do
59
- RSpec.configuration.stub(:render_views?).and_return true
59
+ allow(RSpec.configuration).to receive(:render_views?).and_return true
60
60
  group.render_views false
61
- group.new.render_views?.should be_falsey
61
+ expect(group.new.render_views?).to be_falsey
62
62
  end
63
63
  end
64
64
 
@@ -70,40 +70,40 @@ module RSpec::Rails
70
70
  context "with no args" do
71
71
  it "tells examples to render views" do
72
72
  nested_group.render_views
73
- nested_group.new.render_views?.should be_truthy
73
+ expect(nested_group.new.render_views?).to be_truthy
74
74
  end
75
75
  end
76
76
 
77
77
  context "with true" do
78
78
  it "tells examples to render views" do
79
79
  nested_group.render_views true
80
- nested_group.new.render_views?.should be_truthy
80
+ expect(nested_group.new.render_views?).to be_truthy
81
81
  end
82
82
  end
83
83
 
84
84
  context "with false" do
85
85
  it "tells examples not to render views" do
86
86
  nested_group.render_views false
87
- nested_group.new.render_views?.should be_falsey
87
+ expect(nested_group.new.render_views?).to be_falsey
88
88
  end
89
89
  end
90
90
 
91
91
  it "leaves the parent group as/is" do
92
92
  group.render_views
93
93
  nested_group.render_views false
94
- group.new.render_views?.should be_truthy
94
+ expect(group.new.render_views?).to be_truthy
95
95
  end
96
96
 
97
97
  it "overrides the value inherited from the parent group" do
98
98
  group.render_views
99
99
  nested_group.render_views false
100
- nested_group.new.render_views?.should be_falsey
100
+ expect(nested_group.new.render_views?).to be_falsey
101
101
  end
102
102
 
103
103
  it "passes override to children" do
104
104
  group.render_views
105
105
  nested_group.render_views false
106
- nested_group.describe{}.new.render_views?.should be_falsey
106
+ expect(nested_group.describe{}.new.render_views?).to be_falsey
107
107
  end
108
108
  end
109
109
  end
@@ -2,6 +2,7 @@ require 'rails/all'
2
2
 
3
3
  module RSpecRails
4
4
  class Application < ::Rails::Application
5
+ self.config.secret_key_base = 'ASecretString' if config.respond_to? :secret_key_base
5
6
  end
6
7
  end
7
8
 
@@ -1,7 +1,7 @@
1
1
  module Helpers
2
2
  def stub_metadata(additional_metadata)
3
3
  stub_metadata = metadata_with(additional_metadata)
4
- RSpec::Core::ExampleGroup.stub(:metadata) { stub_metadata }
4
+ allow(RSpec::Core::ExampleGroup).to receive(:metadata) { stub_metadata }
5
5
  end
6
6
 
7
7
  def metadata_with(additional_metadata)
@@ -16,5 +16,19 @@ module Helpers
16
16
  m
17
17
  end
18
18
 
19
+ def with_isolated_config
20
+ original_config = RSpec.configuration
21
+ RSpec.configuration = RSpec::Core::Configuration.new
22
+ RSpec.configure do |c|
23
+ c.include RSpec::Rails::FixtureSupport
24
+ c.add_setting :use_transactional_fixtures, :alias_with => :use_transactional_examples
25
+ c.add_setting :use_instantiated_fixtures
26
+ c.add_setting :global_fixtures
27
+ c.add_setting :fixture_path
28
+ end
29
+ yield
30
+ RSpec.configuration = original_config
31
+ end
32
+
19
33
  RSpec.configure {|c| c.include self}
20
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.99.0.beta1
4
+ version: 2.99.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-07 00:00:00.000000000 Z
11
+ date: 2014-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -72,42 +72,56 @@ dependencies:
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 2.99.0.beta1
75
+ version: 2.99.0.beta2
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 2.99.0.beta1
82
+ version: 2.99.0.beta2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-expectations
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: 2.99.0.beta1
89
+ version: 2.99.0.beta2
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: 2.99.0.beta1
96
+ version: 2.99.0.beta2
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec-mocks
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 2.99.0.beta1
103
+ version: 2.99.0.beta2
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 2.99.0.beta1
110
+ version: 2.99.0.beta2
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-collection_matchers
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rake
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -154,16 +168,16 @@ dependencies:
154
168
  name: ZenTest
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
- - - '='
171
+ - - ~>
158
172
  - !ruby/object:Gem::Version
159
- version: 4.9.0
173
+ version: 4.9.5
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
- - - '='
178
+ - - ~>
165
179
  - !ruby/object:Gem::Version
166
- version: 4.9.0
180
+ version: 4.9.5
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: ammeter
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -278,6 +292,7 @@ files:
278
292
  - features/controller_specs/README.md
279
293
  - features/controller_specs/anonymous_controller.feature
280
294
  - features/controller_specs/bypass_rescue.feature
295
+ - features/controller_specs/capybara.feature
281
296
  - features/controller_specs/controller_spec.feature
282
297
  - features/controller_specs/engine_routes.feature
283
298
  - features/controller_specs/isolation_from_views.feature
@@ -379,7 +394,7 @@ rubyforge_project: rspec
379
394
  rubygems_version: 2.0.7
380
395
  signing_key:
381
396
  specification_version: 4
382
- summary: rspec-rails-2.99.0.beta1
397
+ summary: rspec-rails-2.99.0.beta2
383
398
  test_files:
384
399
  - features/Autotest.md
385
400
  - features/Generators.md
@@ -392,6 +407,7 @@ test_files:
392
407
  - features/controller_specs/README.md
393
408
  - features/controller_specs/anonymous_controller.feature
394
409
  - features/controller_specs/bypass_rescue.feature
410
+ - features/controller_specs/capybara.feature
395
411
  - features/controller_specs/controller_spec.feature
396
412
  - features/controller_specs/engine_routes.feature
397
413
  - features/controller_specs/isolation_from_views.feature