Sha256: cf52a077d1349d2726490f296983a532c6ff1362228657d88a43a9275972ea89
Contents?: true
Size: 1.87 KB
Versions: 28
Compression:
Stored size: 1.87 KB
Contents
require 'spec_helper' describe Shoulda::Matchers::ActionController::RouteMatcher do context "given a controller with a defined glob url" do let(:controller) { define_controller('Examples').new } before do define_routes do match 'examples/*id', :to => 'examples#example' end end it "should accept glob route" do controller.should route(:get, '/examples/foo/bar'). to(:action => 'example', :id => 'foo/bar') end end context "given a controller with a defined route" do let!(:controller) { define_controller('Examples').new } before do define_routes do match 'examples/:id', :to => 'examples#example' end end it "should accept routing the correct path to the correct parameters" do controller.should route(:get, '/examples/1'). to(:action => 'example', :id => '1') end it "should accept a symbol controller" do Object.new.should route(:get, '/examples/1'). to(:controller => :examples, :action => 'example', :id => '1') end it "should accept a symbol action" do controller.should route(:get, '/examples/1'). to(:action => :example, :id => '1') end it "should accept a non-string parameter" do controller.should route(:get, '/examples/1'). to(:action => 'example', :id => 1) end it "should reject an undefined route" do controller.should_not route(:get, '/bad_route').to(:var => 'value') end it "should reject a route for another controller" do other = define_controller('Other').new other.should_not route(:get, '/examples/1'). to(:action => 'example', :id => '1') end it "should reject a route for different parameters" do controller.should_not route(:get, '/examples/1'). to(:action => 'other', :id => '1') end end end
Version data entries
28 entries across 20 versions & 4 rubygems