Skip to content

Commit 6a328a2

Browse files
committed
Merge pull request #738 from rspec/define_let_block_definitions_on_example_group_instance
LetDefinitions needs to be defined on the nested instance rather than the definition of ExampleGroup
2 parents 06782b1 + dad3f1b commit 6a328a2

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
### dev
22
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.13.1...master)
33

4+
Bug fixes
5+
6+
* `let` definitions may override methods defined in modules brought in via
7+
`config.include` in controller specs. Fixes regression introduced in 2.13.
8+
(Andy Lindeman, Jon Rowe)
9+
410
### 2.13.1 / 2013-04-27
511
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.13.0...v2.13.1)
612

features/controller_specs/controller_spec.feature

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,26 @@ Feature: controller spec
3333
"""
3434
When I run `rspec spec`
3535
Then the example should pass
36+
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 "spec_helper"
41+
42+
module MyHelper
43+
def my_variable
44+
end
45+
end
46+
47+
RSpec.configure {|c| c.include MyHelper }
48+
49+
describe WidgetsController 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

lib/rspec/rails/example/controller_example_group.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,11 @@ def method_missing(method, *args, &block)
142142
end
143143
end
144144

145-
included do
146-
subject { controller }
145+
def subject
146+
controller
147+
end
147148

149+
included do
148150
metadata[:type] = :controller
149151

150152
before do

0 commit comments

Comments
 (0)