Sha256: 25c96a71388da4da43619b3f8320fc645262cd22c0bd178b837ea235f3b4ab96

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

describe BunnyMock::Session do

	context '::new' do

		it 'should start as not connected' do

			expect(@session.status).to eq(:not_connected)
		end
	end

	context '#start' do

		it 'should set status to connected' do

			expect(@session.start.status).to eq(:connected)
		end
	end

	context '#stop (close)' do

		it 'should set status to closed' do

			@session.start

			expect(@session.stop.status).to eq(:closed)
		end
	end

	context '#open?' do

		it 'should return true if status is open' do

			@session.start

			expect(@session.open?).to be_truthy
		end

		it 'should return false otherwise' do

			# not_connected
			expect(@session.open?).to be_falsey

			@session.stop

			# closed
			expect(@session.open?).to be_falsey
		end
	end

	context '#create_channel (channel)' do

		it 'should create a new channel with no arguments' do

			first = @session.create_channel
			second = @session.create_channel

			expect(first.class).to eq(BunnyMock::Channel)
			expect(second.class).to eq(BunnyMock::Channel)

			expect(first).to_not eq(second)
		end

		it 'should return cached channel with same identifier' do

			first = @session.create_channel 1
			second = @session.create_channel 1

			expect(first.class).to eq(BunnyMock::Channel)
			expect(second.class).to eq(BunnyMock::Channel)

			expect(first).to eq(second)
		end

		it 'should return an ArgumentError for reserved channel' do

			expect { @session.create_channel(0) }.to raise_error(ArgumentError)
		end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bunny-mock-1.1.0 spec/unit/bunny_mock/session_spec.rb
bunny-mock-1.0.0 spec/unit/bunny_mock/session_spec.rb