Sha256: 2ea6da8a47e3791ad74516c0d66b33c1546a4db31fe438bc06d9ad794357b10a

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

class MyMessage < Arachni::RPC::Message
    attr_accessor :foo
    attr_accessor :boo

    def transmit?( attr )
        attr == :@boo
    end
end

describe Arachni::RPC::Message do
    let(:options) { { foo: 'foo val', boo: 'boo val' }}
    subject { MyMessage.new( options ) }

    describe '#initialize' do
        it 'sets attributes' do
            subject.foo == options[:foo]
            subject.boo == options[:boo]
        end
    end

    describe '#merge!' do
        it 'assigns the attribute values of the provided object to self' do
            opts = { foo: 'my foo' }
            my_msg = MyMessage.new( opts )

            subject.merge!( my_msg )

            subject.foo == opts[:foo]
            subject.boo == options[:boo]
        end
    end

    describe '#prepare_for_tx' do
        it 'converts self into a hash' do
            subject.prepare_for_tx.class.should == Hash
        end

        it 'skips attributes based on #transmit?' do
            subject.prepare_for_tx.should include 'boo'
            subject.prepare_for_tx.should_not include 'callback_id'
            subject.prepare_for_tx.should_not include 'foo'
        end
    end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
arachni-rpc-0.2.1.4 spec/arachni/rpc/message_spec.rb
arachni-rpc-0.2.1.3 spec/arachni/rpc/message_spec.rb
arachni-rpc-0.2.1.2 spec/arachni/rpc/message_spec.rb
arachni-rpc-0.2.1.1 spec/arachni/rpc/message_spec.rb
arachni-rpc-0.2.1 spec/arachni/rpc/message_spec.rb
arachni-rpc-0.2.0 spec/arachni/rpc/message_spec.rb