Sha256: f74a79016116397a7dfb973a97df395de6bda2ae3b477d053c43cfd583767ff5

Contents?: true

Size: 953 Bytes

Versions: 1

Compression:

Stored size: 953 Bytes

Contents

#!/usr/bin/ruby

require File.expand_path('../spec_helper', __FILE__)

describe 'Eventer' do
  it "Good event match" do
    class Test
      events :event
    end

    t = Test.new

    t.on_event do |args|
      "Matched"
    end

    o = t.event_rs :event

    raise "Event result isn't matched" if o != [ "Matched" ]
  end

  it "Unknown event triggered" do
    class Test
      events :event
    end

    t = Test.new

    t.on_event do |args|
      "Matched"
    end

    o = begin
      t.event_rs :unknown
    rescue Eventer::UnknownEventError
      true
    end

    raise "Event result isn't matched" if (not o) or (o != true)
  end

  it "Try to register an unknown event" do
    class Test
      events :event
    end

    t = Test.new

    o = begin
      t.on_unknown do |args|
        "Matched"
      end
      false
    rescue NoMethodError
      true
    end

    raise "Event result isn't matched" if (not o) or (o != true)
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eventer-0.0.2 spec/eventer_spec.rb