Sha256: 9094e5f1a35e28bb4954fe4609973c558e4b879dc16eb962ae70f0b5762b0851

Contents?: true

Size: 1.59 KB

Versions: 5

Compression:

Stored size: 1.59 KB

Contents

require "spec_helper"

describe "route_to" do
  include RSpec::Rails::Matchers::RoutingMatchers

  it "uses failure message from assert_routing" do
    self.stub!(:assert_routing).and_raise(
      Test::Unit::AssertionFailedError.new("this message"))
    expect do
      {"this" => "path"}.should route_to("these" => "options")
    end.to raise_error("this message")
  end
end

describe "be_routable" do
  include RSpec::Rails::Matchers::RoutingMatchers
  attr_reader :routes

  before { @routes = double("routes") }

  context "with should" do
    it "passes if routes recognize the path" do
      routes.stub(:recognize_path) { {} }
      expect do
        {:get => "/a/path"}.should be_routable
      end.to_not raise_error
    end

    it "fails if routes do not recognize the path" do
      routes.stub(:recognize_path) { raise ActionController::RoutingError.new('ignore') }
      expect do
        {:get => "/a/path"}.should be_routable
      end.to raise_error(/expected \{:get=>"\/a\/path"\} to be routable/)
    end
  end

  context "with should_not" do

    it "passes if routes do not recognize the path" do
      routes.stub(:recognize_path) { raise ActionController::RoutingError.new('ignore') }
      expect do
        {:get => "/a/path"}.should_not be_routable
      end.to_not raise_error
    end

    it "fails if routes recognize the path" do
      routes.stub(:recognize_path) { {:controller => "foo"} }
      expect do
        {:get => "/a/path"}.should_not be_routable
      end.to raise_error(/expected \{:get=>"\/a\/path"\} not to be routable, but it routes to \{:controller=>"foo"\}/)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rspec-rails-2.0.0.rc spec/rspec/rails/matchers/route_to_spec.rb
rspec-rails-2.0.0.beta.22 spec/rspec/rails/matchers/route_to_spec.rb
rspec-rails-2.0.0.beta.20 spec/rspec/rails/matchers/route_to_spec.rb
rspec-rails-2.0.0.beta.19 spec/rspec/rails/matchers/route_to_spec.rb
rspec-rails-2.0.0.beta.18 spec/rspec/rails/matchers/route_to_spec.rb