Sha256: 4799a26f652934a80ebb8b35ade38a40cc9cbd50a8bb635d55d27ddd50e82bf4

Contents?: true

Size: 1020 Bytes

Versions: 4

Compression:

Stored size: 1020 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

SampleController = Object.new

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', :controller => 'sample', :action => 'action').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.2.0 spec/rack/dispatch_spec.rb
joshbuddy-usher-0.2.1 spec/rack/dispatch_spec.rb
joshbuddy-usher-0.2.2 spec/rack/dispatch_spec.rb
joshbuddy-usher-0.3.0 spec/rack/dispatch_spec.rb