controller is nil in global before(:each, :type => :controller) hook #23

Closed
zealoushacker opened this Issue May 3, 2011 · 4 comments

Comments

Projects
None yet
4 participants
@zealoushacker

RSpec version: 2.4.0

I've defined method in ApplicationController, which is called via a before_filter.

I then added the following to spec_helper.rb:

RSpec.configure do |config|
  config.before(:each, :type => :controller) do
    controller.stub(:method)
  end
end

Every spec example throws the following:

FAn expectation of :method was set on nil. Called from spec/spec_helper.rb:75:in `block (2 levels) in <top (required)>'. Use allow_message_expectations_on_nil to disable warnings.

This leads me to conclude that controller is nil in global before(:each, :type => :controller) hooks.

@davidgrieser

This comment has been minimized.

Show comment
Hide comment
@davidgrieser

davidgrieser May 4, 2011

+1

Still seems to happen in RSpec 2.5.1 as well.

+1

Still seems to happen in RSpec 2.5.1 as well.

@trkoch

This comment has been minimized.

Show comment
Hide comment
@trkoch

trkoch Jun 5, 2011

+1

Observed in RSpec 2.6.3

trkoch commented Jun 5, 2011

+1

Observed in RSpec 2.6.3

@dchelimsky

This comment has been minimized.

Show comment
Hide comment
@dchelimsky

dchelimsky Jun 5, 2011

Owner

This is not going to be fixed in rspec-rails-1.x as it would require some re-architecting.

See rspec/rspec-rails#391 for info on same issue in rspec-rails-2.

Owner

dchelimsky commented Jun 5, 2011

This is not going to be fixed in rspec-rails-1.x as it would require some re-architecting.

See rspec/rspec-rails#391 for info on same issue in rspec-rails-2.

@dchelimsky dchelimsky closed this Jun 5, 2011

@zealoushacker

This comment has been minimized.

Show comment
Hide comment
@zealoushacker

zealoushacker Jun 7, 2011

David, thanks for the feedback. I'll be watching the issue in rspec-rails-2 more closely. wdso thank you for re-opening this issue in the appropriate place.

Cheers,
Alex

David, thanks for the feedback. I'll be watching the issue in rspec-rails-2 more closely. wdso thank you for re-opening this issue in the appropriate place.

Cheers,
Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment