Skip to content

LetDefinitions needs to be defined on the nested instance rather than the definition of ExampleGroup #738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
### dev
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.13.1...master)

Bug fixes

* `let` definitions may override methods defined in modules brought in via
`config.include` in controller specs. Fixes regression introduced in 2.13.
(Andy Lindeman, Jon Rowe)

### 2.13.1 / 2013-04-27
[full changelog](http://github.com/rspec/rspec-rails/compare/v2.13.0...v2.13.1)

Expand Down
23 changes: 23 additions & 0 deletions features/controller_specs/controller_spec.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,26 @@ Feature: controller spec
"""
When I run `rspec spec`
Then the example should pass

Scenario: controller is extended with a helper module
Given a file named "spec/controllers/widgets_controller_spec.rb" with:
"""ruby
require "spec_helper"

module MyHelper
def my_variable
end
end

RSpec.configure {|c| c.include MyHelper }

describe WidgetsController do
let(:my_variable) { 'is a value' }

describe 'something' do
specify { expect(my_variable).to eq 'is a value' }
end
end
"""
When I run `rspec spec`
Then the example should pass
6 changes: 4 additions & 2 deletions lib/rspec/rails/example/controller_example_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ def method_missing(method, *args, &block)
end
end

included do
subject { controller }
def subject
controller
end

included do
metadata[:type] = :controller

before do
Expand Down