Sha256: 93e2a2d038dd2917083f8f16cbb56a51c72fab02b1740f15d362e745cb6050cc
Contents?: true
Size: 2 KB
Versions: 2
Compression:
Stored size: 2 KB
Contents
require 'spec_helper' module ApiTaster describe Mapper do context "non-existing routes" do before(:all) do routes = ActionDispatch::Routing::RouteSet.new routes.draw do get '/awesome_route' => 'awesome#route' end ApiTaster.routes do get '/dummy_route' end Route.route_set = routes Route.map_routes end it "records obsolete definitions" do Route.obsolete_definitions.first[:path].should == '/dummy_route' end end before(:all) do Rails.application.routes.draw { resources :dummy_users } end context "#global_params" do before(:all) do ApiTaster.global_params = { :foo => 'bar' } ApiTaster.routes do get '/dummy_users/:id', :id => 1 end Route.map_routes end it "merges params" do route = Route.find_by_verb_and_path(:get, '/dummy_users/:id') Route.supplied_params[route[:id]].should == [{ :foo => 'bar', :id => 1 }] end end before(:all) do ApiTaster.routes do get '/dummy_users/:id', :id => 1 post '/dummy_users' post '/dummy_users', { :hello => 'world' } put '/dummy_users/:id', :id => 2 delete '/dummy_users/:id', :id => 3 end Route.map_routes end it "gets users" do route = Route.find_by_verb_and_path(:get, '/dummy_users/:id') Route.supplied_params[route[:id]].should == [{ :id => 1 }] end it "posts a new user" do route = Route.find_by_verb_and_path(:post, '/dummy_users') Route.supplied_params[route[:id]].should == [{}, { :hello => 'world' }] end it "edits a user" do route = Route.find_by_verb_and_path(:put, '/dummy_users/:id') Route.supplied_params[route[:id]].should == [{ :id => 2 }] end it "deletes a user" do route = Route.find_by_verb_and_path(:delete, '/dummy_users/:id') Route.supplied_params[route[:id]].should == [{ :id => 3 }] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
api_taster-0.4.8 | spec/mapper_spec.rb |
api_taster-0.4.7 | spec/mapper_spec.rb |