rspec-rails 3.0.0.beta1 → 3.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/Changelog.md +46 -0
- data/README.md +19 -17
- data/features/Generators.md +1 -0
- data/features/README.md +7 -15
- data/features/controller_specs/anonymous_controller.feature +222 -164
- data/lib/generators/rspec/feature/feature_generator.rb +15 -0
- data/lib/generators/rspec/feature/templates/feature_spec.rb +5 -0
- data/lib/generators/rspec/install/templates/spec/spec_helper.rb.tt +0 -6
- data/lib/generators/rspec/integration/integration_generator.rb +0 -11
- data/lib/generators/rspec/integration/templates/request_spec.rb +0 -5
- data/lib/generators/rspec/model/templates/fixtures.yml +1 -1
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +0 -8
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +4 -4
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +0 -9
- data/lib/generators/rspec/scaffold/templates/index_spec.rb +0 -7
- data/lib/generators/rspec/scaffold/templates/new_spec.rb +0 -9
- data/lib/generators/rspec/scaffold/templates/show_spec.rb +0 -7
- data/lib/rspec/rails.rb +1 -1
- data/lib/rspec/rails/adapters.rb +18 -15
- data/lib/rspec/rails/example/controller_example_group.rb +18 -9
- data/lib/rspec/rails/example/view_example_group.rb +3 -0
- data/lib/rspec/rails/matchers/be_a_new.rb +1 -1
- data/lib/rspec/rails/matchers/be_new_record.rb +2 -2
- data/lib/rspec/rails/matchers/be_valid.rb +10 -3
- data/lib/rspec/rails/matchers/have_rendered.rb +2 -2
- data/lib/rspec/rails/matchers/redirect_to.rb +2 -2
- data/lib/rspec/rails/matchers/relation_match_array.rb +1 -1
- data/lib/rspec/rails/matchers/routing_matchers.rb +7 -3
- data/lib/rspec/rails/mocks.rb +50 -26
- data/lib/rspec/rails/vendor/capybara.rb +4 -4
- data/lib/rspec/rails/version.rb +1 -1
- data/spec/generators/rspec/controller/controller_generator_spec.rb +16 -16
- data/spec/generators/rspec/feature/feature_generator_spec.rb +43 -0
- data/spec/generators/rspec/helper/helper_generator_spec.rb +4 -4
- data/spec/generators/rspec/install/install_generator_spec.rb +4 -4
- data/spec/generators/rspec/integration/integration_generator_spec.rb +8 -20
- data/spec/generators/rspec/mailer/mailer_generator_spec.rb +11 -11
- data/spec/generators/rspec/model/model_generator_spec.rb +7 -7
- data/spec/generators/rspec/observer/observer_generator_spec.rb +3 -3
- data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +34 -34
- data/spec/generators/rspec/view/view_generator_spec.rb +6 -6
- data/spec/rspec/rails/assertion_adapter_spec.rb +3 -3
- data/spec/rspec/rails/configuration_spec.rb +2 -2
- data/spec/rspec/rails/deprecations_spec.rb +1 -1
- data/spec/rspec/rails/example/controller_example_group_spec.rb +79 -20
- data/spec/rspec/rails/example/feature_example_group_spec.rb +2 -2
- data/spec/rspec/rails/example/helper_example_group_spec.rb +12 -12
- data/spec/rspec/rails/example/mailer_example_group_spec.rb +3 -3
- data/spec/rspec/rails/example/model_example_group_spec.rb +3 -3
- data/spec/rspec/rails/example/request_example_group_spec.rb +5 -5
- data/spec/rspec/rails/example/routing_example_group_spec.rb +5 -5
- data/spec/rspec/rails/example/view_example_group_spec.rb +44 -29
- data/spec/rspec/rails/extensions/active_model/errors_on_spec.rb +3 -3
- data/spec/rspec/rails/fixture_support_spec.rb +3 -3
- data/spec/rspec/rails/matchers/be_a_new_spec.rb +17 -17
- data/spec/rspec/rails/matchers/be_new_record_spec.rb +2 -2
- data/spec/rspec/rails/matchers/be_routable_spec.rb +8 -8
- data/spec/rspec/rails/matchers/be_valid_spec.rb +33 -4
- data/spec/rspec/rails/matchers/has_spec.rb +1 -1
- data/spec/rspec/rails/matchers/have_rendered_spec.rb +3 -3
- data/spec/rspec/rails/matchers/redirect_to_spec.rb +7 -6
- data/spec/rspec/rails/matchers/relation_match_array_spec.rb +6 -6
- data/spec/rspec/rails/matchers/route_to_spec.rb +21 -21
- data/spec/rspec/rails/minitest_lifecycle_adapter_spec.rb +9 -0
- data/spec/rspec/rails/mocks/mock_model_spec.rb +95 -73
- data/spec/rspec/rails/mocks/stub_model_spec.rb +23 -23
- data/spec/rspec/rails/setup_and_teardown_adapter_spec.rb +4 -4
- data/spec/rspec/rails/view_rendering_spec.rb +14 -14
- data/spec/spec_helper.rb +3 -5
- data/spec/support/helpers.rb +15 -1
- metadata +112 -46
- metadata.gz.sig +0 -0
- checksums.yaml +0 -15
- checksums.yaml.gz.sig +0 -2
@@ -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 {
|
12
|
-
it {
|
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].
|
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 {
|
6
|
-
it {
|
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].
|
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 {
|
6
|
-
it {
|
7
|
-
it {
|
8
|
-
it {
|
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].
|
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 {
|
6
|
-
it {
|
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].
|
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.
|
26
|
+
allow(example).to receive_messages(:routes => routes)
|
27
27
|
|
28
|
-
example.foo_path.
|
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 {
|
6
|
-
it {
|
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].
|
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.
|
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.
|
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
|
-
|
37
|
+
expect {
|
38
38
|
RSpec::Core::ExampleGroup.describe 'clocks/show.html.erb' do
|
39
39
|
include ViewExampleGroup
|
40
40
|
end
|
41
|
-
}.
|
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.
|
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
|
-
|
82
|
+
expect {
|
83
83
|
RSpec::Core::ExampleGroup.describe 'foos/edit.html.erb' do
|
84
84
|
include ViewExampleGroup
|
85
85
|
end
|
86
|
-
}.
|
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.
|
112
|
+
allow(view_spec).to receive(:_default_file_to_render) { "widgets/new" }
|
113
113
|
view_spec.render
|
114
|
-
view_spec.received.first.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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
|
-
|
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.
|
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
|
-
|
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.
|
195
|
-
view_spec.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.
|
222
|
+
before { allow(RSpec).to receive(:deprecate) }
|
208
223
|
|
209
224
|
it "is deprecated" do
|
210
|
-
RSpec.
|
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.
|
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.
|
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.
|
18
|
+
allow(model).to receive(:errors) do
|
19
19
|
{ :foo => ['a', 'b'] }
|
20
20
|
end
|
21
|
-
model.errors_on(:foo).
|
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.
|
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.
|
13
|
-
group.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
73
|
+
expect(record).to be_a_new(record.class).with(:zoo => 'zoo', :car => 'car')
|
74
74
|
}.to raise_error {|e|
|
75
|
-
e.message.
|
76
|
-
e.message.
|
77
|
-
e.message.
|
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.
|
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.
|
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.
|
121
|
+
expect(record).to be_a_new(String).with(:zoo => 'zoo', :car => 'car')
|
122
122
|
}.to raise_error {|e|
|
123
|
-
e.message.
|
124
|
-
e.message.
|
125
|
-
e.message.
|
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.
|
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})
|
@@ -7,7 +7,7 @@ describe "be_new_record" do
|
|
7
7
|
let(:record) { double('record', :persisted? => false) }
|
8
8
|
|
9
9
|
it "passes" do
|
10
|
-
record.
|
10
|
+
expect(record).to be_new_record
|
11
11
|
end
|
12
12
|
|
13
13
|
it "fails with custom failure message" do
|
@@ -21,7 +21,7 @@ describe "be_new_record" do
|
|
21
21
|
let(:record) { double('record', :persisted? => true) }
|
22
22
|
|
23
23
|
it "fails" do
|
24
|
-
record.
|
24
|
+
expect(record).not_to be_new_record
|
25
25
|
end
|
26
26
|
|
27
27
|
it "fails with custom failure message" do
|
@@ -8,16 +8,16 @@ describe "be_routable" do
|
|
8
8
|
|
9
9
|
context "with should" do
|
10
10
|
it "passes if routes recognize the path" do
|
11
|
-
routes.
|
11
|
+
allow(routes).to receive(:recognize_path) { {} }
|
12
12
|
expect do
|
13
|
-
{:get => "/a/path"}.
|
13
|
+
expect({:get => "/a/path"}).to be_routable
|
14
14
|
end.to_not raise_error
|
15
15
|
end
|
16
16
|
|
17
17
|
it "fails if routes do not recognize the path" do
|
18
|
-
routes.
|
18
|
+
allow(routes).to receive(:recognize_path) { raise ActionController::RoutingError.new('ignore') }
|
19
19
|
expect do
|
20
|
-
{:get => "/a/path"}.
|
20
|
+
expect({:get => "/a/path"}).to be_routable
|
21
21
|
end.to raise_error(/expected \{:get=>"\/a\/path"\} to be routable/)
|
22
22
|
end
|
23
23
|
end
|
@@ -25,16 +25,16 @@ describe "be_routable" do
|
|
25
25
|
context "with should_not" do
|
26
26
|
|
27
27
|
it "passes if routes do not recognize the path" do
|
28
|
-
routes.
|
28
|
+
allow(routes).to receive(:recognize_path) { raise ActionController::RoutingError.new('ignore') }
|
29
29
|
expect do
|
30
|
-
{:get => "/a/path"}.
|
30
|
+
expect({:get => "/a/path"}).not_to be_routable
|
31
31
|
end.to_not raise_error
|
32
32
|
end
|
33
33
|
|
34
34
|
it "fails if routes recognize the path" do
|
35
|
-
routes.
|
35
|
+
allow(routes).to receive(:recognize_path) { {:controller => "foo"} }
|
36
36
|
expect do
|
37
|
-
{:get => "/a/path"}.
|
37
|
+
expect({:get => "/a/path"}).not_to be_routable
|
38
38
|
end.to raise_error(/expected \{:get=>"\/a\/path"\} not to be routable, but it routes to \{:controller=>"foo"\}/)
|
39
39
|
end
|
40
40
|
end
|