Sha256: e7342a94b4d7503dd6b192f8df9eea93a02ff749bf5a4b6b45d851ea8fb46f69

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))

module Stomper::Frames
  describe Headers do
    before(:each) do
      @headers = Headers.new
    end

    it "should set a header by a string key, accessible by all" do
      @test_value = "a test"
      @headers['testing'] = @test_value
      @headers['testing'].should == @test_value
      @headers[:testing].should == @test_value
      @headers.testing.should == @test_value
      @headers.send(:testing).should == @test_value
    end

    it "should set a header by a symbol key, accessible by all" do
      @test_value = "another test"
      @headers[:some_key] = @test_value
      @headers['some_key'].should == @test_value
      @headers[:some_key].should == @test_value
      @headers.some_key.should == @test_value
      @headers.send(:some_key).should == @test_value
    end

    it "should set a header by a method, accessible by all" do
      @test_value = "yet more testing"
      @headers.another_key = @test_value
      @headers['another_key'].should == @test_value
      @headers[:another_key].should == @test_value
      @headers.another_key.should == @test_value
      @headers.send(:another_key).should == @test_value
    end

    it "should override the default id getter and provide a setter" do
      @test_value = "my id"
      @headers.id = @test_value
      @headers.id.should == @test_value
      @headers['id'].should == @test_value
      @headers[:id].should == @test_value
      @headers.send(:id).should == @test_value
    end

    it "should provide method to convert to stomp compatible headers" do
      @headers.to_stomp.should be_empty
      @headers.ack = 'auto'
      @headers.destination = '/queue/test/1'
      @headers.to_stomp.should == "ack:auto\ndestination:/queue/test/1\n"
    end


  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
stomper-0.4 spec/frames/headers_spec.rb
stomper-0.3.2 spec/frames/headers_spec.rb
stomper-0.3.1 spec/frames/headers_spec.rb
stomper-0.3.0 spec/frames/headers_spec.rb