Sha256: ec81948b041f2fb32872d24fa8d115a897e7a488f9e17664955595914ea9f464

Contents?: true

Size: 644 Bytes

Versions: 9

Compression:

Stored size: 644 Bytes

Contents

require 'helper'

class EventTester
  include Evented
end

describe Safubot::Evented do
  evy = EventTester.new

  it "should bind and execute a non-repeating event handler" do
	output = "planarians"

	evy.once(:wormy) do
	  output = "flatworms"
	end

	evy.emit(:wormy)

	output.should == "flatworms"

	output = "platyhelminthes"

	evy.emit(:wormy)

	output.should == "platyhelminthes"
  end

  it "should bind and execute a repeating event handler" do
	output = "waffles"

	evy.on(:nom) do
	  output = "toasties"
	end

	evy.emit(:nom)

	output.should == "toasties"

	output = "cookies"

	evy.emit(:nom)

	output.should == "toasties"
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
safubot-0.0.9 spec/safubot/evented_spec.rb
safubot-0.0.8 spec/safubot/evented_spec.rb
safubot-0.0.7 spec/safubot/evented_spec.rb
safubot-0.0.6 spec/safubot/evented_spec.rb
safubot-0.0.5 spec/safubot/evented_spec.rb
safubot-0.0.4 spec/safubot/evented_spec.rb
safubot-0.0.3 spec/safubot/evented_spec.rb
safubot-0.0.2 spec/safubot/evented_spec.rb
safubot-0.0.1 spec/safubot/evented_spec.rb