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

Comments

Projects
None yet
@terlar

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

This comment has been minimized.

Show comment
Hide comment
@ryansch

ryansch Oct 5, 2012

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

ryansch commented Oct 5, 2012

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

@terlar

This comment has been minimized.

Show comment
Hide comment
@terlar

terlar 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 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

This comment has been minimized.

Show comment
Hide comment
@terlar

terlar 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 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 Oct 5, 2012

@ryansch

This comment has been minimized.

Show comment
Hide comment
@ryansch

ryansch Oct 5, 2012

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

ryansch commented Oct 5, 2012

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

@mattheworiordan

This comment has been minimized.

Show comment
Hide comment
@mattheworiordan

mattheworiordan Jan 27, 2013

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.

mattheworiordan commented Jan 27, 2013

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

This comment has been minimized.

Show comment
Hide comment
@lcx

lcx 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.

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

This comment has been minimized.

Show comment
Hide comment
@squiter

squiter Apr 18, 2013

unfortunately it didn't work for me too.

squiter commented Apr 18, 2013

unfortunately it didn't work for me too.

@andyw8

This comment has been minimized.

Show comment
Hide comment
@andyw8

andyw8 Apr 18, 2013

Contributor

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

Contributor

andyw8 commented Apr 18, 2013

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

@squiter

This comment has been minimized.

Show comment
Hide comment
@squiter

squiter 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.

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

This comment has been minimized.

Show comment
Hide comment
@terlar

terlar Apr 19, 2013

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

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

This comment has been minimized.

Show comment
Hide comment
@lcx

lcx 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

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

This comment has been minimized.

Show comment
Hide comment
@squiter

squiter 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! 👍

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

This comment has been minimized.

Show comment
Hide comment
@lcx

lcx Apr 19, 2013

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

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

This comment has been minimized.

Show comment
Hide comment
@squiter

squiter Apr 19, 2013

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

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

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

This comment has been minimized.

Show comment
Hide comment
@lcx

lcx Apr 19, 2013

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

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

This comment has been minimized.

Show comment
Hide comment
@lcx

lcx 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

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

This comment has been minimized.

Show comment
Hide comment
@SeriousM

SeriousM 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.

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

This comment has been minimized.

Show comment
Hide comment
@alex-zige

alex-zige May 14, 2013

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

alex-zige commented May 14, 2013

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

@HangingClowns

This comment has been minimized.

Show comment
Hide comment
@HangingClowns

HangingClowns Jul 29, 2013

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

HangingClowns commented Jul 29, 2013

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

@szymon-jez

This comment has been minimized.

Show comment
Hide comment
@szymon-jez

szymon-jez Nov 27, 2013

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?

szymon-jez commented Nov 27, 2013

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

This comment has been minimized.

Show comment
Hide comment
@mattheworiordan

mattheworiordan Nov 27, 2013

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

mattheworiordan commented Nov 27, 2013

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

@michaelglass

This comment has been minimized.

Show comment
Hide comment
@michaelglass

michaelglass May 1, 2014

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

michaelglass commented May 1, 2014

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

@michaelglass

This comment has been minimized.

Show comment
Hide comment
@michaelglass

michaelglass May 22, 2014

also: ensure require:false

gem 'shoulda-matchers', require: false

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

michaelglass commented May 22, 2014

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

This comment has been minimized.

Show comment
Hide comment
@edipofederle

edipofederle Nov 20, 2014

Someone with this issue when running tests usign guard ?

edipofederle commented Nov 20, 2014

Someone with this issue when running tests usign guard ?

@lukerollans

This comment has been minimized.

Show comment
Hide comment
@lukerollans

lukerollans Jun 3, 2015

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

lukerollans commented Jun 3, 2015

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

This comment has been minimized.

Show comment
Hide comment
@gmonfort

gmonfort commented Oct 28, 2015

+1 to @michaelglass solution

@Andrelton

This comment has been minimized.

Show comment
Hide comment
@Andrelton

Andrelton Nov 22, 2015

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

Andrelton commented Nov 22, 2015

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

@AlejandroFernandesAntunes

This comment has been minimized.

Show comment
Hide comment
@AlejandroFernandesAntunes

AlejandroFernandesAntunes Oct 11, 2017

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

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