Sha256: 12a1c83f6ecaa419070161b7601c4fe553391f021565a9a81dd0f24ac4589416

Contents?: true

Size: 836 Bytes

Versions: 7

Compression:

Stored size: 836 Bytes

Contents

module RSpec::Rails::Matchers
  module RoutingMatchers
    extend RSpec::Matchers::DSL

    matcher :route_to do |route_options|
      match_unless_raises Test::Unit::AssertionFailedError do |path|
        assertion_path = { :method => path.keys.first, :path => path.values.first }
        assert_recognizes(route_options, assertion_path)
      end

      failure_message_for_should do
        rescued_exception.message
      end
    end

    matcher :be_routable do
      match_unless_raises ActionController::RoutingError do |path|
        @routing_options = routes.recognize_path(
          path.values.first, :method => path.keys.first
        )
      end

      failure_message_for_should_not do |path|
        "expected #{path.inspect} not to be routable, but it routes to #{@routing_options.inspect}"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rspec-rails-2.3.1 lib/rspec/rails/matchers/routing_matchers.rb
rspec-rails-2.3.0 lib/rspec/rails/matchers/routing_matchers.rb
rspec-rails-2.2.1 lib/rspec/rails/matchers/routing_matchers.rb
rspec-rails-2.2.0 lib/rspec/rails/matchers/routing_matchers.rb
rspec-rails-2.1.0 lib/rspec/rails/matchers/routing_matchers.rb
rspec-rails-2.0.1 lib/rspec/rails/matchers/routing_matchers.rb
rspec-rails-2.0.0 lib/rspec/rails/matchers/routing_matchers.rb