Sha256: 1105a15a5f37d7177ff2ba43374e109e4a71d1d0a9277ed8c4d8d936063ebb36

Contents?: true

Size: 1.86 KB

Versions: 10

Compression:

Stored size: 1.86 KB

Contents

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

class RouteToMatcherTest < Test::Unit::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

10 entries across 10 versions & 5 rubygems

Version Path
Flamefork-shoulda-2.10.1 test/matchers/controller/route_matcher_test.rb
Flamefork-shoulda-2.10.2 test/matchers/controller/route_matcher_test.rb
francois-shoulda-2.10.1 test/matchers/controller/route_matcher_test.rb
technicalpickles-shoulda-2.10.0 test/matchers/controller/route_matcher_test.rb
thoughtbot-shoulda-2.10.0 test/matchers/controller/route_matcher_test.rb
thoughtbot-shoulda-2.10.1 test/matchers/controller/route_matcher_test.rb
thoughtbot-shoulda-2.9.2 test/matchers/controller/route_matcher_test.rb
shoulda-2.9.2 test/matchers/controller/route_matcher_test.rb
shoulda-2.10.0 test/matchers/controller/route_matcher_test.rb
shoulda-2.10.1 test/matchers/controller/route_matcher_test.rb