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

Dependence issue with shoulda-matchers 3 and should 3.5 #825

Closed
olimart opened this issue Oct 29, 2015 · 12 comments
Closed

Dependence issue with shoulda-matchers 3 and should 3.5 #825

olimart opened this issue Oct 29, 2015 · 12 comments
Milestone

Comments

@olimart
Copy link
Contributor

olimart commented Oct 29, 2015

Following installation instructions and since I'm using Minitest I've added both shoulda and shoulda-matchers to Gemfile.

Bundler could not find compatible versions for gem "shoulda-matchers":
  In snapshot (Gemfile.lock):
    shoulda-matchers (3.0.1)

  In Gemfile:
    shoulda (~> 3.5) ruby depends on
      shoulda-matchers (< 3.0, >= 1.4.1) ruby
@mcmire
Copy link
Collaborator

mcmire commented Oct 29, 2015

Yes, shoulda needs to be updated to support shoulda-matchers 3.x. I'll submit a PR over there. Thanks for reminding.

@mcmire mcmire modified the milestones: 3.0.1, 3.0.2 Nov 20, 2015
@mcmire mcmire modified the milestones: 3.1.0, 3.0.2 Jan 10, 2016
@mcmire
Copy link
Collaborator

mcmire commented Jan 10, 2016

I'm delaying this until we get all of the 3.0.0 regressions under control.

@mcmire
Copy link
Collaborator

mcmire commented Jan 10, 2016

In the meantime, I've updated the README to suggest that shoulda users use shoulda-matchers 2.8.0.

@gamov
Copy link

gamov commented Feb 19, 2016

Is it possible, in the meantime, to use shoulda-matchers and minitest without shoulda-context (which provides the 'should' keyword?)? For example, calling them in some fashion in a regular test?

@olimart
Copy link
Contributor Author

olimart commented Feb 19, 2016

@gamov I've tried a bunch of things but all failed so I gave up and now waiting for the release (not sure what's holding on though).

@mcmire
Copy link
Collaborator

mcmire commented Jun 10, 2016

Sorry to keep you waiting. I've created thoughtbot/shoulda#261 to address this.

@samuelpismel
Copy link

Any news on this? It would be nice to use pure minitest with shoulda matchers.

@zavan
Copy link

zavan commented Feb 2, 2017

@gamov @olimart @samuelpismel
I'm successfully using shoulda-matchers with standard MiniTest tests thanks to the minitest-matchers_vaccine gem:

Gemfile:

group :test do
  gem 'shoulda-matchers'
  gem 'minitest-matchers_vaccine'
end

test_helper.rb:

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

user_test.rb:

class UserTest <  Minitest::Test
  def test_validation
    user = User.new
    assert_must validate_presence_of(:email), user
  end
end

or using @subject and must:

class UserTest < Minitest::Test
  def setup
    @subject = User.new
  end

  def test_validation
    must validate_presence_of :email
  end
end

@zavan
Copy link

zavan commented Feb 2, 2017

I have created a wiki page to help others with this problem: https://github.com/thoughtbot/shoulda-matchers/wiki/Usage-with-standard-MiniTest-tests

@olimart
Copy link
Contributor Author

olimart commented Feb 2, 2017

Thanks @zavan

@olimart olimart closed this as completed Feb 2, 2017
@mcmire
Copy link
Collaborator

mcmire commented Feb 3, 2017

That is really great! I'm guessing that you can use this gem alongside shoulda-context if you like? Has anyone tried this?

@zavan
Copy link

zavan commented Feb 3, 2017

@mcmire I haven't tried it, but I think so. The gem is super simple:
https://github.com/rmm5t/minitest-matchers_vaccine/blob/master/lib/minitest/matchers_vaccine.rb

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

5 participants