Skip to content
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

The gem shoulda-matchers does not work #134

Closed
terlar opened this issue Oct 5, 2012 · 28 comments
Closed

The gem shoulda-matchers does not work #134

terlar opened this issue Oct 5, 2012 · 28 comments

Comments

@terlar
Copy link

terlar commented Oct 5, 2012

When running specs with zeus rspec all tests using shoulda-matchers fail.

I get the error message with undefined method which is the same as if shoulda-matchers weren't loaded.

Do I need to configure something special to get this to work with zeus? Works perfectly fine with bare rspec.

The only thing I have right now specific to the shoulda-matchers is the following code in my Gemfile and my specs of course.

group :test do
  gem 'shoulda-matchers'
end
@ryansch
Copy link

ryansch commented Oct 5, 2012

Do you have config.include Paperclip::Shoulda::Matchers defined in your spec_helper?

@terlar
Copy link
Author

terlar commented Oct 5, 2012

No, but I am not using paperclip though. I am using (https://github.com/thoughtbot/shoulda-matchers).

Don't use it for any models, only use it for my controllers at this moment. And again, works without zeus.

@terlar
Copy link
Author

terlar commented Oct 5, 2012

I will close this issue, zeus was just more sensitive to the order I loaded the gems. Fixed the order and put them in the same group to make it less error prone.

Setup that was failing:

group :test do
  gem 'shoulda-matchers'
end

group :development, :test do
  gem 'rspec-rails'
end

Setup that is working:

group :test do
  gem 'rspec-rails'
  gem 'shoulda-matchers'
end

@terlar terlar closed this as completed Oct 5, 2012
@ryansch
Copy link

ryansch commented Oct 5, 2012

Wow, I read through that way too fast. Sorry for the useless question.

@mattheworiordan
Copy link

Thanks @terlar, I had the same issue, moved rspec-rails and should-matchers to the top of my group :test and it worked. Very odd. Although another test is failing with zeus and working with normal rspec, I'll investigate now.

@lcx
Copy link

lcx commented Apr 11, 2013

unfortunately it didn't work for me. very odd, since I have a different project, same order but other versions for shoulda an rspec-rails, and there it works.

@squiter
Copy link

squiter commented Apr 18, 2013

unfortunately it didn't work for me too.

@andyw8
Copy link
Contributor

andyw8 commented Apr 18, 2013

@lcx and @squiter85 - can you share your full Gemfile in a gist please

@squiter
Copy link

squiter commented Apr 18, 2013

Here it goes @andyw8 https://gist.github.com/squiter85/5416077 :)
I already tried to change the order of groups and order of gems but still not work.

hmm I'm use 'shoulda', not 'shoulda-matcher', but I think the error is the same, my specs that don't use it runs fine.

@terlar
Copy link
Author

terlar commented Apr 19, 2013

@squiter85 Did you try to move them to the same group as that seemed to be the problem for me.

@lcx
Copy link

lcx commented Apr 19, 2013

https://gist.github.com/lcx/5419536

Funny thing is, I have a similar Gemfile in a different project where I have no problems.
I tried downgrading zeus to the same version as used in the other project but still have the same issue.
Here is the Gemfile of the other project where I don't have these issues: https://gist.github.com/lcx/5419573

@squiter
Copy link

squiter commented Apr 19, 2013

@terlar I was tried to change order of gems, but not tried put all in the same group, and when I made it all works fine!

Thank you guys! 👍

@lcx
Copy link

lcx commented Apr 19, 2013

@squiter85 could you please share your new gemfile? Didn't work for me so I'm curious where the difference is.

@squiter
Copy link

squiter commented Apr 19, 2013

Here @lcx https://gist.github.com/squiter85/5420557

I'm justo move 'gem "shoulda"' to the same group of 'rspec-rails' ;)

@lcx
Copy link

lcx commented Apr 19, 2013

nope, no matter how I change it, won't work for me. Any other hints except to remove shoulda?

@lcx
Copy link

lcx commented Apr 19, 2013

I just found this solution to be working:

Remove require 'rspec/autotest' from spec_helper.rb

from: http://stackoverflow.com/questions/14030561/zeus-rspec-fails-include-required-files-but-rspec-alone-does-fine

@SeriousM
Copy link

SeriousM commented May 2, 2013

I just found this solution to be working:
Remove require 'rspec/autotest' from spec_helper.rb

that worked for me too! thank you so much,was wasting so much time finding out the issue.

@alex-zige
Copy link

yeah. make sure remove/comment out # require 'rspec/autorun'. it helps <3

@allenwyma
Copy link

+50! Spent like all morning and part of the afternoon. Please someone put this on the README ASAP!

@szymon-jez
Copy link

How to not require it only when run via zeus?
The only idea I now have came up with is this require 'rspec/autorun' unless ENV['ZEUS'] bu then this is not DRY (I have to repeat something that could be set somehow OOTB by Zeus while run).
Any ideas?

@mattheworiordan
Copy link

I just removed require 'rspec/autorun' and everything worked both with RSpec with/without Zeus.

@michaelglass
Copy link

also: see thoughtbot/shoulda-matchers#384, this rebroke when I moved from shoulda-matchers 2.5 -> 2.6

@michaelglass
Copy link

also: ensure require:false

gem 'shoulda-matchers', require: false

and then require 'shoulda/matchers' in spec_helper.rb
as documented in the shoulda readme

@edipofederle
Copy link

Someone with this issue when running tests usign guard ?

@lukerollans
Copy link

Moving rspec-rails next to shoulda-matchers in my :test group did not work, however @michaelglass's solution did indeed work for me (require false in gemfile and manually requiring in spec_helper.rb

@gmonfort
Copy link

+1 to @michaelglass solution

@Andrelton
Copy link

Another +1 to the @michaelglass solution, thank you!

@AlejandroFernandesAntunes

it started working for me when adding the following to rails_helper:


Shoulda::Matchers.configure do |config|
  config.integrate do |with|
    with.test_framework :rspec
    with.library :rails
  end
end

which was in the readme file

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

No branches or pull requests