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
@@ -16,15 +16,15 @@ describe Rspec::Generators::HelperGenerator do
16
16
  end
17
17
 
18
18
  describe 'the spec' do
19
- it { should exist }
20
- it { should contain(/require 'spec_helper'/) }
21
- it { should contain(/describe PostsHelper/) }
19
+ it { is_expected.to exist }
20
+ it { is_expected.to contain(/require 'spec_helper'/) }
21
+ it { is_expected.to contain(/describe PostsHelper/) }
22
22
  end
23
23
  end
24
24
  describe 'skipped with a flag' do
25
25
  before do
26
26
  run_generator %w(posts --no-helper_specs)
27
27
  end
28
- it { should_not exist }
28
+ it { is_expected.not_to exist }
29
29
  end
30
30
  end
@@ -8,23 +8,23 @@ describe Rspec::Generators::InstallGenerator do
8
8
 
9
9
  it "generates .rspec" do
10
10
  run_generator
11
- file('.rspec').should exist
11
+ expect(file('.rspec')).to exist
12
12
  end
13
13
 
14
14
  it "generates spec/spec_helper.rb" do
15
15
  run_generator
16
- File.read( file('spec/spec_helper.rb') ).should =~ /^require 'rspec\/autorun'$/m
16
+ expect(File.read( file('spec/spec_helper.rb') )).to match(/^require 'rspec\/rails'$/m)
17
17
  end
18
18
 
19
19
  if ::Rails::VERSION::STRING >= '4'
20
20
  it "generates spec/spec_helper.rb with a check for pending migrations" do
21
21
  run_generator
22
- File.read( file('spec/spec_helper.rb') ).should =~ /ActiveRecord::Migration\.check_pending!/m
22
+ expect(File.read( file('spec/spec_helper.rb') )).to match(/ActiveRecord::Migration\.check_pending!/m)
23
23
  end
24
24
  else
25
25
  it "generates spec/spec_helper.rb without a check for pending migrations" do
26
26
  run_generator
27
- File.read( file('spec/spec_helper.rb') ).should_not =~ /ActiveRecord::Migration\.check_pending!/m
27
+ expect(File.read( file('spec/spec_helper.rb') )).not_to match(/ActiveRecord::Migration\.check_pending!/m)
28
28
  end
29
29
  end
30
30
  end
@@ -15,7 +15,7 @@ describe Rspec::Generators::IntegrationGenerator do
15
15
  end
16
16
  describe 'index.html.erb' do
17
17
  subject { file('spec/requests/posts_spec.rb') }
18
- it { should_not exist }
18
+ it { is_expected.not_to exist }
19
19
  end
20
20
  end
21
21
 
@@ -25,11 +25,12 @@ describe Rspec::Generators::IntegrationGenerator do
25
25
  run_generator %w(posts)
26
26
  end
27
27
  subject { file('spec/requests/posts_spec.rb') }
28
- it { should exist }
29
- it { should contain(/require 'spec_helper'/) }
30
- it { should contain(/describe "GET \/posts"/) }
31
- it { should contain(/get posts_index_path/) }
28
+ it { is_expected.to exist }
29
+ it { is_expected.to contain(/require 'spec_helper'/) }
30
+ it { is_expected.to contain(/describe "GET \/posts"/) }
31
+ it { is_expected.to contain(/get posts_index_path/) }
32
32
  end
33
+
33
34
  describe 'with webrat matchers' do
34
35
  before do
35
36
  run_generator %w(posts --webrat)
@@ -40,5 +41,17 @@ describe Rspec::Generators::IntegrationGenerator do
40
41
  it { should contain(/describe "GET \/posts"/) }
41
42
  it { should contain(/visit posts_index_path/) }
42
43
  end
44
+
45
+ describe 'the webrat option' do
46
+ it 'is deprecated when invoked as --webrat' do
47
+ expect(RSpec).to receive(:deprecate).with("the --webrat option", :replacement => nil)
48
+ run_generator %w(posts --webrat)
49
+ end
50
+
51
+ it 'is deprecated when invoked as --webrat-matchers' do
52
+ expect(RSpec).to receive(:deprecate).with("the --webrat-matchers option", :replacement => nil)
53
+ run_generator %w(posts --webrat-matchers)
54
+ end
55
+ end
43
56
  end
44
57
  end
@@ -15,18 +15,18 @@ describe Rspec::Generators::MailerGenerator do
15
15
  before do
16
16
  run_generator %w(posts index show)
17
17
  end
18
- it { should exist }
19
- it { should contain(/require "spec_helper"/) }
20
- it { should contain(/describe "index" do/) }
21
- it { should contain(/describe "show" do/) }
18
+ it { is_expected.to exist }
19
+ it { is_expected.to contain(/require "spec_helper"/) }
20
+ it { is_expected.to contain(/describe "index" do/) }
21
+ it { is_expected.to contain(/describe "show" do/) }
22
22
  end
23
23
  describe 'creates placeholder when no actions specified' do
24
24
  before do
25
25
  run_generator %w(posts)
26
26
  end
27
- it { should exist }
28
- it { should contain(/require "spec_helper"/) }
29
- it { should contain(/pending "add some examples to \(or delete\)/) }
27
+ it { is_expected.to exist }
28
+ it { is_expected.to contain(/require "spec_helper"/) }
29
+ it { is_expected.to contain(/pending "add some examples to \(or delete\)/) }
30
30
  end
31
31
  end
32
32
 
@@ -36,13 +36,13 @@ describe Rspec::Generators::MailerGenerator do
36
36
  end
37
37
  describe 'index' do
38
38
  subject { file('spec/fixtures/posts/index') }
39
- it { should exist }
40
- it { should contain(/Posts#index/) }
39
+ it { is_expected.to exist }
40
+ it { is_expected.to contain(/Posts#index/) }
41
41
  end
42
42
  describe 'show' do
43
43
  subject { file('spec/fixtures/posts/show') }
44
- it { should exist }
45
- it { should contain(/Posts#show/) }
44
+ it { is_expected.to exist }
45
+ it { is_expected.to contain(/Posts#show/) }
46
46
  end
47
47
  end
48
48
  end
@@ -11,8 +11,8 @@ describe Rspec::Generators::ModelGenerator do
11
11
 
12
12
  it 'runs both the model and fixture tasks' do
13
13
  gen = generator %w(posts)
14
- gen.should_receive :create_model_spec
15
- gen.should_receive :create_fixture_file
14
+ expect(gen).to receive :create_model_spec
15
+ expect(gen).to receive :create_fixture_file
16
16
  capture(:stdout) { gen.invoke_all }
17
17
  end
18
18
 
@@ -25,15 +25,15 @@ describe Rspec::Generators::ModelGenerator do
25
25
  describe 'the spec' do
26
26
  subject { file('spec/models/posts_spec.rb') }
27
27
 
28
- it { should exist }
29
- it { should contain(/require 'spec_helper'/) }
30
- it { should contain(/describe Posts/) }
28
+ it { is_expected.to exist }
29
+ it { is_expected.to contain(/require 'spec_helper'/) }
30
+ it { is_expected.to contain(/describe Posts/) }
31
31
  end
32
32
 
33
33
  describe 'the fixtures' do
34
34
  subject { file('spec/fixtures/posts.yml') }
35
35
 
36
- it { should contain(Regexp.new('# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html')) }
36
+ it { is_expected.to contain(Regexp.new('# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html')) }
37
37
  end
38
38
  end
39
39
 
@@ -45,7 +45,7 @@ describe Rspec::Generators::ModelGenerator do
45
45
  describe 'the fixtures' do
46
46
  subject { file('spec/fixtures/posts.yml') }
47
47
 
48
- it { should_not exist }
48
+ it { is_expected.not_to exist }
49
49
  end
50
50
  end
51
51
  end
@@ -14,8 +14,8 @@ describe Rspec::Generators::ObserverGenerator do
14
14
  end
15
15
 
16
16
  describe 'the spec' do
17
- it { should exist }
18
- it { should contain(/require 'spec_helper'/) }
19
- it { should contain(/describe PostsObserver/) }
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 { should contain(/require 'spec_helper'/) }
16
- it { should contain(/describe PostsController/) }
17
- it { should contain(%({ "these" => "params" })) }
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 { should_not exist }
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 { should contain(%({ "title" => "MyString" })) }
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 { should contain(/describe Admin::PostsController/)}
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 { should exist }
45
- it { should contain(/require 'spec_helper'/) }
46
- it { should contain(/describe "(.*)\/edit"/) }
47
- it { should contain(/it "renders the edit (.*) form"/) }
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 { should exist }
53
- it { should contain(/require 'spec_helper'/) }
54
- it { should contain(/describe "(.*)\/index"/) }
55
- it { should contain(/it "renders a list of (.*)"/) }
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 { should exist }
61
- it { should contain(/require 'spec_helper'/) }
62
- it { should contain(/describe "(.*)\/new"/) }
63
- it { should contain(/it "renders new (.*) form"/) }
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 { should exist }
69
- it { should contain(/require 'spec_helper'/) }
70
- it { should contain(/describe "(.*)\/show"/) }
71
- it { should contain(/it "renders attributes in <p>"/) }
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 { should_not exist }
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 { should_not exist }
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 { should_not exist }
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 { should_not exist }
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 { should_not exist }
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 { should_not exist }
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 { should_not exist }
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 { should_not exist }
118
+ it { is_expected.not_to exist }
119
119
  end
120
120
  end
121
121
  end
@@ -125,14 +125,26 @@ describe Rspec::Generators::ScaffoldGenerator do
125
125
 
126
126
  describe 'with default options' do
127
127
  before { run_generator %w(posts) }
128
- it { should contain(/require "spec_helper"/) }
129
- it { should contain(/describe PostsController/) }
130
- it { should contain(/describe "routing"/) }
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 { should_not exist }
135
+ it { is_expected.not_to exist }
136
+ end
137
+ end
138
+
139
+ describe 'the webrat option' do
140
+ it 'is deprecated when invoked as --webrat' do
141
+ expect(RSpec).to receive(:deprecate).with("the --webrat option", :replacement => nil)
142
+ run_generator %w(posts --webrat)
143
+ end
144
+
145
+ it 'is deprecated when invoked as --webrat-matchers' do
146
+ expect(RSpec).to receive(:deprecate).with("the --webrat-matchers option", :replacement => nil)
147
+ run_generator %w(posts --webrat-matchers)
136
148
  end
137
149
  end
138
150
  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.should contain(/require 'spec_helper'/)
17
- f.should contain(/describe "posts\/index"/)
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.should contain(/require 'spec_helper'/)
26
- f.should contain(/describe "admin\/posts\/index"/)
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.should contain(/require 'spec_helper'/)
37
- f.should contain(/describe "posts\/index"/)
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.should include(m)
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.should_not include("_assertions")
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.should_not include("message")
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?.should be_falsey
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?.should be_truthy
23
+ expect(RSpec.configuration.render_views?).to be_truthy
24
24
  end
25
25
  end
26
26
  end
@@ -10,7 +10,7 @@ describe "rspec-rails-2 deprecations" do
10
10
  end
11
11
 
12
12
  it "is deprecated" do
13
- RSpec.should_receive(:deprecate)
13
+ expect(RSpec).to receive(:deprecate)
14
14
  group.integrate_views
15
15
  end
16
16
  end
@@ -5,8 +5,8 @@ end
5
5
 
6
6
  module RSpec::Rails
7
7
  describe ControllerExampleGroup do
8
- it { should be_included_in_files_in('./spec/controllers/') }
9
- it { should be_included_in_files_in('.\\spec\\controllers\\') }
8
+ it { is_expected.to be_included_in_files_in('./spec/controllers/') }
9
+ it { is_expected.to be_included_in_files_in('.\\spec\\controllers\\') }
10
10
 
11
11
  let(:group) do
12
12
  RSpec::Core::ExampleGroup.describe do
@@ -15,19 +15,19 @@ module RSpec::Rails
15
15
  end
16
16
 
17
17
  it "includes routing matchers" do
18
- group.included_modules.should include(RSpec::Rails::Matchers::RoutingMatchers)
18
+ expect(group.included_modules).to include(RSpec::Rails::Matchers::RoutingMatchers)
19
19
  end
20
20
 
21
21
  it "adds :type => :controller to the metadata" do
22
- group.metadata[:type].should eq(:controller)
22
+ expect(group.metadata[:type]).to eq(:controller)
23
23
  end
24
24
 
25
25
  context "with implicit subject" do
26
26
  it "uses the controller as the subject" do
27
27
  controller = double('controller')
28
28
  example = group.new
29
- example.stub(:controller => controller)
30
- example.subject.should == controller
29
+ allow(example).to receive(:controller).and_return(controller)
30
+ expect(example.subject).to eq(controller)
31
31
  end
32
32
  end
33
33
 
@@ -35,7 +35,7 @@ module RSpec::Rails
35
35
  it "uses the specified subject instead of the controller" do
36
36
  group.subject { 'explicit' }
37
37
  example = group.new
38
- example.subject.should == 'explicit'
38
+ expect(example.subject).to eq('explicit')
39
39
  end
40
40
  end
41
41
 
@@ -48,10 +48,10 @@ module RSpec::Rails
48
48
 
49
49
  it "delegates named route helpers to the underlying controller" do
50
50
  controller = double('controller')
51
- controller.stub(:foos_url).and_return('http://test.host/foos')
51
+ allow(controller).to receive(:foos_url).and_return('http://test.host/foos')
52
52
 
53
53
  example = group.new
54
- example.stub(:controller => controller)
54
+ allow(example).to receive(:controller).and_return(controller)
55
55
 
56
56
  # As in the routing example spec, this is pretty invasive, but not sure
57
57
  # how to do it any other way as the correct operation relies on before
@@ -60,7 +60,7 @@ module RSpec::Rails
60
60
  routes.draw { resources :foos }
61
61
  example.instance_variable_set(:@orig_routes, routes)
62
62
 
63
- example.foos_url.should eq('http://test.host/foos')
63
+ expect(example.foos_url).to eq('http://test.host/foos')
64
64
  end
65
65
  end
66
66
 
@@ -77,23 +77,49 @@ module RSpec::Rails
77
77
 
78
78
  describe "with inferred anonymous controller" do
79
79
  before do
80
- group.stub(:controller_class).and_return(Class.new)
80
+ allow(group).to receive(:controller_class).and_return(Class.new)
81
81
  end
82
82
 
83
- it "infers the anonymous controller class when infer_base_class_for_anonymous_controllers is true" do
84
- RSpec.configuration.stub(:infer_base_class_for_anonymous_controllers?).and_return(true)
85
- group.controller { }
83
+ context "when infer_base_class_for_anonymous_controllers is true" do
84
+ before do
85
+ allow(RSpec.configuration).to receive(:infer_base_class_for_anonymous_controllers?).and_return(true)
86
+ end
87
+
88
+ it "infers the anonymous controller class" do
89
+ group.controller { }
90
+
91
+ controller_class = group.metadata[:example_group][:described_class]
92
+ expect(controller_class.superclass).to eq(group.controller_class)
93
+ end
94
+
95
+ it "infers the anonymous controller class when no ApplicationController is present" do
96
+ hide_const '::ApplicationController'
97
+ group.controller { }
86
98
 
87
- controller_class = group.metadata[:example_group][:described_class]
88
- controller_class.superclass.should eq(group.controller_class)
99
+ controller_class = group.metadata[:example_group][:described_class]
100
+ expect(controller_class.superclass).to eq(group.controller_class)
101
+ end
89
102
  end
90
103
 
91
- it "sets the anonymous controller class to ApplicationController when infer_base_class_for_anonymous_controllers is false" do
92
- RSpec.configuration.stub(:infer_base_class_for_anonymous_controllers?).and_return(false)
93
- group.controller { }
104
+ context "when infer_base_class_for_anonymous_controllers is false" do
105
+ before do
106
+ allow(RSpec.configuration).to receive(:infer_base_class_for_anonymous_controllers?).and_return(false)
107
+ end
108
+
109
+ it "sets the anonymous controller class to ApplicationController" do
110
+ group.controller { }
111
+
112
+ controller_class = group.metadata[:example_group][:described_class]
113
+ expect(controller_class.superclass).to eq(ApplicationController)
114
+ end
115
+
116
+ it "sets the anonymous controller class to ActiveController::Base when no ApplicationController is present" do
117
+ hide_const '::ApplicationController'
118
+ group.controller { }
94
119
 
95
- controller_class = group.metadata[:example_group][:described_class]
96
- controller_class.superclass.should eq(ApplicationController)
120
+ controller_class = group.metadata[:example_group][:described_class]
121
+ expect(controller_class.superclass).to eq(ActionController::Base)
122
+ end
97
123
  end
98
124
  end
99
125
  end