Skip to content

Commit 87ed573

Browse files
committed
move rspec#738 regression check to spec
This is confusing and not useful as documentation, all rspec#738 was intended to do was to prevent our let definitions from being defined earlier than 3rd party inclusions (and hence being overriden) which was confusing behaviour, so move it to a spec.
1 parent 41628f8 commit 87ed573

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

features/controller_specs/controller_spec.feature

-23
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,6 @@ Feature: controller spec
3434
When I run `rspec spec`
3535
Then the example should pass
3636

37-
Scenario: controller is extended with a helper module
38-
Given a file named "spec/controllers/widgets_controller_spec.rb" with:
39-
"""ruby
40-
require "rails_helper"
41-
42-
module MyHelper
43-
def my_variable
44-
end
45-
end
46-
47-
RSpec.configure {|c| c.include MyHelper }
48-
49-
RSpec.describe WidgetsController, :type => :controller do
50-
let(:my_variable) { 'is a value' }
51-
52-
describe 'something' do
53-
specify { expect(my_variable).to eq 'is a value' }
54-
end
55-
end
56-
"""
57-
When I run `rspec spec`
58-
Then the example should pass
59-
6037
Scenario: setting a different content type for example json (request type)
6138
Given a file named "spec/controllers/widgets_controller_spec.rb" with:
6239
"""ruby

spec/rspec/rails/example/controller_example_group_spec.rb

+18
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ def group_for(klass)
2828
allow(example).to receive_messages(:controller => controller)
2929
expect(example.subject).to eq(controller)
3030
end
31+
32+
it "doesn't cause let definition priority to be changed" do
33+
# before #738 implicit subject definition for controllers caused
34+
# external methods to take precedence over our let definitions
35+
36+
with_isolated_config do |config|
37+
mod = Module.new do
38+
def my_helper
39+
"other_value"
40+
end
41+
end
42+
config.include mod
43+
group.class_exec do
44+
let(:my_helper) { "my_value" }
45+
end
46+
expect(group.new.my_helper).to eq "my_value"
47+
end
48+
end
3149
end
3250

3351
context "with explicit subject" do

0 commit comments

Comments
 (0)