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

Version Path
challah-1.0.0.beta vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/action_controller/route_matcher_spec.rb
challah-0.9.1.beta.3 vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/action_controller/route_matcher_spec.rb
devise_sociable-0.1.0 vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/action_controller/route_matcher_spec.rb
challah-0.9.1.beta vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/action_controller/route_matcher_spec.rb
challah-0.9.0 vendor/bundle/gems/shoulda-matchers-1.4.2/spec/shoulda/action_controller/route_matcher_spec.rb
shoulda-matchers-1.4.2 spec/shoulda/action_controller/route_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/shoulda-matchers-1.4.1/spec/shoulda/action_controller/route_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/action_controller/route_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/action_controller/route_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/shoulda-matchers-1.4.1/spec/shoulda/action_controller/route_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/action_controller/route_matcher_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/action_controller/route_matcher_spec.rb
challah-0.8.3 vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/action_controller/route_matcher_spec.rb
challah-0.8.3 vendor/bundle/gems/shoulda-matchers-1.4.1/spec/shoulda/action_controller/route_matcher_spec.rb
shoulda-matchers-1.4.1 spec/shoulda/action_controller/route_matcher_spec.rb
shoulda-matchers-1.4.0 spec/shoulda/action_controller/route_matcher_spec.rb
challah-0.8.1 vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/action_controller/route_matcher_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/action_controller/route_matcher_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/shoulda-matchers-1.2.0/spec/shoulda/action_controller/route_matcher_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/shoulda-matchers-1.3.0/spec/shoulda/action_controller/route_matcher_spec.rb