Sha256: bbdfde6890f3709b2a72aff6987d50728c770db39f975cb22735a6b90d08a889
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
require 'spec_helper' module ApiTaster describe Route do let(:app_home_route) do { :id => 0, :name => 'home', :verb => 'GET', :path => '/home', :reqs => { :controller => 'application', :action => 'home' } } end before(:all) do routes = ActionDispatch::Routing::RouteSet.new routes.draw do get 'home' => 'application#home', :as => :home resources :users do resources :comments end end Route.route_set = routes end it "#routes" do Route.routes.first.should == app_home_route end it "#grouped_routes" do Route.grouped_routes.has_key?('application').should == true Route.grouped_routes.has_key?('users').should == true Route.grouped_routes.has_key?('comments').should == true Route.grouped_routes['application'][0].should == app_home_route end it "#find" do Route.find(0).should == app_home_route Route.find(999).should == nil end it "#find_by_verb_and_path" do Route.find_by_verb_and_path(:get, '/home').should == app_home_route Route.find_by_verb_and_path(:get, '/dummy').should == nil Route.find_by_verb_and_path(:delete, '/home').should == nil end it "#inputs_for" do Route.stub(:routes).and_return([{ :id => 0, :path => '/dummy/:dummy_id' }, { :id => 1 }]) Route.inputs[0] = [{ :dummy_id => 1, :hello => 'world' }] Route.inputs_for(Route.find(1)).should have_key(:undefined) 2.times do Route.inputs_for(Route.find(0)).should == [{ :url_params => { :dummy_id => 1 }, :post_params => { :hello => 'world' } }] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
api_taster-0.1.0 | spec/route_spec.rb |