Sha256: e25fbce6e6f674cdc806c48f8a9a5c38857ca7d528c93bd2c7ba170ced97c2ee

Contents?: true

Size: 1.28 KB

Versions: 14

Compression:

Stored size: 1.28 KB

Contents

describe Orange::Middleware::Base do
  it "should call init after initializing" do
    lambda{
      mid = MockOrangeDeathMiddleware.new(nil, nil, :foo => 'bar')
    }.should raise_error(RuntimeError, "middleware_init with foo=bar")
  end
  
  it "should create a packet and call packet call" do
    mid = MockOrangeBasedMiddlewareTwo.new(nil, nil)
    mid.should_receive(:packet_call).with(an_instance_of(Orange::Packet))
    mid.call({})
  end
  
  it "should pass the packet on by default for packet_call" do
    mid = MockOrangeBasedMiddlewareTwo.new(nil, nil)
    mid.should_receive(:pass).with(an_instance_of(Orange::Packet))
    mid.packet_call(empty_packet)
  end
  
  it "should call the downstream app on pass" do
    app = mock("downstream")
    app2 = mock("downstream_orange")
    my_hash = {:foo => :bar}
    app.should_receive(:call).with(my_hash).and_return([{},200,[]])
    app2.should_receive(:packet_call).with(an_instance_of(Orange::Packet))
    mid = MockOrangeBasedMiddlewareTwo.new(app, nil)
    mid2 = MockOrangeBasedMiddlewareTwo.new(app2, nil)
    mid.call(my_hash)
    mid2.call(my_hash)
  end
  
  it "should give access to the orange core on calling orange" do
    c = Orange::Core.new
    mid = MockOrangeBasedMiddlewareTwo.new(nil, c)
    mid.orange.should equal c
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
orange-0.1.8 spec/orange-core/middleware/base_spec.rb
orange-0.1.7 spec/orange-core/middleware/base_spec.rb
orange-0.1.4 spec/orange-core/middleware/base_spec.rb
orange-0.1.2 spec/orange-core/middleware/base_spec.rb
orange-0.1.0 spec/orange-core/middleware/base_spec.rb
orange-0.0.15 spec/orange-core/middleware/base_spec.rb
orange-0.0.14 spec/orange-core/middleware/base_spec.rb
orange-0.0.13 spec/orange/middleware/base_spec.rb
orange-0.0.12 spec/orange/middleware/base_spec.rb
orange-0.0.10 spec/orange/middleware/base_spec.rb
orange-0.0.8 spec/orange/middleware/base_spec.rb
orange-0.0.7 spec/orange/middleware/base_spec.rb
orange-0.0.6 spec/orange/middleware/base_spec.rb
orange-0.0.5 spec/orange/middleware/base_spec.rb