Sha256: 425d27a90757a4d843f12693c76523cc849207f7673745ee4464a77586f3c5a0

Contents?: true

Size: 943 Bytes

Versions: 4

Compression:

Stored size: 943 Bytes

Contents

require 'lib/usher'

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

def build_request_mock(path, method, params)
  request = mock "Request"
  request.should_receive(:path).any_number_of_times.and_return(path)
  request.should_receive(:method).any_number_of_times.and_return(method)
  params = params.with_indifferent_access
  request.should_receive(:path_parameters=).any_number_of_times.with(params)
  request.should_receive(:path_parameters).any_number_of_times.and_return(params)
  request
end

def build_app_mock(params)
  request = mock "App"
  request.should_receive(:call).any_number_of_times.with(params)
  request
end

describe "Usher (for rack) route dispatching" do

  before(:each) do
    route_set.reset!
  end

  it "should dispatch a simple request" do
    env = {'REQUEST_URI' => '/sample', 'REQUEST_METHOD' => 'get', 'usher.params' => {}}
    route_set.add('/sample').to(build_app_mock(env.dup))
    route_set.call(env)
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
joshbuddy-usher-0.4.3 spec/private/rack/dispatch_spec.rb
joshbuddy-usher-0.4.5 spec/private/rack/dispatch_spec.rb
joshbuddy-usher-0.4.6 spec/private/rack/dispatch_spec.rb
joshbuddy-usher-0.4.7 spec/private/rack/dispatch_spec.rb