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
set_fixture_class doesn't work in config.before block #510
Comments
That's because set_fixture_class is a class method, but before hooks run in instance scope. You'll need to do something like: config.before {
self.class.class_eval {
set_fixture_class :foo => Bar
}
} |
Can you just do: RSpec.configure do |config|
config.set_fixture_class :foo => Bar
end |
@justinko : that gives me |
@skizzybiz sorry @dchelimsky is right, it is a class method. |
Since set_fixture_class is a public method, you can also do this: config.before do
self.class.set_fixture_class :foo => Bar
end |
config.before does not quite work when you also have before blocks that reference fixture foo. In those cases the before block closer to the spec gets invoked first, which would again throw FixtureClassNotFound: No class attached to find. Using before(:all) solves it for me. config.before(:all) do
self.class.set_fixture_class :foo => Bar
end |
This does not work:
If I try to run that, it tells me:
spec_helper.rb:6:in 'included': undefined method 'set_fixture_class' for FixtureClasses:Module (NoMethodError)
.In order to get the equivalent functionality, I need to jump through hoops like:
The text was updated successfully, but these errors were encountered: