Skip to content

Commit dad3f1b

Browse files
committed
subject is defined as a method rather than with the subject declarative method
There is currently some odd interactions between rspec-rails and rspec-core when it comes to `let` definitions. If we call `subject` in an `included` hook, the dynamically generated `LetDefinitions` module gets inserted into the ancestor chain earlier than normal. This placement no longer allows `let` definitions to override methods defined on other modules that are brought in via `config.include`. We may raise a warning in future (see discussion in #738) [Fixes #738]
1 parent 0d45ffb commit dad3f1b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-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

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)