Sha256: 0f66b72cf6f853b96e1db13b0e26c8bfd74d883daff8b8c0a396783effefd73c

Contents?: true

Size: 828 Bytes

Versions: 5

Compression:

Stored size: 828 Bytes

Contents

require 'lib/usher'

require 'rack'

route_set = Usher::Interface.for(:rack)

describe "Usher (for rack) route dispatching" do

  before(:each) do
    route_set.reset!
  end

  it "should dispatch a simple request" do
    app = mock 'app'
    app.should_receive(:call).once.with {|v| v['usher.params'].should == {} }
    route_set.add('/sample').to(app)
    route_set.call(Rack::MockRequest.env_for("/sample", :method => 'GET'))
  end
  
  it "should dispatch a POST request" do
    bad_app = mock 'bad_app'
    app = mock 'app'
    app.should_receive(:call).once.with {|v| v['usher.params'].should == {} }
    route_set.add('/sample').to(bad_app)
    route_set.add('/sample', :requirements => {:request_method => 'POST'}).to(app)
    route_set.call(Rack::MockRequest.env_for("/sample", :request_method => 'POST'))
  end
  
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
joshbuddy-usher-0.4.10 spec/private/rack/dispatch_spec.rb
joshbuddy-usher-0.4.11 spec/private/rack/dispatch_spec.rb
joshbuddy-usher-0.4.8 spec/private/rack/dispatch_spec.rb
joshbuddy-usher-0.5.1 spec/private/rack/dispatch_spec.rb
usher-0.4.8 spec/private/rack/dispatch_spec.rb