On Sep 9, 2009, at 4:37 PM, Chuck Remes wrote:

I am trying to spec out a method that is using the 'beam' gem to fire an event. When the method fires the event, it should pass the current +self+ as an argument.

e.g.

def foo
 Beam.fire :my_event, self
end

it "should fire :my_event and pass self" do
 Beam.should_receive(:fire).with(:my_event, ????)
 foo
end

How can I set a mock expectation to work resolve self correctly? I suspect it isn't possible but I'd like confirmation before I waste too much time on this.

Ugh, never mind. :-\

I should have thought a little harder before posting... sorry for the noise.

cr


class Bar
  def foo
    Beacon.fire :my_event, self
  end
end

it "should fire :my_evnet and pass self" do
  @klass = Bar.new
  Beacon.should_receive(:fire).with(:my_event, @klass)

  @klass.foo
end

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to