Sha256: 2ec1aaf60e8668c1f52085a184f848b10692cba4e4247c0f4ddf8413d3c6b729

Contents?: true

Size: 1.87 KB

Versions: 33

Compression:

Stored size: 1.87 KB

Contents

require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')

class RouteToMatcherTest < ActionController::TestCase # :nodoc:

  context "given a controller with a defined route" do
    setup do
      @controller = define_controller('Examples').new
      define_routes do |map|
        map.connect 'examples/:id', :controller => 'examples',
                                    :action     => 'example'
      end
    end

    should "accept routing the correct path to the correct parameters" do
      assert_accepts route(:get, '/examples/1').
                       to(:action => 'example', :id => '1'),
                     @controller
    end

    should "accept a symbol controller" do
      assert_accepts route(:get, '/examples/1').
                       to(:controller => :examples, 
                          :action     => 'example',
                          :id         => '1'),
                     self
    end

    should "accept a symbol action" do
      assert_accepts route(:get, '/examples/1').
                       to(:action => :example, :id => '1'), 
                     @controller
    end

    should "accept a non-string parameter" do
      assert_accepts route(:get, '/examples/1').
                       to(:action => 'example', :id => 1),
                     @controller
    end

    should "reject an undefined route" do
      assert_rejects route(:get, '/bad_route').to(:var => 'value'), @controller
    end

    should "reject a route for another controller" do
      @other = define_controller('Other').new
      assert_rejects route(:get, '/examples/1').
                       to(:action => 'example', :id => '1'),
                     @other
    end

    should "reject a route for different parameters" do
      assert_rejects route(:get, '/examples/1').
                       to(:action => 'other', :id => '1'),
                     @controller
    end
  end

end

Version data entries

33 entries across 33 versions & 8 rubygems

Version Path
auser-poolparty-1.3.0 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.1 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.10 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.11 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.12 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.13 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.14 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.15 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.16 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.17 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.2 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.3 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.4 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.5 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.6 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.7 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
auser-poolparty-1.3.8 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
fairchild-poolparty-1.3.17 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
fairchild-poolparty-1.3.5 vendor/gems/shoulda/test/matchers/controller/route_matcher_test.rb
iGEL-shoulda-2.10.2 test/matchers/controller/route_matcher_test.rb