I have a Rakefile that defines the spec task as
task :spec => [:check_dependencies, :load_backends]
And then runs the actual rspec tests. During the load_backends task, it loads a class called Story, but in the first spec test, defined?(Story) returns false.
I'm assuming that it is intended behavior of Rake to start with a fresh environment at the beginning of each task, but is there a way to override this? Or do I need to re-architect loading the backends into each task?
RSpec's spec task fires up a new Ruby process (mainly to not screw with your Rake process, I think), therefore classes defined in a rake task (even the spec task) are not available in your specs. Consider moving this logic to your spec helper or don't use RSpec's spec task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With