Skip to content

sentry-rails 4.9.0 breaks channels specs #1685

@maciejpankanin

Description

@maciejpankanin

Issue Description

Recently bumped sentry SKD to 4.9.0 and after that none of my channel specs passes 🙁

I get this error:

       undefined method `env' for #<ActionCable::Channel::ConnectionStub (...)
     # /usr/local/bundle/gems/sentry-rails-4.9.0/lib/sentry/rails/action_cable.rb:72:in `sentry_capture'
     # /usr/local/bundle/gems/sentry-rails-4.9.0/lib/sentry/rails/action_cable.rb:62:in `block (2 levels) in included'
     # /usr/local/bundle/gems/actioncable-6.1.4.4/lib/action_cable/engine.rb:68:in `block (3 levels) in <class:Engine>'
     # /usr/local/bundle/gems/actioncable-6.1.4.4/lib/action_cable/channel/base.rb:180:in `subscribe_to_channel'
     # /usr/local/bundle/gems/actioncable-6.1.4.4/lib/action_cable/channel/test_case.rb:228:in `subscribe'
     # ./spec/channels/agent_call_channel_spec.rb:7:in `block (2 levels) in <top (required)>'

Spec looks like this:

it "subscribes to a stream" do
    stub_connection cable_agent: agent

    subscribe

    expect(subscription).to be_confirmed
    assert_has_stream_for agent
end

I looked into ActionCable source and found out there is no env accessor for ActionCable::Channel::ConnectionStub class.

ActionCable::Connection
ActionCable::Channel::ConnectionStub

I do not see clear solution here, but maybe SDK could extend ActionCable::Channel::ConnectionStub and add .env attribute?

Reproduction Steps

Just prepare any channel spec using stub_connection helper.

Expected Behavior

Sentry SDK is not breaking any specs.

Actual Behavior

Sentry SDK is breaking channel specs.

Ruby Version

3.0.3

SDK Version

4.9.0

Integration and Its Version

Rails 6.1.4.4

Sentry Config

No response

Metadata

Metadata

Assignees

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions