2
votes

I've read all the recommendations about how to get rspec on rails working with zeus. In particular, I've commented out "require 'rspec/autorun'" in spec/spec_helper.rb:

# require 'rspec/autorun'

I start up zeus in one terminal:

zeus start

Then in another terminal run rspec:

zeus rspec spec/controllers/source_configs_controller_spec.rb

And get... nothing. No output, no response, nada - just dumps me back to command line. However, if I uncomment require 'rspec/autorun' in spec_helper.rb, and run it again, I get:


Failure/Error: post :create, {:account_id => @account.id, :source_config => valid_attributes.except(:account_id)}, {}
NoMethodError:
  undefined method `post' for #<RSpec::Core::ExampleGroup::Nested_2::Nested_1::Nested_1:0x007fbdff3032d8>

Any ideas? I feel like I've lost more time trying to figure this out than I'll ever recover with speedier rspec runs... so frustrating.

2

2 Answers

1
votes

After more digging and experimentation, it looks like rr (mocking framework) in spec_helper.rb was the culprit. I had

RSpec.configure do |config|
  config.mock_with :rr
  #...
end

To fix it:

  1. Upgrade rr ("bundle update rr").
  2. Initialize rr in a different manner:

In Gemfile

group :development, :test do
  gem "rr", :require => false # important to specify ":require => false"
  gem "rspec-rails"
  # (any other appropriate gems)
end

In spec_helper.rb

require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'

# vvvv NOTE: this is how you enable rr now
require 'rr'

#require 'rspec/autorun'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
  # ## Mock Framework
  #
  # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
  #
  # config.mock_with :mocha
  # config.mock_with :flexmock

  # vvvv NOTE: Make sure this line is commented out
  # config.mock_with :rr

  # ... other rspec config
end

Would love to hear anyone else's thoughts - is there a better way?

0
votes

So I was having the same issue and using some debugging I found that the tests were being run, but there was no output.

What worked so far is putting config.reset at the top of the RSpec.configure block. I got that idea from here: https://github.com/burke/zeus/issues/461 which got the idea from here: How can I configure rspec to show output with spork?

As a warning, one of the comments in the first link mentions that putting config.reset has undesirable side effects, but I have not run into any .... yet.