palkan / action-cable-testing

Action Cable testing utils
MIT License
213 stars 17 forks source link

Rails 6: undefined method `stub_connection' #48

Closed Petercopter closed 5 years ago

Petercopter commented 5 years ago

I was using this gem in Rails 5.x/RSpec before it was merged into Rails 6, and it worked great. I've got Rails 6 beta 1 running, and obviously I've commented out the gem now.

However, when I run my ActionCable tests, I'm getting NoMethodError: undefined method 'stub_connection'. It looks like I need to include something, and require "action_cable/testing/rspec" is no longer available. What am I missing here?

Thanks for the hard work, and congratulations on getting it merged into Rails.

palkan commented 5 years ago

Thanks for the report!

We plan to add RSpec support for Rails 6 soon (right after #46).

For now you can try the following:

# do not load the whole gem by default
gem "action-cable-testing", require: false

In your rails_helper.rb, after require "action_cable/testing/rspec" add the following (see https://github.com/palkan/action-cable-testing/pull/46/files#diff-fe8e12e25dcfdac5a034c51ff1cf1998R24):

RSpec::Rails::ChannelExampleGroup.include ActionCable::Connection::TestCase::Behavior

Hope that would help.

Petercopter commented 5 years ago

@palkan Thanks for the quick response! I ended up with this:

Bundler could not find compatible versions for gem "actioncable":
  In snapshot (Gemfile.lock):
    actioncable (= 6.0.0.beta1)

  In Gemfile:
    action-cable-testing (~> 0.4) was resolved to 0.4.0, which depends on
      actioncable (~> 5.0)

    rails (~> 6.0.0.beta1) was resolved to 6.0.0.beta1, which depends on
      actioncable (= 6.0.0.beta1)

Which is totally fine, obviously we need the rest of the Rails ecosystem to catch up. I've got a few other gems that aren't compatible as well. I will just sit tight and wait for things to progress.