Follow the README's configuration section, I got a NoMethodError when I use Shoulda::Matchers.configure in spec_helper.rb.
Can try with this demo repository to reproduce.
In this repository, I only strip all comments in Gemfile and install rspec-rails and shoulda-matchers gem:
source 'https://rubygems.org'
gem 'rails', '4.2.1'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'rspec-rails'
end
group :test do
gem 'shoulda-matchers'
end
Then did:
$ rails g rspec:install
$ rails g scaffold user name
when I run the spec, bin/rspec I got:
/Users/Juan/null/shoulda-config/spec/spec_helper.rb:91:in `<top (required)>': undefined method `configure' for Shoulda::Matchers:Module (NoMethodError)
The Shoulda::Matchers configure block lives here:
require 'shoulda/matchers'
Shoulda::Matchers.configure do |config|
config.integrate do |with|
# Choose a test framework:
with.test_framework :rspec
# Choose a library:
with.library :active_record
with.library :active_model
with.library :action_controller
end
end
https://github.com/JuanitoFatas/shoulda-matchers-report/blob/master/spec/spec_helper.rb#L89-L101
What is the right way to configure shoulda-matchers alone without meta shoulda gem? Thanks!!!
You've got the syntax right, but there isn't a release that contains the new configuration stuff just yet -- it's only in master. We'll probably be publishing some kind of pre-release version soon, but if you want to try it out now, you can use:
gem 'shoulda-matchers', github: 'thoughtbot/shoulda-matchers'
Got it. Thank you, Elliot.
Good to know. Thanks!
I'm experiencing this error:
$ bundle install
Fetching git://github.com/thoughtbot/shoulda-matchers.git
fatal: Unable to look up github.com (port 9418) (nodename nor servname provided, or not known)
Retrying git clone 'git://github.com/thoughtbot/shoulda-matchers.git' "/Users/user/.rvm/gems/ruby-2.2.1/cache/bundler/git/shoulda-matchers-cd8a06a9d51df7c7d82151a699775b8e4698c027" --bare --no-hardlinks --quiet due to error (2/3): Bundler::Source::Git::GitCommandError Git error: command git clone 'git://github.com/thoughtbot/shoulda-matchers.git' "/Users/user/.rvm/gems/ruby-2.2.1/cache/bundler/git/shoulda-matchers-cd8a06a9d51df7c7d82151a699775b8e4698c027" --bare --no-hardlinks --quiet in directory /Users/user/ProjectsPortfolio/rails_projects/authenticator has failed.
fatal: Unable to look up github.com (port 9418) (nodename nor servname provided, or not known)
Git error: command git clone 'git://github.com/thoughtbot/shoulda-matchers.git'
"/Users/user/.rvm/gems/ruby-2.2.1/cache/bundler/git/shoulda-matchers-cd8a06a9d51df7c7d82151a699775b8e4698c027"
--bare --no-hardlinks --quiet in directory
/Users/user/ProjectsPortfolio/rails_projects/authenticator has failed.
Most helpful comment
You've got the syntax right, but there isn't a release that contains the new configuration stuff just yet -- it's only in master. We'll probably be publishing some kind of pre-release version soon, but if you want to try it out now, you can use: