rspec-rails 2.99.0 → 3.0.0.beta1

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 (128) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.sig +2 -0
  3. data.tar.gz.sig +0 -0
  4. data/Changelog.md +40 -68
  5. data/License.txt +1 -0
  6. data/README.md +6 -4
  7. data/features/Generators.md +24 -0
  8. data/features/GettingStarted.md +84 -0
  9. data/features/README.md +56 -0
  10. data/features/RailsVersions.md +4 -0
  11. data/features/Transactions.md +84 -0
  12. data/features/Upgrade.md +121 -0
  13. data/features/controller_specs/Cookies.md +57 -0
  14. data/features/controller_specs/README.md +45 -0
  15. data/features/controller_specs/anonymous_controller.feature +378 -0
  16. data/features/controller_specs/bypass_rescue.feature +75 -0
  17. data/features/controller_specs/controller_spec.feature +58 -0
  18. data/features/controller_specs/engine_routes.feature +51 -0
  19. data/features/controller_specs/isolation_from_views.feature +87 -0
  20. data/features/controller_specs/render_views.feature +114 -0
  21. data/features/directory_structure.feature +71 -0
  22. data/features/feature_specs/feature_spec.feature +35 -0
  23. data/features/helper_specs/helper_spec.feature +122 -0
  24. data/features/mailer_specs/url_helpers.feature +38 -0
  25. data/features/matchers/README.md +18 -0
  26. data/features/matchers/new_record_matcher.feature +41 -0
  27. data/features/matchers/redirect_to_matcher.feature +40 -0
  28. data/features/matchers/relation_match_array.feature +27 -0
  29. data/features/matchers/render_template_matcher.feature +49 -0
  30. data/features/mocks/mock_model.feature +147 -0
  31. data/features/mocks/stub_model.feature +58 -0
  32. data/features/model_specs/README.md +21 -0
  33. data/features/model_specs/errors_on.feature +51 -0
  34. data/features/model_specs/records.feature +27 -0
  35. data/features/model_specs/transactional_examples.feature +109 -0
  36. data/features/request_specs/request_spec.feature +49 -0
  37. data/features/routing_specs/README.md +16 -0
  38. data/features/routing_specs/be_routable_matcher.feature +80 -0
  39. data/features/routing_specs/engine_routes.feature +38 -0
  40. data/features/routing_specs/named_routes.feature +18 -0
  41. data/features/routing_specs/route_to_matcher.feature +90 -0
  42. data/features/step_definitions/additional_cli_steps.rb +4 -0
  43. data/features/step_definitions/model_steps.rb +3 -0
  44. data/features/support/capybara.rb +7 -0
  45. data/features/support/env.rb +53 -0
  46. data/features/support/rails_versions.rb +4 -0
  47. data/features/support/rubinius.rb +6 -0
  48. data/features/view_specs/inferred_controller_path.feature +45 -0
  49. data/features/view_specs/stub_template.feature +51 -0
  50. data/features/view_specs/view_spec.feature +206 -0
  51. data/lib/generators/rspec/controller/templates/controller_spec.rb +1 -1
  52. data/lib/generators/rspec/install/templates/spec/spec_helper.rb.tt +2 -21
  53. data/lib/generators/rspec/integration/integration_generator.rb +2 -3
  54. data/lib/generators/rspec/integration/templates/request_spec.rb +1 -1
  55. data/lib/generators/rspec/mailer/templates/mailer_spec.rb +4 -4
  56. data/lib/generators/rspec/scaffold/scaffold_generator.rb +2 -3
  57. data/lib/generators/rspec/scaffold/templates/controller_spec.rb +16 -16
  58. data/lib/generators/rspec/scaffold/templates/edit_spec.rb +2 -2
  59. data/lib/generators/rspec/scaffold/templates/index_spec.rb +1 -1
  60. data/lib/generators/rspec/scaffold/templates/new_spec.rb +2 -2
  61. data/lib/generators/rspec/scaffold/templates/routing_spec.rb +7 -7
  62. data/lib/generators/rspec/scaffold/templates/show_spec.rb +2 -2
  63. data/lib/rspec/rails.rb +0 -5
  64. data/lib/rspec/rails/adapters.rb +5 -12
  65. data/lib/rspec/rails/example.rb +55 -24
  66. data/lib/rspec/rails/example/controller_example_group.rb +7 -31
  67. data/lib/rspec/rails/example/view_example_group.rb +0 -3
  68. data/lib/rspec/rails/matchers.rb +1 -2
  69. data/lib/rspec/rails/matchers/be_a_new.rb +1 -1
  70. data/lib/rspec/rails/matchers/be_new_record.rb +1 -1
  71. data/lib/rspec/rails/matchers/be_valid.rb +1 -1
  72. data/lib/rspec/rails/matchers/have_rendered.rb +1 -1
  73. data/lib/rspec/rails/matchers/redirect_to.rb +1 -1
  74. data/lib/rspec/rails/matchers/relation_match_array.rb +1 -1
  75. data/lib/rspec/rails/matchers/routing_matchers.rb +6 -10
  76. data/lib/rspec/rails/mocks.rb +5 -41
  77. data/lib/rspec/rails/tasks/rspec.rake +5 -12
  78. data/lib/rspec/rails/vendor/capybara.rb +4 -35
  79. data/lib/rspec/rails/version.rb +1 -1
  80. data/spec/generators/rspec/controller/controller_generator_spec.rb +97 -0
  81. data/spec/generators/rspec/helper/helper_generator_spec.rb +30 -0
  82. data/spec/generators/rspec/install/install_generator_spec.rb +30 -0
  83. data/spec/generators/rspec/integration/integration_generator_spec.rb +44 -0
  84. data/spec/generators/rspec/mailer/mailer_generator_spec.rb +48 -0
  85. data/spec/generators/rspec/model/model_generator_spec.rb +52 -0
  86. data/spec/generators/rspec/observer/observer_generator_spec.rb +21 -0
  87. data/spec/generators/rspec/scaffold/scaffold_generator_spec.rb +138 -0
  88. data/spec/generators/rspec/view/view_generator_spec.rb +41 -0
  89. data/spec/rspec/rails/assertion_adapter_spec.rb +28 -0
  90. data/spec/rspec/rails/assertion_delegator_spec.rb +43 -0
  91. data/spec/rspec/rails/configuration_spec.rb +26 -0
  92. data/spec/rspec/rails/deprecations_spec.rb +18 -0
  93. data/spec/rspec/rails/example/controller_example_group_spec.rb +100 -0
  94. data/spec/rspec/rails/example/feature_example_group_spec.rb +56 -0
  95. data/spec/rspec/rails/example/helper_example_group_spec.rb +66 -0
  96. data/spec/rspec/rails/example/mailer_example_group_spec.rb +21 -0
  97. data/spec/rspec/rails/example/model_example_group_spec.rb +15 -0
  98. data/spec/rspec/rails/example/request_example_group_spec.rb +17 -0
  99. data/spec/rspec/rails/example/routing_example_group_spec.rb +32 -0
  100. data/spec/rspec/rails/example/view_example_group_spec.rb +220 -0
  101. data/spec/rspec/rails/extensions/active_model/errors_on_spec.rb +23 -0
  102. data/spec/rspec/rails/extensions/active_record/base_spec.rb +42 -0
  103. data/spec/rspec/rails/fixture_support_spec.rb +17 -0
  104. data/spec/rspec/rails/matchers/be_a_new_spec.rb +142 -0
  105. data/spec/rspec/rails/matchers/be_new_record_spec.rb +33 -0
  106. data/spec/rspec/rails/matchers/be_routable_spec.rb +41 -0
  107. data/spec/rspec/rails/matchers/be_valid_spec.rb +44 -0
  108. data/spec/rspec/rails/matchers/has_spec.rb +29 -0
  109. data/spec/rspec/rails/matchers/have_rendered_spec.rb +93 -0
  110. data/spec/rspec/rails/matchers/redirect_to_spec.rb +80 -0
  111. data/spec/rspec/rails/matchers/relation_match_array_spec.rb +31 -0
  112. data/spec/rspec/rails/matchers/route_to_spec.rb +151 -0
  113. data/spec/rspec/rails/minitest_lifecycle_adapter_spec.rb +22 -0
  114. data/spec/rspec/rails/mocks/mock_model_spec.rb +378 -0
  115. data/spec/rspec/rails/mocks/stub_model_spec.rb +154 -0
  116. data/spec/rspec/rails/setup_and_teardown_adapter_spec.rb +32 -0
  117. data/spec/rspec/rails/view_rendering_spec.rb +111 -0
  118. data/spec/spec_helper.rb +35 -0
  119. data/spec/support/ar_classes.rb +42 -0
  120. data/spec/support/helpers.rb +20 -0
  121. data/spec/support/matchers.rb +9 -0
  122. data/spec/support/null_object.rb +6 -0
  123. metadata +229 -42
  124. metadata.gz.sig +0 -0
  125. data/lib/autotest/rails_rspec2.rb +0 -91
  126. data/lib/rspec/rails/infer_type_configuration.rb +0 -26
  127. data/lib/rspec/rails/matchers/have_extension.rb +0 -36
  128. data/lib/rspec/rails/module_inclusion.rb +0 -19
@@ -7,7 +7,7 @@ describe <%= class_name %>Controller do
7
7
  describe "GET '<%= action %>'" do
8
8
  it "returns http success" do
9
9
  get '<%= action %>'
10
- response.should be_success
10
+ expect(response).to be_success
11
11
  end
12
12
  end
13
13
 
@@ -2,6 +2,7 @@
2
2
  ENV["RAILS_ENV"] ||= 'test'
3
3
  require File.expand_path("../../config/environment", __FILE__)
4
4
  require 'rspec/rails'
5
+ require 'rspec/autorun'
5
6
 
6
7
  # Requires supporting ruby files with custom matchers and macros, etc, in
7
8
  # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
@@ -12,12 +13,7 @@ require 'rspec/rails'
12
13
  # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
13
14
  Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
14
15
 
15
- <% if ::Rails::VERSION::STRING >= '4.1' -%>
16
- # Checks for pending migrations before tests are run.
17
- # If you are not using ActiveRecord, you can remove this line.
18
- ActiveRecord::Migration.maintain_test_schema!
19
-
20
- <% elsif ::Rails::VERSION::STRING >= '4' -%>
16
+ <% if ::Rails::VERSION::STRING >= '4' -%>
21
17
  # Checks for pending migrations before tests are run.
22
18
  # If you are not using ActiveRecord, you can remove this line.
23
19
  ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
@@ -50,19 +46,4 @@ RSpec.configure do |config|
50
46
  # the seed, which is printed after each run.
51
47
  # --seed 1234
52
48
  config.order = "random"
53
-
54
- # RSpec Rails can automatically mix in different behaviours to your tests
55
- # based on their file location, for example enabling you to call `get` and
56
- # `post` in specs under `spec/controllers`.
57
- #
58
- # You can disable this behaviour by removing the line below, and instead
59
- # explictly tag your specs with their type, e.g.:
60
- #
61
- # describe UsersController, :type => :controller do
62
- # # ...
63
- # end
64
- #
65
- # The different available types are documented in the features, such as in
66
- # https://relishapp.com/rspec/rspec-rails/v/3-0/docs
67
- config.infer_spec_type_from_file_location!
68
49
  end
@@ -10,16 +10,15 @@ module Rspec
10
10
  def generate_request_spec
11
11
  return unless options[:request_specs]
12
12
 
13
- RSpec.deprecate("the --webrat-matchers option", :replacement => nil) if options[:webrat_matchers]
14
- RSpec.deprecate("the --webrat option", :replacement => nil) if options[:webrat]
15
-
16
13
  template 'request_spec.rb',
17
14
  File.join('spec/requests', class_path, "#{table_name}_spec.rb")
18
15
  end
19
16
 
20
17
  protected
21
18
 
19
+ # @deprecated Use `--webrat` instead.
22
20
  def webrat?
21
+ RSpec.deprecate("the --webrat-matchers option", :replacement => "--webrat") if options[:webrat_matchers]
23
22
  options[:webrat] || options[:webrat_matchers]
24
23
  end
25
24
 
@@ -9,7 +9,7 @@ describe "<%= class_name.pluralize %>" do
9
9
  # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
10
10
  get <%= index_helper %>_path
11
11
  <% end -%>
12
- response.status.should be(200)
12
+ expect(response.status).to be(200)
13
13
  end
14
14
  end
15
15
  end
@@ -7,13 +7,13 @@ describe <%= class_name %> do
7
7
  let(:mail) { <%= class_name %>.<%= action %> }
8
8
 
9
9
  it "renders the headers" do
10
- mail.subject.should eq(<%= action.to_s.humanize.inspect %>)
11
- mail.to.should eq(["to@example.org"])
12
- mail.from.should eq(["from@example.com"])
10
+ expect(mail.subject).to eq(<%= action.to_s.humanize.inspect %>)
11
+ expect(mail.to).to eq(["to@example.org"])
12
+ expect(mail.from).to eq(["from@example.com"])
13
13
  end
14
14
 
15
15
  it "renders the body" do
16
- mail.body.encoded.should match("Hi")
16
+ expect(mail.body.encoded).to match("Hi")
17
17
  end
18
18
  end
19
19
 
@@ -22,9 +22,6 @@ module Rspec
22
22
  def generate_controller_spec
23
23
  return unless options[:controller_specs]
24
24
 
25
- RSpec.deprecate("the --webrat-matchers option", :replacement => nil) if options[:webrat_matchers]
26
- RSpec.deprecate("the --webrat option", :replacement => nil) if options[:webrat]
27
-
28
25
  template 'controller_spec.rb',
29
26
  File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb")
30
27
  end
@@ -49,7 +46,9 @@ module Rspec
49
46
 
50
47
  protected
51
48
 
49
+ # @deprecated Use `--webrat` instead.
52
50
  def webrat?
51
+ RSpec.deprecate("--webrat-matchers", :replacement => "--webrat") if options[:webrat_matchers]
53
52
  options[:webrat] || options[:webrat_matchers]
54
53
  end
55
54
 
@@ -36,7 +36,7 @@ describe <%= controller_class_name %>Controller do
36
36
  it "assigns all <%= table_name.pluralize %> as @<%= table_name.pluralize %>" do
37
37
  <%= file_name %> = <%= class_name %>.create! valid_attributes
38
38
  get :index, {}, valid_session
39
- assigns(:<%= table_name %>).should eq([<%= file_name %>])
39
+ expect(assigns(:<%= table_name %>)).to eq([<%= file_name %>])
40
40
  end
41
41
  end
42
42
 
@@ -45,14 +45,14 @@ describe <%= controller_class_name %>Controller do
45
45
  it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
46
46
  <%= file_name %> = <%= class_name %>.create! valid_attributes
47
47
  get :show, {:id => <%= file_name %>.to_param}, valid_session
48
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
48
+ expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
49
49
  end
50
50
  end
51
51
 
52
52
  describe "GET new" do
53
53
  it "assigns a new <%= ns_file_name %> as @<%= ns_file_name %>" do
54
54
  get :new, {}, valid_session
55
- assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
55
+ expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
56
56
  end
57
57
  end
58
58
 
@@ -60,7 +60,7 @@ describe <%= controller_class_name %>Controller do
60
60
  it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
61
61
  <%= file_name %> = <%= class_name %>.create! valid_attributes
62
62
  get :edit, {:id => <%= file_name %>.to_param}, valid_session
63
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
63
+ expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
64
64
  end
65
65
  end
66
66
 
@@ -74,13 +74,13 @@ describe <%= controller_class_name %>Controller do
74
74
 
75
75
  it "assigns a newly created <%= ns_file_name %> as @<%= ns_file_name %>" do
76
76
  post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
77
- assigns(:<%= ns_file_name %>).should be_a(<%= class_name %>)
78
- assigns(:<%= ns_file_name %>).should be_persisted
77
+ expect(assigns(:<%= ns_file_name %>)).to be_a(<%= class_name %>)
78
+ expect(assigns(:<%= ns_file_name %>)).to be_persisted
79
79
  end
80
80
 
81
81
  it "redirects to the created <%= ns_file_name %>" do
82
82
  post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session
83
- response.should redirect_to(<%= class_name %>.last)
83
+ expect(response).to redirect_to(<%= class_name %>.last)
84
84
  end
85
85
  end
86
86
 
@@ -89,14 +89,14 @@ describe <%= controller_class_name %>Controller do
89
89
  # Trigger the behavior that occurs when invalid params are submitted
90
90
  <%= class_name %>.any_instance.stub(:save).and_return(false)
91
91
  post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
92
- assigns(:<%= ns_file_name %>).should be_a_new(<%= class_name %>)
92
+ expect(assigns(:<%= ns_file_name %>)).to be_a_new(<%= class_name %>)
93
93
  end
94
94
 
95
95
  it "re-renders the 'new' template" do
96
96
  # Trigger the behavior that occurs when invalid params are submitted
97
97
  <%= class_name %>.any_instance.stub(:save).and_return(false)
98
98
  post :create, {:<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
99
- response.should render_template("new")
99
+ expect(response).to render_template("new")
100
100
  end
101
101
  end
102
102
  end
@@ -110,9 +110,9 @@ describe <%= controller_class_name %>Controller do
110
110
  # receives the :update_attributes message with whatever params are
111
111
  # submitted in the request.
112
112
  <%- if ::Rails::VERSION::STRING >= '4' -%>
113
- <%= class_name %>.any_instance.should_receive(:update).with(<%= formatted_hash(example_params_for_update) %>)
113
+ expect_any_instance_of(<%= class_name %>).to receive(:update).with(<%= formatted_hash(example_params_for_update) %>)
114
114
  <%- else -%>
115
- <%= class_name %>.any_instance.should_receive(:update_attributes).with(<%= formatted_hash(example_params_for_update) %>)
115
+ expect_any_instance_of(<%= class_name %>).to receive(:update_attributes).with(<%= formatted_hash(example_params_for_update) %>)
116
116
  <%- end -%>
117
117
  put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_params_for_update) %>}, valid_session
118
118
  end
@@ -120,13 +120,13 @@ describe <%= controller_class_name %>Controller do
120
120
  it "assigns the requested <%= ns_file_name %> as @<%= ns_file_name %>" do
121
121
  <%= file_name %> = <%= class_name %>.create! valid_attributes
122
122
  put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
123
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
123
+ expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
124
124
  end
125
125
 
126
126
  it "redirects to the <%= ns_file_name %>" do
127
127
  <%= file_name %> = <%= class_name %>.create! valid_attributes
128
128
  put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session
129
- response.should redirect_to(<%= file_name %>)
129
+ expect(response).to redirect_to(<%= file_name %>)
130
130
  end
131
131
  end
132
132
 
@@ -136,7 +136,7 @@ describe <%= controller_class_name %>Controller do
136
136
  # Trigger the behavior that occurs when invalid params are submitted
137
137
  <%= class_name %>.any_instance.stub(:save).and_return(false)
138
138
  put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
139
- assigns(:<%= ns_file_name %>).should eq(<%= file_name %>)
139
+ expect(assigns(:<%= ns_file_name %>)).to eq(<%= file_name %>)
140
140
  end
141
141
 
142
142
  it "re-renders the 'edit' template" do
@@ -144,7 +144,7 @@ describe <%= controller_class_name %>Controller do
144
144
  # Trigger the behavior that occurs when invalid params are submitted
145
145
  <%= class_name %>.any_instance.stub(:save).and_return(false)
146
146
  put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => <%= formatted_hash(example_invalid_attributes) %>}, valid_session
147
- response.should render_template("edit")
147
+ expect(response).to render_template("edit")
148
148
  end
149
149
  end
150
150
  end
@@ -160,7 +160,7 @@ describe <%= controller_class_name %>Controller do
160
160
  it "redirects to the <%= table_name %> list" do
161
161
  <%= file_name %> = <%= class_name %>.create! valid_attributes
162
162
  delete :destroy, {:id => <%= file_name %>.to_param}, valid_session
163
- response.should redirect_to(<%= index_helper %>_url)
163
+ expect(response).to redirect_to(<%= index_helper %>_url)
164
164
  end
165
165
  end
166
166
 
@@ -14,9 +14,9 @@ describe "<%= ns_table_name %>/edit" do
14
14
  render
15
15
 
16
16
  <% if webrat? -%>
17
- rendered.should have_selector("form", :action => <%= ns_file_name %>_path(@<%= ns_file_name %>), :method => "post") do |form|
17
+ expect(rendered).to have_selector("form", :action => <%= ns_file_name %>_path(@<%= ns_file_name %>), :method => "post") do |form|
18
18
  <% for attribute in output_attributes -%>
19
- form.should have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
19
+ expect(form).to have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
20
20
  <% end -%>
21
21
  end
22
22
  <% else -%>
@@ -23,7 +23,7 @@ describe "<%= ns_table_name %>/index" do
23
23
  <% end -%>
24
24
  <% for attribute in output_attributes -%>
25
25
  <% if webrat? -%>
26
- rendered.should have_selector("tr>td", :content => <%= value_for(attribute) %>.to_s, :count => 2)
26
+ expect(rendered).to have_selector("tr>td", :content => <%= value_for(attribute) %>.to_s, :count => 2)
27
27
  <% else -%>
28
28
  assert_select "tr>td", :text => <%= value_for(attribute) %>.to_s, :count => 2
29
29
  <% end -%>
@@ -13,9 +13,9 @@ describe "<%= ns_table_name %>/new" do
13
13
  render
14
14
 
15
15
  <% if webrat? -%>
16
- rendered.should have_selector("form", :action => <%= table_name %>_path, :method => "post") do |form|
16
+ expect(rendered).to have_selector("form", :action => <%= table_name %>_path, :method => "post") do |form|
17
17
  <% for attribute in output_attributes -%>
18
- form.should have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
18
+ expect(form).to have_selector("<%= attribute.input_type -%>#<%= ns_file_name %>_<%= attribute.name %>", :name => "<%= ns_file_name %>[<%= attribute.name %>]")
19
19
  <% end -%>
20
20
  end
21
21
  <% else -%>
@@ -6,32 +6,32 @@ describe <%= controller_class_name %>Controller do
6
6
 
7
7
  <% unless options[:singleton] -%>
8
8
  it "routes to #index" do
9
- get("/<%= ns_table_name %>").should route_to("<%= ns_table_name %>#index")
9
+ expect(:get => "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#index")
10
10
  end
11
11
 
12
12
  <% end -%>
13
13
  it "routes to #new" do
14
- get("/<%= ns_table_name %>/new").should route_to("<%= ns_table_name %>#new")
14
+ expect(:get => "/<%= ns_table_name %>/new").to route_to("<%= ns_table_name %>#new")
15
15
  end
16
16
 
17
17
  it "routes to #show" do
18
- get("/<%= ns_table_name %>/1").should route_to("<%= ns_table_name %>#show", :id => "1")
18
+ expect(:get => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#show", :id => "1")
19
19
  end
20
20
 
21
21
  it "routes to #edit" do
22
- get("/<%= ns_table_name %>/1/edit").should route_to("<%= ns_table_name %>#edit", :id => "1")
22
+ expect(:get => "/<%= ns_table_name %>/1/edit").to route_to("<%= ns_table_name %>#edit", :id => "1")
23
23
  end
24
24
 
25
25
  it "routes to #create" do
26
- post("/<%= ns_table_name %>").should route_to("<%= ns_table_name %>#create")
26
+ expect(:post => "/<%= ns_table_name %>").to route_to("<%= ns_table_name %>#create")
27
27
  end
28
28
 
29
29
  it "routes to #update" do
30
- put("/<%= ns_table_name %>/1").should route_to("<%= ns_table_name %>#update", :id => "1")
30
+ expect(:put => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#update", :id => "1")
31
31
  end
32
32
 
33
33
  it "routes to #destroy" do
34
- delete("/<%= ns_table_name %>/1").should route_to("<%= ns_table_name %>#destroy", :id => "1")
34
+ expect(:delete => "/<%= ns_table_name %>/1").to route_to("<%= ns_table_name %>#destroy", :id => "1")
35
35
  end
36
36
 
37
37
  end
@@ -19,9 +19,9 @@ describe "<%= ns_table_name %>/show" do
19
19
  <% end -%>
20
20
  <% for attribute in output_attributes -%>
21
21
  <% if webrat? -%>
22
- rendered.should contain(<%= value_for(attribute) %>.to_s)
22
+ expect(rendered).to contain(<%= value_for(attribute) %>.to_s)
23
23
  <% else -%>
24
- rendered.should match(/<%= eval(value_for(attribute)) %>/)
24
+ expect(rendered).to match(/<%= eval(value_for(attribute)) %>/)
25
25
  <% end -%>
26
26
  <% end -%>
27
27
  end
@@ -11,12 +11,7 @@ require 'rspec/rails/view_rendering'
11
11
  require 'rspec/rails/adapters'
12
12
  require 'rspec/rails/matchers'
13
13
  require 'rspec/rails/fixture_support'
14
-
15
- # Load rspec-activemodel-mocks if available; otherwise fall back
16
- # to the deprecated mock methods
17
14
  require 'rspec/rails/mocks'
18
- require 'rspec/rails/module_inclusion'
19
15
  require 'rspec/rails/example'
20
- require 'rspec/rails/infer_type_configuration'
21
16
  require 'rspec/rails/vendor/capybara'
22
17
  require 'rspec/rails/vendor/webrat'
@@ -1,5 +1,4 @@
1
1
  require 'delegate'
2
- require 'active_support'
3
2
  require 'active_support/concern'
4
3
 
5
4
  module RSpec
@@ -9,13 +8,7 @@ module RSpec
9
8
  require 'minitest/assertions'
10
9
  Assertions = Minitest::Assertions
11
10
  else
12
- begin
13
- require 'test/unit/assertions'
14
- rescue LoadError
15
- # work around for Rubinius not having a std std-lib
16
- require 'rubysl-test-unit' if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
17
- require 'test/unit/assertions'
18
- end
11
+ require 'test/unit/assertions'
19
12
  Assertions = Test::Unit::Assertions
20
13
  end
21
14
 
@@ -108,10 +101,10 @@ module RSpec
108
101
  # hooks.
109
102
  def setup(*methods)
110
103
  methods.each do |method|
111
- if method.to_s =~ /^setup_(with_controller|fixtures|controller_request_and_response)$/
112
- prepend_before { __send__ method }
104
+ if method.to_s =~ /^setup_(fixtures|controller_request_and_response)$/
105
+ prepend_before { send method }
113
106
  else
114
- before { __send__ method }
107
+ before { send method }
115
108
  end
116
109
  end
117
110
  end
@@ -121,7 +114,7 @@ module RSpec
121
114
  # Wraps `teardown` calls from within Rails' testing framework in
122
115
  # `after` hooks.
123
116
  def teardown(*methods)
124
- methods.each { |method| after { __send__ method } }
117
+ methods.each { |method| after { send method } }
125
118
  end
126
119
  end
127
120
 
@@ -13,30 +13,61 @@ RSpec::configure do |c|
13
13
  Regexp.compile(parts.join('[\\\/]') + '[\\\/]')
14
14
  end
15
15
 
16
- c.include RSpec::Rails::ControllerExampleGroup, :type => :controller, :example_group => {
17
- :file_path => c.escaped_path(%w[spec controllers])
18
- }
19
- c.include RSpec::Rails::HelperExampleGroup, :type => :helper, :example_group => {
20
- :file_path => c.escaped_path(%w[spec helpers])
21
- }
22
- if defined?(RSpec::Rails::MailerExampleGroup)
23
- c.include RSpec::Rails::MailerExampleGroup, :type => :mailer, :example_group => {
24
- :file_path => c.escaped_path(%w[spec mailers])
16
+ controller_path_regex = c.escaped_path(%w[spec controllers])
17
+ c.include RSpec::Rails::ControllerExampleGroup,
18
+ :type => :controller,
19
+ :example_group => lambda { |example_group, metadata|
20
+ metadata[:type].nil? && controller_path_regex =~ example_group[:file_path]
21
+ }
22
+
23
+ helper_path_regex = c.escaped_path(%w[spec helpers])
24
+ c.include RSpec::Rails::HelperExampleGroup,
25
+ :type => :helper,
26
+ :example_group => lambda { |example_group, metadata|
27
+ metadata[:type].nil? && helper_path_regex =~ example_group[:file_path]
25
28
  }
29
+
30
+ mailer_path_regex = c.escaped_path(%w[spec mailers])
31
+ if defined?(RSpec::Rails::MailerExampleGroup)
32
+ c.include RSpec::Rails::MailerExampleGroup,
33
+ :type => :mailer,
34
+ :example_group => lambda { |example_group, metadata|
35
+ metadata[:type].nil? && mailer_path_regex =~ example_group[:file_path]
36
+ }
26
37
  end
27
- c.include RSpec::Rails::ModelExampleGroup, :type => :model, :example_group => {
28
- :file_path => c.escaped_path(%w[spec models])
29
- }
30
- c.include RSpec::Rails::RequestExampleGroup, :type => :request, :example_group => {
31
- :file_path => c.escaped_path(%w[spec (requests|integration|api)])
32
- }
33
- c.include RSpec::Rails::RoutingExampleGroup, :type => :routing, :example_group => {
34
- :file_path => c.escaped_path(%w[spec routing])
35
- }
36
- c.include RSpec::Rails::ViewExampleGroup, :type => :view, :example_group => {
37
- :file_path => c.escaped_path(%w[spec views])
38
- }
39
- c.include RSpec::Rails::FeatureExampleGroup, :type => :feature, :example_group => {
40
- :file_path => c.escaped_path(%w[spec features])
41
- }
38
+
39
+ model_path_regex = c.escaped_path(%w[spec models])
40
+ c.include RSpec::Rails::ModelExampleGroup,
41
+ :type => :model,
42
+ :example_group => lambda { |example_group, metadata|
43
+ metadata[:type].nil? && model_path_regex =~ example_group[:file_path]
44
+ }
45
+
46
+ request_path_regex = c.escaped_path(%w[spec (requests|integration|api)])
47
+ c.include RSpec::Rails::RequestExampleGroup,
48
+ :type => :request,
49
+ :example_group => lambda { |example_group, metadata|
50
+ metadata[:type].nil? && request_path_regex =~ example_group[:file_path]
51
+ }
52
+
53
+ routing_path_regex = c.escaped_path(%w[spec routing])
54
+ c.include RSpec::Rails::RoutingExampleGroup,
55
+ :type => :routing,
56
+ :example_group => lambda { |example_group, metadata|
57
+ metadata[:type].nil? && routing_path_regex =~ example_group[:file_path]
58
+ }
59
+
60
+ view_path_regex = c.escaped_path(%w[spec views])
61
+ c.include RSpec::Rails::ViewExampleGroup,
62
+ :type => :view,
63
+ :example_group => lambda { |example_group, metadata|
64
+ metadata[:type].nil? && view_path_regex =~ example_group[:file_path]
65
+ }
66
+
67
+ feature_example_regex = c.escaped_path(%w[spec features])
68
+ c.include RSpec::Rails::FeatureExampleGroup,
69
+ :type => :feature,
70
+ :example_group => lambda { |example_group, metadata|
71
+ metadata[:type].nil? && feature_example_regex =~ example_group[:file_path]
72
+ }
42
73
  end