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
@@ -14,8 +14,8 @@ describe Rspec::Generators::ObserverGenerator do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe 'the spec' do
|
17
|
-
it {
|
18
|
-
it {
|
19
|
-
it {
|
17
|
+
it { is_expected.to exist }
|
18
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
19
|
+
it { is_expected.to contain(/describe PostsObserver/) }
|
20
20
|
end
|
21
21
|
end
|
@@ -12,14 +12,14 @@ describe Rspec::Generators::ScaffoldGenerator do
|
|
12
12
|
|
13
13
|
describe 'with no options' do
|
14
14
|
before { run_generator %w(posts) }
|
15
|
-
it {
|
16
|
-
it {
|
17
|
-
it {
|
15
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
16
|
+
it { is_expected.to contain(/describe PostsController/) }
|
17
|
+
it { is_expected.to contain(%({ "these" => "params" })) }
|
18
18
|
end
|
19
19
|
|
20
20
|
describe 'with --no-controller_specs' do
|
21
21
|
before { run_generator %w(posts --no-controller_specs) }
|
22
|
-
it {
|
22
|
+
it { is_expected.not_to exist }
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -27,13 +27,13 @@ describe Rspec::Generators::ScaffoldGenerator do
|
|
27
27
|
subject { file('spec/controllers/posts_controller_spec.rb') }
|
28
28
|
before { run_generator %w(posts title:string) }
|
29
29
|
|
30
|
-
it {
|
30
|
+
it { is_expected.to contain(%({ "title" => "MyString" })) }
|
31
31
|
end
|
32
32
|
|
33
33
|
describe 'namespaced controller spec' do
|
34
34
|
subject { file('spec/controllers/admin/posts_controller_spec.rb') }
|
35
35
|
before { run_generator %w(admin/posts) }
|
36
|
-
it {
|
36
|
+
it { is_expected.to contain(/describe Admin::PostsController/)}
|
37
37
|
end
|
38
38
|
|
39
39
|
describe 'view specs' do
|
@@ -41,34 +41,34 @@ describe Rspec::Generators::ScaffoldGenerator do
|
|
41
41
|
before { run_generator %w(posts) }
|
42
42
|
describe 'edit' do
|
43
43
|
subject { file("spec/views/posts/edit.html.erb_spec.rb") }
|
44
|
-
it {
|
45
|
-
it {
|
46
|
-
it {
|
47
|
-
it {
|
44
|
+
it { is_expected.to exist }
|
45
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
46
|
+
it { is_expected.to contain(/describe "(.*)\/edit"/) }
|
47
|
+
it { is_expected.to contain(/it "renders the edit (.*) form"/) }
|
48
48
|
end
|
49
49
|
|
50
50
|
describe 'index' do
|
51
51
|
subject { file("spec/views/posts/index.html.erb_spec.rb") }
|
52
|
-
it {
|
53
|
-
it {
|
54
|
-
it {
|
55
|
-
it {
|
52
|
+
it { is_expected.to exist }
|
53
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
54
|
+
it { is_expected.to contain(/describe "(.*)\/index"/) }
|
55
|
+
it { is_expected.to contain(/it "renders a list of (.*)"/) }
|
56
56
|
end
|
57
57
|
|
58
58
|
describe 'new' do
|
59
59
|
subject { file("spec/views/posts/new.html.erb_spec.rb") }
|
60
|
-
it {
|
61
|
-
it {
|
62
|
-
it {
|
63
|
-
it {
|
60
|
+
it { is_expected.to exist }
|
61
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
62
|
+
it { is_expected.to contain(/describe "(.*)\/new"/) }
|
63
|
+
it { is_expected.to contain(/it "renders new (.*) form"/) }
|
64
64
|
end
|
65
65
|
|
66
66
|
describe 'show' do
|
67
67
|
subject { file("spec/views/posts/show.html.erb_spec.rb") }
|
68
|
-
it {
|
69
|
-
it {
|
70
|
-
it {
|
71
|
-
it {
|
68
|
+
it { is_expected.to exist }
|
69
|
+
it { is_expected.to contain(/require 'spec_helper'/) }
|
70
|
+
it { is_expected.to contain(/describe "(.*)\/show"/) }
|
71
|
+
it { is_expected.to contain(/it "renders attributes in <p>"/) }
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -76,22 +76,22 @@ describe Rspec::Generators::ScaffoldGenerator do
|
|
76
76
|
before { run_generator %w(posts --no-template-engine) }
|
77
77
|
describe 'edit' do
|
78
78
|
subject { file("spec/views/posts/edit.html._spec.rb") }
|
79
|
-
it {
|
79
|
+
it { is_expected.not_to exist }
|
80
80
|
end
|
81
81
|
|
82
82
|
describe 'index' do
|
83
83
|
subject { file("spec/views/posts/index.html._spec.rb") }
|
84
|
-
it {
|
84
|
+
it { is_expected.not_to exist }
|
85
85
|
end
|
86
86
|
|
87
87
|
describe 'new' do
|
88
88
|
subject { file("spec/views/posts/new.html._spec.rb") }
|
89
|
-
it {
|
89
|
+
it { is_expected.not_to exist }
|
90
90
|
end
|
91
91
|
|
92
92
|
describe 'show' do
|
93
93
|
subject { file("spec/views/posts/show.html._spec.rb") }
|
94
|
-
it {
|
94
|
+
it { is_expected.not_to exist }
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -100,22 +100,22 @@ describe Rspec::Generators::ScaffoldGenerator do
|
|
100
100
|
|
101
101
|
describe 'edit' do
|
102
102
|
subject { file("spec/views/posts/edit.html.erb_spec.rb") }
|
103
|
-
it {
|
103
|
+
it { is_expected.not_to exist }
|
104
104
|
end
|
105
105
|
|
106
106
|
describe 'index' do
|
107
107
|
subject { file("spec/views/posts/index.html.erb_spec.rb") }
|
108
|
-
it {
|
108
|
+
it { is_expected.not_to exist }
|
109
109
|
end
|
110
110
|
|
111
111
|
describe 'new' do
|
112
112
|
subject { file("spec/views/posts/new.html.erb_spec.rb") }
|
113
|
-
it {
|
113
|
+
it { is_expected.not_to exist }
|
114
114
|
end
|
115
115
|
|
116
116
|
describe 'show' do
|
117
117
|
subject { file("spec/views/posts/show.html.erb_spec.rb") }
|
118
|
-
it {
|
118
|
+
it { is_expected.not_to exist }
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
@@ -125,14 +125,14 @@ describe Rspec::Generators::ScaffoldGenerator do
|
|
125
125
|
|
126
126
|
describe 'with default options' do
|
127
127
|
before { run_generator %w(posts) }
|
128
|
-
it {
|
129
|
-
it {
|
130
|
-
it {
|
128
|
+
it { is_expected.to contain(/require "spec_helper"/) }
|
129
|
+
it { is_expected.to contain(/describe PostsController/) }
|
130
|
+
it { is_expected.to contain(/describe "routing"/) }
|
131
131
|
end
|
132
132
|
|
133
133
|
describe 'with --no-routing-specs' do
|
134
134
|
before { run_generator %w(posts --no-routing_specs) }
|
135
|
-
it {
|
135
|
+
it { is_expected.not_to exist }
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
@@ -13,8 +13,8 @@ describe Rspec::Generators::ViewGenerator do
|
|
13
13
|
it 'generates a spec for the supplied action' do
|
14
14
|
run_generator %w(posts index)
|
15
15
|
file('spec/views/posts/index.html.erb_spec.rb').tap do |f|
|
16
|
-
f.
|
17
|
-
f.
|
16
|
+
expect(f).to contain(/require 'spec_helper'/)
|
17
|
+
expect(f).to contain(/describe "posts\/index"/)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -22,8 +22,8 @@ describe Rspec::Generators::ViewGenerator do
|
|
22
22
|
it 'generates a spec for the supplied action' do
|
23
23
|
run_generator %w(admin/posts index)
|
24
24
|
file('spec/views/admin/posts/index.html.erb_spec.rb').tap do |f|
|
25
|
-
f.
|
26
|
-
f.
|
25
|
+
expect(f).to contain(/require 'spec_helper'/)
|
26
|
+
expect(f).to contain(/describe "admin\/posts\/index"/)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -33,8 +33,8 @@ describe Rspec::Generators::ViewGenerator do
|
|
33
33
|
it 'generates a spec for the supplied action' do
|
34
34
|
run_generator %w(posts index --template_engine haml)
|
35
35
|
file('spec/views/posts/index.html.haml_spec.rb').tap do |f|
|
36
|
-
f.
|
37
|
-
f.
|
36
|
+
expect(f).to contain(/require 'spec_helper'/)
|
37
|
+
expect(f).to contain(/describe "posts\/index"/)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -13,16 +13,16 @@ describe RSpec::Rails::MinitestAssertionAdapter do
|
|
13
13
|
end
|
14
14
|
else
|
15
15
|
it "exposes #{m} to host examples" do
|
16
|
-
methods.
|
16
|
+
expect(methods).to include(m)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
it "does not expose internal methods of Minitest" do
|
22
|
-
methods.
|
22
|
+
expect(methods).not_to include("_assertions")
|
23
23
|
end
|
24
24
|
|
25
25
|
it "does not expose Minitest's message method" do
|
26
|
-
methods.
|
26
|
+
expect(methods).not_to include("message")
|
27
27
|
end
|
28
28
|
end
|
@@ -11,7 +11,7 @@ describe "configuration" do
|
|
11
11
|
|
12
12
|
describe "#render_views?" do
|
13
13
|
it "is false by default" do
|
14
|
-
RSpec.configuration.render_views
|
14
|
+
expect(RSpec.configuration.render_views?).to be_falsey
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -20,7 +20,7 @@ describe "configuration" do
|
|
20
20
|
RSpec.configuration.render_views = false
|
21
21
|
RSpec.configuration.render_views
|
22
22
|
|
23
|
-
RSpec.configuration.render_views
|
23
|
+
expect(RSpec.configuration.render_views?).to be_truthy
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -1,12 +1,13 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
class ::ApplicationController
|
4
|
+
def self.abstract?; false; end
|
4
5
|
end
|
5
6
|
|
6
7
|
module RSpec::Rails
|
7
8
|
describe ControllerExampleGroup do
|
8
|
-
it {
|
9
|
-
it {
|
9
|
+
it { is_expected.to be_included_in_files_in('./spec/controllers/') }
|
10
|
+
it { is_expected.to be_included_in_files_in('.\\spec\\controllers\\') }
|
10
11
|
|
11
12
|
let(:group) do
|
12
13
|
RSpec::Core::ExampleGroup.describe do
|
@@ -15,19 +16,19 @@ module RSpec::Rails
|
|
15
16
|
end
|
16
17
|
|
17
18
|
it "includes routing matchers" do
|
18
|
-
group.included_modules.
|
19
|
+
expect(group.included_modules).to include(RSpec::Rails::Matchers::RoutingMatchers)
|
19
20
|
end
|
20
21
|
|
21
22
|
it "adds :type => :controller to the metadata" do
|
22
|
-
group.metadata[:type].
|
23
|
+
expect(group.metadata[:type]).to eq(:controller)
|
23
24
|
end
|
24
25
|
|
25
26
|
context "with implicit subject" do
|
26
27
|
it "uses the controller as the subject" do
|
27
28
|
controller = double('controller')
|
28
29
|
example = group.new
|
29
|
-
example.
|
30
|
-
example.subject.
|
30
|
+
allow(example).to receive_messages(:controller => controller)
|
31
|
+
expect(example.subject).to eq(controller)
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
@@ -35,7 +36,7 @@ module RSpec::Rails
|
|
35
36
|
it "uses the specified subject instead of the controller" do
|
36
37
|
group.subject { 'explicit' }
|
37
38
|
example = group.new
|
38
|
-
example.subject.
|
39
|
+
expect(example.subject).to eq('explicit')
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
@@ -48,10 +49,10 @@ module RSpec::Rails
|
|
48
49
|
|
49
50
|
it "delegates named route helpers to the underlying controller" do
|
50
51
|
controller = double('controller')
|
51
|
-
controller.
|
52
|
+
allow(controller).to receive(:foos_url).and_return('http://test.host/foos')
|
52
53
|
|
53
54
|
example = group.new
|
54
|
-
example.
|
55
|
+
allow(example).to receive_messages(:controller => controller)
|
55
56
|
|
56
57
|
# As in the routing example spec, this is pretty invasive, but not sure
|
57
58
|
# how to do it any other way as the correct operation relies on before
|
@@ -60,7 +61,7 @@ module RSpec::Rails
|
|
60
61
|
routes.draw { resources :foos }
|
61
62
|
example.instance_variable_set(:@orig_routes, routes)
|
62
63
|
|
63
|
-
example.foos_url.
|
64
|
+
expect(example.foos_url).to eq('http://test.host/foos')
|
64
65
|
end
|
65
66
|
end
|
66
67
|
|
@@ -77,23 +78,81 @@ module RSpec::Rails
|
|
77
78
|
|
78
79
|
describe "with inferred anonymous controller" do
|
79
80
|
before do
|
80
|
-
group.
|
81
|
+
allow(group).to receive(:controller_class).and_return(Class.new)
|
81
82
|
end
|
82
83
|
|
83
|
-
it "
|
84
|
-
RSpec.configuration.
|
85
|
-
|
84
|
+
it "defaults to inferring anonymous controller class" do
|
85
|
+
expect(RSpec.configuration.infer_base_class_for_anonymous_controllers).to be_truthy
|
86
|
+
end
|
87
|
+
|
88
|
+
context "when infer_base_class_for_anonymous_controllers is true" do
|
89
|
+
before do
|
90
|
+
allow(RSpec.configuration).to receive(:infer_base_class_for_anonymous_controllers?).and_return(true)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "infers the anonymous controller class" do
|
94
|
+
group.controller { }
|
95
|
+
|
96
|
+
controller_class = group.metadata[:example_group][:described_class]
|
97
|
+
expect(controller_class.superclass).to eq(group.controller_class)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "infers the anonymous controller class when no ApplicationController is present" do
|
101
|
+
hide_const '::ApplicationController'
|
102
|
+
group.controller { }
|
103
|
+
|
104
|
+
controller_class = group.metadata[:example_group][:described_class]
|
105
|
+
expect(controller_class.superclass).to eq(group.controller_class)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "when infer_base_class_for_anonymous_controllers is false" do
|
110
|
+
before do
|
111
|
+
allow(RSpec.configuration).to receive(:infer_base_class_for_anonymous_controllers?).and_return(false)
|
112
|
+
end
|
86
113
|
|
87
|
-
|
88
|
-
|
114
|
+
it "sets the anonymous controller class to ApplicationController" do
|
115
|
+
group.controller { }
|
116
|
+
|
117
|
+
controller_class = group.metadata[:example_group][:described_class]
|
118
|
+
expect(controller_class.superclass).to eq(ApplicationController)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "sets the anonymous controller class to ActiveController::Base when no ApplicationController is present" do
|
122
|
+
hide_const '::ApplicationController'
|
123
|
+
group.controller { }
|
124
|
+
|
125
|
+
controller_class = group.metadata[:example_group][:described_class]
|
126
|
+
expect(controller_class.superclass).to eq(ActionController::Base)
|
127
|
+
end
|
89
128
|
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe "controller name" do
|
132
|
+
let(:controller_class) { group.metadata[:example_group][:described_class] }
|
90
133
|
|
91
|
-
it "sets the
|
92
|
-
RSpec.configuration.stub(:infer_base_class_for_anonymous_controllers?).and_return(false)
|
134
|
+
it "sets the name as AnonymousController if it's anonymous" do
|
93
135
|
group.controller { }
|
136
|
+
expect(controller_class.name).to eq "AnonymousController"
|
137
|
+
end
|
138
|
+
|
139
|
+
it "sets the name according to defined controller if it is not anonymous" do
|
140
|
+
stub_const "FoosController", Class.new(::ApplicationController)
|
141
|
+
group.controller(FoosController) { }
|
142
|
+
expect(controller_class.name).to eq "FoosController"
|
143
|
+
end
|
144
|
+
|
145
|
+
it "sets name as AnonymousController if defined as ApplicationController" do
|
146
|
+
group.controller(ApplicationController) { }
|
147
|
+
expect(controller_class.name).to eq "AnonymousController"
|
148
|
+
end
|
149
|
+
|
150
|
+
it "sets name as AnonymousController the controller is abstract" do
|
151
|
+
abstract_controller = Class.new(::ApplicationController)
|
152
|
+
def abstract_controller.abstract?; true; end
|
94
153
|
|
95
|
-
|
96
|
-
controller_class.
|
154
|
+
group.controller(abstract_controller) { }
|
155
|
+
expect(controller_class.name).to eq "AnonymousController"
|
97
156
|
end
|
98
157
|
end
|
99
158
|
end
|
@@ -2,8 +2,8 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
module RSpec::Rails
|
4
4
|
describe FeatureExampleGroup do
|
5
|
-
it {
|
6
|
-
it {
|
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 {
|
9
|
-
it {
|
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).
|
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].
|
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.
|
29
|
+
expect(helper_spec).to receive(:view_assigns)
|
30
30
|
av_tc_b_view = double('_view')
|
31
|
-
av_tc_b_view.
|
32
|
-
helper_spec.
|
33
|
-
helper_spec.helper.
|
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.
|
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.
|
61
|
-
helper_spec.determine_default_helper_class("ignore this").
|
62
|
-
|
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
|