Sha256: 60c135c9746ed818f16188795f3af8c7bf50422846586dd685f612cbadcc7f8d

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

require 'lib/compat'
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

5 entries across 5 versions & 1 rubygems

Version Path
joshbuddy-usher-0.0.2 spec/rack/dispatch_spec.rb
joshbuddy-usher-0.0.3 spec/rack/dispatch_spec.rb
joshbuddy-usher-0.1.0 spec/rack/dispatch_spec.rb
joshbuddy-usher-0.1.1 spec/rack/dispatch_spec.rb
joshbuddy-usher-0.1.2 spec/rack/dispatch_spec.rb