Description
What Ruby, Rails and RSpec versions are you using?
Ruby version: 2.7.1
Rails version: 5.2.4.3
RSpec version: rspec-rails (4.0.1)
Observed behaviour
I write a channel rspec like this:
RSpec.describe GmiChannel do
before do
stub_connection current_user: nil
end
it 'fails' do
end
end
and it fails with
NoMethodError:
undefined method `stub_connection' for #<RSpec::ExampleGroups::GmiChannel::OlderRun:0x00007fa138fcd498>
Expected Behaviour
I expect stub_connection to be defined. Perhaps the version check here should allow rails 5.2:
26: def has_action_cable_testing?
27 defined?(::ActionCable) && ActionCable::VERSION::MAJOR >= 6
28 end
tl; dr section
I've tracked this down to a mismatch in version numbers. rspec-rails has the following method:
rspec-rails-4.0.1/lib/rspec/rails/matchers.rb:
29: if RSpec::Rails::FeatureCheck.has_action_cable_testing?
30 require 'rspec/rails/matchers/action_cable'
31 end
And also,
rspec-rails-4.0.1/lib/rspec/rails/feature_check.rb:
26: def has_action_cable_testing?
27 defined?(::ActionCable) && ActionCable::VERSION::MAJOR >= 6
28 end
In my project, rails is '5.2.4.3' and so actioncable is version 5.2.4.3.
Now, I'm happy to continue using action-cable-testing, but unfortunately, it detects that rspec defines " has_action_cable_testing?", issues a deprecation warning, and then doesn't load.
Maybe I should file the bug report over there? Not sure, plus I know that he's deprecating that gem, so starting here.