-
-
Notifications
You must be signed in to change notification settings - Fork 912
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
shoulda-matcher could not found test class name when work with rails 6 minitest #1247
Comments
We're a bit behind in supporting Minitest at the moment. I don't think we even test that you can use controller matchers in an ActionDispatch::IntegrationTest (although in theory they should work). I know the README advises staying on shoulda-matchers 2.x, but given that we are to 4.x now, what if you try upgrading? There's a pre-release version of shoulda-context out that should fix any compatibility issues. Instead of using this in your gemfile,
try:
Then add the following to your Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :minitest
with.library :rails
end
end |
I just tried what you suggests, it works just at before and I don't need now the extend Shoulda::Matchers::ActionController But its still failing on the same Error:
GradesControllerTest#test_: GET #index should render template index. :
NoMethodError: undefined method `body' for nil:NilClass
rails test /home/xxxx/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/shoulda-context-2.0.0.rc2/lib/shoulda/context/context.rb:62
E
Error:
GradesControllerTest#test_: GET #index should respond with 200. :
NoMethodError: undefined method `response_code' for nil:NilClass
rails test /home/xxxx/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/shoulda-context-2.0.0.rc2/lib/shoulda/context/context.rb:62 |
Hmm, alright. I don't have any immediate insight as to why this could be happening, but I'll look into this to see if there is a workaround. |
Great thanks! |
@mcmire Hi there, not sure if this issue is still being looked at, but I'm experiencing similar issues. After installing shoulda-matchers 4.4.1 in Rails 6.0.3 (ruby 2.7), I get gemfilegroup :test do
gem "shoulda-matchers", "~> 4.0"
end test_helperENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"
require "minitest/mock"
class ActiveSupport::TestCase
include FactoryBot::Syntax::Methods
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
# fixtures :none
# Add more helper methods to be used by all tests here...
def switch_account(account)
patch "/accounts/#{account.id}/switch"
end
end
class ActionDispatch::IntegrationTest
include Devise::Test::IntegrationHelpers
end
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :minitest
with.library :rails
end
end testrequire "test_helper"
class UserTest < ActiveSupport::TestCase
context 'associations' do
should have_many(:accounts)
end
end backtrace |
|
@mcmire With or without context, it seems matcher methods are not defined appropriately. |
Okay, sanity check. Which version of shoulda-context is being brought in? |
Right. So |
Thanks for that clarification. I've installed I get the same results if I use context as well. EDIT -- happy to open this as a separate issue |
The issue reported above is a false negative on my part due to my test running shortcut -- I'm no longer having issues, thanks! |
@mrjonesbot Ah, no worries, glad you figured it out! |
I'm using rails 6 and with most of ActionController matchers is not working.
Tests Controller
Errors
Gemfile
I think this is someway relate to this issues #1229, #1217, #1158.
I have add this line to make it work for some of the matchers as you suggest in #1158 :
But in the matchers that need the className is not working at all.
The text was updated successfully, but these errors were encountered: