Code Monkey home page Code Monkey logo

Comments (9)

palkan avatar palkan commented on June 11, 2024 1

@yamanaltereh

One more question: why do you override #subscribe_to_channel in your channel class instead of defining #subscribed callback? I guess, that's the problem; #subscribe_to_channel is an internal method, you should not patch it.

from action-cable-testing.

palkan avatar palkan commented on June 11, 2024

Hi @yamanaltereh,

How does your test look like?

from action-cable-testing.

yamanaltereh avatar yamanaltereh commented on June 11, 2024

@palkan Ah, I see .. actually the problem was .. when I use subscribed I get this error:

NoMethodError:
       private method `subscribe_to_channel' called for #<ConversationChannel:0x007fc1940c7418>
       Did you mean?  unsubscribe_from_channel
     # /Users/yaman/.rvm/gems/ruby-2.3.1/gems/action-cable-testing-0.1.0/lib/action_cable/channel/test_case.rb:201:in `subscribe'

after looking at the source code .. I thought it should be subscribe_to_channel ...

from action-cable-testing.

yamanaltereh avatar yamanaltereh commented on June 11, 2024

@palkan my rspec test is like this:

RSpec.describe ConversationChannel, type: :channel do
  let(:user) { build_stubbed(:user) }
  ...
  before do
      stub_connection user_id: user.id
  end

  it "rejected" do
    subscribe
    expect(subscription).to be_rejected
  end
end

from action-cable-testing.

palkan avatar palkan commented on June 11, 2024

@yamanaltereh It turned out that the problem was with Rails 5.0.0.1 calling subscribe_to_channel during the channel's initialization (fixed by myself, btw, in 5.0.1).

Fixed by #3 and released as 0.1.1.

from action-cable-testing.

yamanaltereh avatar yamanaltereh commented on June 11, 2024

@palkan okay thanks, updated gem to release 0.1.1 .. and it's working now 👍

from action-cable-testing.

mateuszdw avatar mateuszdw commented on June 11, 2024

Hello,
I see the same error on rails v5.1.0 & action-cable-testing v0.1.2
undefined method 'server' for #<ActionCable::Channel::ConnectionStub:0x00007fb5a758b998>
when use periodically timer

class TestChannel < ApplicationCable::Channel
  periodically every: 5.seconds do

  end

  def subscribed
    stream_from "some_channel"
  end
end

spec

require 'rails_helper'

RSpec.describe TestChannel, type: :channel do

  it "subscribe" do
    subscribe
    expect(subscription).to be_confirmed
  end

end

Any idea how to get around this problem?
Thanks

from action-cable-testing.

palkan avatar palkan commented on June 11, 2024

Hi, @mateuszdw!

Could you, please, provide the error backtrace?

from action-cable-testing.

mateuszdw avatar mateuszdw commented on June 11, 2024

Hi @palkan, sorry for delay. Here it is

     NoMethodError:
       undefined method `server' for #<ActionCable::Channel::ConnectionStub:0x00007fcd1f40ff08>
     # /Users/matt/.rvm/gems/ruby-2.4.2@chatp-rails5/gems/actioncable-5.1.0/lib/action_cable/channel/periodic_timers.rb:66:in `start_periodic_timer'
     # /Users/matt/.rvm/gems/ruby-2.4.2@chatp-rails5/gems/actioncable-5.1.0/lib/action_cable/channel/periodic_timers.rb:61:in `block in start_periodic_timers'
     # /Users/matt/.rvm/gems/ruby-2.4.2@chatp-rails5/gems/actioncable-5.1.0/lib/action_cable/channel/periodic_timers.rb:60:in `each'
     # /Users/matt/.rvm/gems/ruby-2.4.2@chatp-rails5/gems/actioncable-5.1.0/lib/action_cable/channel/periodic_timers.rb:60:in `start_periodic_timers'
     # /Users/matt/.rvm/gems/ruby-2.4.2@chatp-rails5/gems/actioncable-5.1.0/lib/action_cable/engine.rb:66:in `block (3 levels) in <class:Engine>'
     # /Users/matt/.rvm/gems/ruby-2.4.2@chatp-rails5/gems/actioncable-5.1.0/lib/action_cable/channel/base.rb:176:in `subscribe_to_channel'
     # /Users/matt/.rvm/gems/ruby-2.4.2@chatp-rails5/gems/action-cable-testing-0.1.2/lib/action_cable/channel/test_case.rb:200:in `subscribe'
     # ./spec/channels/test_channel_spec.rb:6:in `block (2 levels) in <top (required)>'

from action-cable-testing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.