Skip to content

Rails test framework is not fully set up before running group-specific before blocks #815

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

Closed
wants to merge 1 commit into from

Conversation

daisybill-dev
Copy link

Before blocks specific to view specs (and possibly controller specs) appear to run before the necessary Rails test framework setup methods. For example:

RSpec.configure do |config|
  config.before(:each, type: :view) do
    view.lookup_context.prefixes << 'wibble'
  end

This will fail, because the @controller instance variable has not been set up by the test framework; this is done by the #setup_with_controller method, which has not yet been called.

It's not entirely clear to me why this changed between 2.10.x and 2.14.x, or the plan to manage this going forward. I'm also not entirely clear how to write specs for this, since I don't know enough about Rspec internals to simulate running a before block from an example block. However, this small change fixes the problem, and all existing specs pass.

Specifically, the #setup_with_controller method of the test framework
must run before the spec-specific befores
@JonRowe
Copy link
Member

JonRowe commented Oct 9, 2013

I believe this has been addressed. See #833.

@JonRowe JonRowe closed this Oct 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants