bogus icon indicating copy to clipboard operation
bogus copied to clipboard

Celluloid actors

Open LTe opened this issue 12 years ago • 4 comments

I have problem with Bogus and Celluloid. Bogus expects that Method object will be respond to name method. But Celluloid::Method does not respond for this method.

How to reproduce:

# celluloid_spec.rb
class Actor
  include Celluloid

  def test_method
    puts "hello"
  end
end

require 'rspec'
require 'bogus/rspec'

describe Actor do
  fake(:actor)

  before { stub(subject).test_method { "value" } } 

  it "returns value" do
    subject.test_method.should == "value"
  end
end

And we can execute spec for that

Failures:

  1) Actor returns value
     Failure/Error: before { stub(subject).test_method { "value" } }
     NoMethodError:
       undefined method `name' for #<Celluloid::Method Actor#test_method>
     # ./celluloid_method.rb:17:in `block (2 levels) in <top (required)>'

Finished in 0.00818 seconds
1 example, 1 failure

I created workaround for that: https://github.com/LTe/dht/blob/master/spec/support/celluloid_method.rb

Solutions:

  1. Create pull request to celluloid.
  2. Bogus should display information about problem with method object.
  3. Add information to wiki about - how to test celluloid actors.

LTe avatar Jul 12 '13 08:07 LTe

This is definitely an issue with Celluloid, because they overwrite Ruby's standard reflection, without preserving the old interface. The fix is rather trivial (Celluloid::Method just needs to respond to name and parameters).

Would you like to create the pull request to Celluloid, or should I?

psyho avatar Jul 12 '13 08:07 psyho

This is definitely an issue with Celluloid, because they overwrite Ruby's standard reflection, without preserving the old interface. The fix is rather trivial (Celluloid::Method just needs to respond to name and parameters).

But when you or library will modify Method object would be nice when Bogus will inform developer about problems. For example:

Hey developer! Bogus depends on original Method object and probably this object has been modified which can cause problems

Or something like that :)

Would you like to create the pull request to Celluloid, or should I?

Yes I will create pull request to Celluloid

LTe avatar Jul 12 '13 08:07 LTe

I created pull request for Celluloid https://github.com/celluloid/celluloid/pull/300

LTe avatar Jul 12 '13 09:07 LTe

Thanks for the workaround LTe. First day yesterday using both celluloid and bogus I got hit by this.

os6sense avatar Oct 08 '13 09:10 os6sense