rspec-rails 2.99.0.beta1 → 2.99.0.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -2,8 +2,8 @@ require "spec_helper"
2
2
 
3
3
  module RSpec::Rails
4
4
  describe FeatureExampleGroup do
5
- it { should be_included_in_files_in('./spec/features/') }
6
- it { should be_included_in_files_in('.\\spec\\features\\') }
5
+ it { is_expected.to be_included_in_files_in('./spec/features/') }
6
+ it { is_expected.to be_included_in_files_in('.\\spec\\features\\') }
7
7
 
8
8
  it "adds :type => :feature to the metadata" do
9
9
  group = RSpec::Core::ExampleGroup.describe do
@@ -5,32 +5,32 @@ module RSpec::Rails
5
5
  module ::FoosHelper; end
6
6
  subject { HelperExampleGroup }
7
7
 
8
- it { should be_included_in_files_in('./spec/helpers/') }
9
- it { should be_included_in_files_in('.\\spec\\helpers\\') }
8
+ it { is_expected.to be_included_in_files_in('./spec/helpers/') }
9
+ it { is_expected.to be_included_in_files_in('.\\spec\\helpers\\') }
10
10
 
11
11
  it "provides a controller_path based on the helper module's name" do
12
12
  example = double
13
13
  example.stub_chain(:example_group, :described_class) { FoosHelper }
14
14
 
15
15
  helper_spec = Object.new.extend HelperExampleGroup
16
- helper_spec.__send__(:_controller_path, example).should == "foos"
16
+ expect(helper_spec.__send__(:_controller_path, example)).to eq("foos")
17
17
  end
18
18
 
19
19
  it "adds :type => :helper to the metadata" do
20
20
  group = RSpec::Core::ExampleGroup.describe do
21
21
  include HelperExampleGroup
22
22
  end
23
- group.metadata[:type].should eq(:helper)
23
+ expect(group.metadata[:type]).to eq(:helper)
24
24
  end
25
25
 
26
26
  describe "#helper" do
27
27
  it "returns the instance of AV::Base provided by AV::TC::Behavior" do
28
28
  helper_spec = Object.new.extend HelperExampleGroup
29
- helper_spec.should_receive(:view_assigns)
29
+ expect(helper_spec).to receive(:view_assigns)
30
30
  av_tc_b_view = double('_view')
31
- av_tc_b_view.should_receive(:assign)
32
- helper_spec.stub(:_view) { av_tc_b_view }
33
- helper_spec.helper.should eq(av_tc_b_view)
31
+ expect(av_tc_b_view).to receive(:assign)
32
+ allow(helper_spec).to receive(:_view) { av_tc_b_view }
33
+ expect(helper_spec.helper).to eq(av_tc_b_view)
34
34
  end
35
35
 
36
36
  before do
@@ -48,7 +48,7 @@ module RSpec::Rails
48
48
  ActionView::Base.new
49
49
  end
50
50
  end
51
- group.new.helper.should be_kind_of(ApplicationHelper)
51
+ expect(group.new.helper).to be_kind_of(ApplicationHelper)
52
52
  end
53
53
  end
54
54
  end
@@ -57,9 +57,9 @@ module RSpec::Rails
57
57
  describe "determine_default_helper_class" do
58
58
  it "returns the helper module passed to describe" do
59
59
  helper_spec = Object.new.extend HelperExampleGroup::ClassMethods
60
- helper_spec.stub(:described_class) { FoosHelper }
61
- helper_spec.determine_default_helper_class("ignore this").
62
- should eq(FoosHelper)
60
+ allow(helper_spec).to receive(:described_class) { FoosHelper }
61
+ expect(helper_spec.determine_default_helper_class("ignore this")).
62
+ to eq(FoosHelper)
63
63
  end
64
64
  end
65
65
  end
@@ -8,14 +8,14 @@ module RSpec::Rails
8
8
  Rails.stub_chain(:configuration, :action_mailer, :default_url_options).and_return({})
9
9
  end
10
10
 
11
- it { should be_included_in_files_in('./spec/mailers/') }
12
- it { should be_included_in_files_in('.\\spec\\mailers\\') }
11
+ it { is_expected.to be_included_in_files_in('./spec/mailers/') }
12
+ it { is_expected.to be_included_in_files_in('.\\spec\\mailers\\') }
13
13
 
14
14
  it "adds :type => :mailer to the metadata" do
15
15
  group = RSpec::Core::ExampleGroup.describe do
16
16
  include MailerExampleGroup
17
17
  end
18
- group.metadata[:type].should eq(:mailer)
18
+ expect(group.metadata[:type]).to eq(:mailer)
19
19
  end
20
20
  end
21
21
  end
@@ -2,14 +2,14 @@ require "spec_helper"
2
2
 
3
3
  module RSpec::Rails
4
4
  describe ModelExampleGroup do
5
- it { should be_included_in_files_in('./spec/models/') }
6
- it { should be_included_in_files_in('.\\spec\\models\\') }
5
+ it { is_expected.to be_included_in_files_in('./spec/models/') }
6
+ it { is_expected.to be_included_in_files_in('.\\spec\\models\\') }
7
7
 
8
8
  it "adds :type => :model to the metadata" do
9
9
  group = RSpec::Core::ExampleGroup.describe do
10
10
  include ModelExampleGroup
11
11
  end
12
- group.metadata[:type].should eq(:model)
12
+ expect(group.metadata[:type]).to eq(:model)
13
13
  end
14
14
  end
15
15
  end
@@ -2,16 +2,16 @@ require "spec_helper"
2
2
 
3
3
  module RSpec::Rails
4
4
  describe RequestExampleGroup do
5
- it { should be_included_in_files_in('./spec/requests/') }
6
- it { should be_included_in_files_in('./spec/integration/') }
7
- it { should be_included_in_files_in('.\\spec\\requests\\') }
8
- it { should be_included_in_files_in('.\\spec\\integration\\') }
5
+ it { is_expected.to be_included_in_files_in('./spec/requests/') }
6
+ it { is_expected.to be_included_in_files_in('./spec/integration/') }
7
+ it { is_expected.to be_included_in_files_in('.\\spec\\requests\\') }
8
+ it { is_expected.to be_included_in_files_in('.\\spec\\integration\\') }
9
9
 
10
10
  it "adds :type => :request to the metadata" do
11
11
  group = RSpec::Core::ExampleGroup.describe do
12
12
  include RequestExampleGroup
13
13
  end
14
- group.metadata[:type].should eq(:request)
14
+ expect(group.metadata[:type]).to eq(:request)
15
15
  end
16
16
  end
17
17
  end
@@ -2,14 +2,14 @@ require "spec_helper"
2
2
 
3
3
  module RSpec::Rails
4
4
  describe RoutingExampleGroup do
5
- it { should be_included_in_files_in('./spec/routing/') }
6
- it { should be_included_in_files_in('.\\spec\\routing\\') }
5
+ it { is_expected.to be_included_in_files_in('./spec/routing/') }
6
+ it { is_expected.to be_included_in_files_in('.\\spec\\routing\\') }
7
7
 
8
8
  it "adds :type => :routing to the metadata" do
9
9
  group = RSpec::Core::ExampleGroup.describe do
10
10
  include RoutingExampleGroup
11
11
  end
12
- group.metadata[:type].should eq(:routing)
12
+ expect(group.metadata[:type]).to eq(:routing)
13
13
  end
14
14
 
15
15
  describe "named routes" do
@@ -23,9 +23,9 @@ module RSpec::Rails
23
23
  # Yes, this is quite invasive
24
24
  url_helpers = double('url_helpers', :foo_path => "foo")
25
25
  routes = double('routes', :url_helpers => url_helpers)
26
- example.stub(:routes => routes)
26
+ allow(example).to receive(:routes).and_return(routes)
27
27
 
28
- example.foo_path.should == "foo"
28
+ expect(example.foo_path).to eq("foo")
29
29
  end
30
30
  end
31
31
  end
@@ -2,14 +2,14 @@ require "spec_helper"
2
2
 
3
3
  module RSpec::Rails
4
4
  describe ViewExampleGroup do
5
- it { should be_included_in_files_in('./spec/views/') }
6
- it { should be_included_in_files_in('.\\spec\\views\\') }
5
+ it { is_expected.to be_included_in_files_in('./spec/views/') }
6
+ it { is_expected.to be_included_in_files_in('.\\spec\\views\\') }
7
7
 
8
8
  it "adds :type => :view to the metadata" do
9
9
  group = RSpec::Core::ExampleGroup.describe do
10
10
  include ViewExampleGroup
11
11
  end
12
- group.metadata[:type].should eq(:view)
12
+ expect(group.metadata[:type]).to eq(:view)
13
13
  end
14
14
 
15
15
  describe 'automatic inclusion of helpers' do
@@ -18,7 +18,7 @@ module RSpec::Rails
18
18
 
19
19
  it 'includes the helper with the same name' do
20
20
  group = RSpec::Core::ExampleGroup.describe 'things/show.html.erb'
21
- group.should_receive(:helper).with(ThingsHelper)
21
+ expect(group).to receive(:helper).with(ThingsHelper)
22
22
  group.class_eval do
23
23
  include ViewExampleGroup
24
24
  end
@@ -26,7 +26,7 @@ module RSpec::Rails
26
26
 
27
27
  it 'includes the namespaced helper with the same name' do
28
28
  group = RSpec::Core::ExampleGroup.describe 'namespaced/things/show.html.erb'
29
- group.should_receive(:helper).with(Namespaced::ThingsHelper)
29
+ expect(group).to receive(:helper).with(Namespaced::ThingsHelper)
30
30
  group.class_eval do
31
31
  include ViewExampleGroup
32
32
  end
@@ -34,11 +34,11 @@ module RSpec::Rails
34
34
 
35
35
  it 'operates normally when no helper with the same name exists' do
36
36
  raise 'unexpected constant found' if Object.const_defined?('ClocksHelper')
37
- lambda {
37
+ expect {
38
38
  RSpec::Core::ExampleGroup.describe 'clocks/show.html.erb' do
39
39
  include ViewExampleGroup
40
40
  end
41
- }.should_not raise_error
41
+ }.not_to raise_error
42
42
  end
43
43
 
44
44
  context 'application helper exists' do
@@ -57,7 +57,7 @@ module RSpec::Rails
57
57
 
58
58
  it 'includes the application helper' do
59
59
  group = RSpec::Core::Example.describe 'bars/new.html.erb'
60
- group.should_receive(:helper).with(ApplicationHelper)
60
+ expect(group).to receive(:helper).with(ApplicationHelper)
61
61
  group.class_eval do
62
62
  include ViewExampleGroup
63
63
  end
@@ -79,11 +79,11 @@ module RSpec::Rails
79
79
  end
80
80
 
81
81
  it 'operates normally' do
82
- lambda {
82
+ expect {
83
83
  RSpec::Core::ExampleGroup.describe 'foos/edit.html.erb' do
84
84
  include ViewExampleGroup
85
85
  end
86
- }.should_not raise_error
86
+ }.not_to raise_error
87
87
  end
88
88
  end
89
89
  end
@@ -109,19 +109,19 @@ module RSpec::Rails
109
109
 
110
110
  context "given no input" do
111
111
  it "sends render(:template => (described file)) to the view" do
112
- view_spec.stub(:_default_file_to_render) { "widgets/new" }
112
+ allow(view_spec).to receive(:_default_file_to_render) { "widgets/new" }
113
113
  view_spec.render
114
- view_spec.received.first.should == [{:template => "widgets/new"},{}, nil]
114
+ expect(view_spec.received.first).to eq([{:template => "widgets/new"},{}, nil])
115
115
  end
116
116
 
117
117
  it "converts the filename components into render options" do
118
- view_spec.stub(:_default_file_to_render) { "widgets/new.en.html.erb" }
118
+ allow(view_spec).to receive(:_default_file_to_render) { "widgets/new.en.html.erb" }
119
119
  view_spec.render
120
120
 
121
121
  if ::Rails::VERSION::STRING >= '3.2'
122
- view_spec.received.first.should == [{:template => "widgets/new", :locales=>['en'], :formats=>['html'], :handlers=>['erb']}, {}, nil]
122
+ expect(view_spec.received.first).to eq([{:template => "widgets/new", :locales=>['en'], :formats=>['html'], :handlers=>['erb']}, {}, nil])
123
123
  else
124
- view_spec.received.first.should == [{:template => "widgets/new.en.html.erb"}, {}, nil]
124
+ expect(view_spec.received.first).to eq([{:template => "widgets/new.en.html.erb"}, {}, nil])
125
125
  end
126
126
  end
127
127
  end
@@ -129,14 +129,14 @@ module RSpec::Rails
129
129
  context "given a string" do
130
130
  it "sends string as the first arg to render" do
131
131
  view_spec.render('arbitrary/path')
132
- view_spec.received.first.should == ["arbitrary/path", {}, nil]
132
+ expect(view_spec.received.first).to eq(["arbitrary/path", {}, nil])
133
133
  end
134
134
  end
135
135
 
136
136
  context "given a hash" do
137
137
  it "sends the hash as the first arg to render" do
138
138
  view_spec.render(:foo => 'bar')
139
- view_spec.received.first.should == [{:foo => "bar"}, {}, nil]
139
+ expect(view_spec.received.first).to eq([{:foo => "bar"}, {}, nil])
140
140
  end
141
141
  end
142
142
  end
@@ -152,7 +152,7 @@ module RSpec::Rails
152
152
  end
153
153
 
154
154
  it 'delegates to the controller' do
155
- view_spec.controller.should_receive(:params).and_return({})
155
+ expect(view_spec.controller).to receive(:params).and_return({})
156
156
  view_spec.params[:foo] = 1
157
157
  end
158
158
  end
@@ -165,19 +165,19 @@ module RSpec::Rails
165
165
  end
166
166
  context "with a common _default_file_to_render" do
167
167
  it "it returns the directory" do
168
- view_spec.stub(:_default_file_to_render).
168
+ allow(view_spec).to receive(:_default_file_to_render).
169
169
  and_return("things/new.html.erb")
170
- view_spec.__send__(:_controller_path).
171
- should == "things"
170
+ expect(view_spec.__send__(:_controller_path)).
171
+ to eq("things")
172
172
  end
173
173
  end
174
174
 
175
175
  context "with a nested _default_file_to_render" do
176
176
  it "it returns the directory path" do
177
- view_spec.stub(:_default_file_to_render).
177
+ allow(view_spec).to receive(:_default_file_to_render).
178
178
  and_return("admin/things/new.html.erb")
179
- view_spec.__send__(:_controller_path).
180
- should == "admin/things"
179
+ expect(view_spec.__send__(:_controller_path)).
180
+ to eq("admin/things")
181
181
  end
182
182
  end
183
183
  end
@@ -191,8 +191,23 @@ module RSpec::Rails
191
191
 
192
192
  it "delegates to _view" do
193
193
  view = double("view")
194
- view_spec.stub(:_view) { view }
195
- view_spec.view.should == view
194
+ allow(view_spec).to receive(:_view) { view }
195
+ expect(view_spec.view).to eq(view)
196
+ end
197
+
198
+ it 'is accessible to hooks' do
199
+ with_isolated_config do
200
+ run_count = 0
201
+ RSpec.configuration.before(:each, :type => :view) do
202
+ allow(view).to receive(:a_stubbed_helper) { :value }
203
+ run_count += 1
204
+ end
205
+ group = RSpec::Core::ExampleGroup.describe 'a view', :type => :view do
206
+ specify { true }
207
+ end
208
+ group.run NullObject.new
209
+ expect(run_count).to eq 1
210
+ end
196
211
  end
197
212
  end
198
213
 
@@ -204,15 +219,15 @@ module RSpec::Rails
204
219
  end.new
205
220
  end
206
221
 
207
- before { RSpec.stub(:deprecate) }
222
+ before { allow(RSpec).to receive(:deprecate) }
208
223
 
209
224
  it "is deprecated" do
210
- RSpec.should_receive(:deprecate)
225
+ expect(RSpec).to receive(:deprecate)
211
226
  view_spec.template
212
227
  end
213
228
 
214
229
  it "delegates to #view" do
215
- view_spec.should_receive(:view)
230
+ expect(view_spec).to receive(:view)
216
231
  view_spec.template
217
232
  end
218
233
  end
@@ -9,15 +9,15 @@ describe "errors_on" do
9
9
 
10
10
  it "calls valid?" do
11
11
  model = klass.new
12
- model.should_receive(:valid?)
12
+ expect(model).to receive(:valid?)
13
13
  model.errors_on(:foo)
14
14
  end
15
15
 
16
16
  it "returns the errors on that attribute" do
17
17
  model = klass.new
18
- model.stub(:errors) do
18
+ allow(model).to receive(:errors) do
19
19
  { :foo => ['a', 'b'] }
20
20
  end
21
- model.errors_on(:foo).should eq(['a','b'])
21
+ expect(model.errors_on(:foo)).to eq(['a','b'])
22
22
  end
23
23
  end
@@ -4,13 +4,13 @@ module RSpec::Rails
4
4
  describe FixtureSupport do
5
5
  context "with use_transactional_fixtures set to false" do
6
6
  it "still supports fixture_path" do
7
- RSpec.configuration.stub(:use_transactional_fixtures) { false }
7
+ allow(RSpec.configuration).to receive(:use_transactional_fixtures) { false }
8
8
  group = RSpec::Core::ExampleGroup.describe do
9
9
  include FixtureSupport
10
10
  end
11
11
 
12
- group.should respond_to(:fixture_path)
13
- group.should respond_to(:fixture_path=)
12
+ expect(group).to respond_to(:fixture_path)
13
+ expect(group).to respond_to(:fixture_path=)
14
14
  end
15
15
  end
16
16
  end
@@ -11,12 +11,12 @@ describe "be_a_new matcher" do
11
11
  end
12
12
  context "right class" do
13
13
  it "passes" do
14
- record.should be_a_new(record.class)
14
+ expect(record).to be_a_new(record.class)
15
15
  end
16
16
  end
17
17
  context "wrong class" do
18
18
  it "fails" do
19
- record.should_not be_a_new(String)
19
+ expect(record).not_to be_a_new(String)
20
20
  end
21
21
  end
22
22
  end
@@ -29,12 +29,12 @@ describe "be_a_new matcher" do
29
29
  end
30
30
  context "right class" do
31
31
  it "fails" do
32
- record.should_not be_a_new(record.class)
32
+ expect(record).not_to be_a_new(record.class)
33
33
  end
34
34
  end
35
35
  context "wrong class" do
36
36
  it "fails" do
37
- record.should_not be_a_new(String)
37
+ expect(record).not_to be_a_new(String)
38
38
  end
39
39
  end
40
40
  end
@@ -57,24 +57,24 @@ describe "be_a_new matcher" do
57
57
 
58
58
  context "all attributes same" do
59
59
  it "passes" do
60
- record.should be_a_new(record.class).with(:foo => 'foo', :bar => 'bar')
60
+ expect(record).to be_a_new(record.class).with(:foo => 'foo', :bar => 'bar')
61
61
  end
62
62
  end
63
63
 
64
64
  context "one attribute same" do
65
65
  it "passes" do
66
- record.should be_a_new(record.class).with(:foo => 'foo')
66
+ expect(record).to be_a_new(record.class).with(:foo => 'foo')
67
67
  end
68
68
  end
69
69
 
70
70
  context "no attributes same" do
71
71
  it "fails" do
72
72
  expect {
73
- record.should be_a_new(record.class).with(:zoo => 'zoo', :car => 'car')
73
+ expect(record).to be_a_new(record.class).with(:zoo => 'zoo', :car => 'car')
74
74
  }.to raise_error {|e|
75
- e.message.should match(/attributes {.*} were not set on #{record.inspect}/)
76
- e.message.should match(/"zoo"=>"zoo"/)
77
- e.message.should match(/"car"=>"car"/)
75
+ expect(e.message).to match(/attributes {.*} were not set on #{record.inspect}/)
76
+ expect(e.message).to match(/"zoo"=>"zoo"/)
77
+ expect(e.message).to match(/"car"=>"car"/)
78
78
  }
79
79
  end
80
80
  end
@@ -82,7 +82,7 @@ describe "be_a_new matcher" do
82
82
  context "one attribute value not the same" do
83
83
  it "fails" do
84
84
  expect {
85
- record.should be_a_new(record.class).with(:foo => 'bar')
85
+ expect(record).to be_a_new(record.class).with(:foo => 'bar')
86
86
  }.to raise_error(
87
87
  %Q(attribute {"foo"=>"bar"} was not set on #{record.inspect})
88
88
  )
@@ -108,7 +108,7 @@ describe "be_a_new matcher" do
108
108
  context "all attributes same" do
109
109
  it "fails" do
110
110
  expect {
111
- record.should be_a_new(String).with(:foo => 'foo', :bar => 'bar')
111
+ expect(record).to be_a_new(String).with(:foo => 'foo', :bar => 'bar')
112
112
  }.to raise_error(
113
113
  "expected #{record.inspect} to be a new String"
114
114
  )
@@ -118,11 +118,11 @@ describe "be_a_new matcher" do
118
118
  context "no attributes same" do
119
119
  it "fails" do
120
120
  expect {
121
- record.should be_a_new(String).with(:zoo => 'zoo', :car => 'car')
121
+ expect(record).to be_a_new(String).with(:zoo => 'zoo', :car => 'car')
122
122
  }.to raise_error {|e|
123
- e.message.should match(/expected #{record.inspect} to be a new String and attributes {.*} were not set on #{record.inspect}/)
124
- e.message.should match(/"zoo"=>"zoo"/)
125
- e.message.should match(/"car"=>"car"/)
123
+ expect(e.message).to match(/expected #{record.inspect} to be a new String and attributes {.*} were not set on #{record.inspect}/)
124
+ expect(e.message).to match(/"zoo"=>"zoo"/)
125
+ expect(e.message).to match(/"car"=>"car"/)
126
126
  }
127
127
  end
128
128
  end
@@ -130,7 +130,7 @@ describe "be_a_new matcher" do
130
130
  context "one attribute value not the same" do
131
131
  it "fails" do
132
132
  expect {
133
- record.should be_a_new(String).with(:foo => 'bar')
133
+ expect(record).to be_a_new(String).with(:foo => 'bar')
134
134
  }.to raise_error(
135
135
  "expected #{record.inspect} to be a new String and " +
136
136
  %Q(attribute {"foo"=>"bar"} was not set on #{record.inspect})