Sha256: 5488781b0471655ada3ca17d7e098ef63d09f6dc5fda65ee7fad11c8207cb60f

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

describe Flirt::Callback do
    before(:each) do
        Flirt.enable
    end

    describe "when instantiated with an object and callback name" do

        let(:listener) { Object.new }

        let(:callback_name) { :call_me }

        let(:callback) { Flirt::Callback.new object: listener, callback_name: callback_name }


        it "sets the object" do
            expect(callback.object).to eq(listener)
        end


        it "sets the callback" do
            expect(callback.callback_name).to eq(callback_name)
        end


        describe "when called" do

            let(:event_data) { {event: :data} }


            it "calls the callback with the event data" do
                expect(listener).to receive(callback_name).with(event_data)
                callback.call(event_data)
            end

        end


        it "tests equality if object and callback are the same" do
            other_callback = Flirt::Callback.new object: listener, callback_name: callback_name
            expect(callback).to eq(other_callback)
        end

    end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flirt-0.2.0 spec/flirt/flirt_callback_spec.rb
flirt-0.1.1 spec/flirt/flirt_callback_spec.rb
flirt-0.1.0 spec/flirt/flirt_callback_spec.rb
flirt-0.0.4 spec/flirt/flirt_callback_spec.rb
flirt-0.0.3 spec/flirt/flirt_callback_spec.rb