-
Notifications
You must be signed in to change notification settings - Fork 63
Shared rspec example groups not loading #39
Comments
Hey, I had this problem on a previous project, but sadly I don't have access to that code anymore. The gist of my solution was that I had to require all the shared examples in my spec helper, and I had to check to see if they had already been defined, because sometimes they would be defined multiple times :-O Hope that helps. |
Hmm interesting, that wouldn't be too bad if it's only in the spec_helper. Right now I have it loading all the shared examples without checking to see if they've been previously defined, but don't see them. Do you remember if there was a different way they have to be loaded rather than just requiring them like this? Dir[File.expand_path('../support/**/*.rb', __FILE__)].each do |file|
require(file)
end Thanks! |
Yeah, you can use load instead of require, which forces the code to run.
|
In brief testing, commenting out this line in Hydra and recompiling the gem seems to do the trick. Not sure if it's affecting something else just yet though. Could you provide a bit of background on what this line is doing? Any shared_examples_for blocks that are set will be reset once this line runs. RSpec.instance_variable_set(:@world, nil) |
That wipes the world so that it must reinstantiate itself between runs. If you're just doing local parallelization, maybe the parallel_tests gem is
|
Hey there, I'm having an issue with hydra with rspec where shared examples aren't able to be used for some reason (shared_examples_for).
It's able to load my environment and successfully run tests, but when it comes to one that uses shared examples defined in another file that was loaded on startup, it errors out.
I created a demo project that has the full stacktrace of the error that you should be able to reproduce:
RAILS_ENV=test rake hydra
https://github.com/adamfortuna/hydra-rspec-failure-demo
Here's a briefer overview:
In spec_helper.rb we load up some rspec shared examples:
Then attempt to use these later on in a test:
Which results in this error:
1303850302.11934 RUNNER| Running file: spec/helpers/application_helper_spec.rb
1303850302.18619 RUNNER| Could not find shared example group named "a demo example"
/Users/adam/.rvm/gems/ree-1.8.7-2010.02/gems/rspec-core-2.0.0.beta.19/lib/rspec/core/example_group.rb:65:in `it_should_behave_like': Could not find shared example group named "a demo example" (RuntimeError)
Full dump, gem versions and the rest in the repo, but it might just be a setup error on my part. I've tried this with various different rspec/hydra gem versions, but right now the demo is running 'hydra', '0.23.0' and 'rspec', '2.0.0.beta.19'. This spec can be run by itself, but errors out when run form hydra. Any ideas?
The text was updated successfully, but these errors were encountered: