diff --git a/README.markdown b/README.markdown index b0aa1f5b27..6eb8c6413a 100644 --- a/README.markdown +++ b/README.markdown @@ -167,6 +167,33 @@ This represents the rendered view. `rendered` replaces `response` from rspec-rails-1.3 +# Routing specs + +Routing specs live in spec/routing. + + describe "routing to profiles" do + it "routes /profile/:username to profile#show for username" do + { :get => "/profiles/jsmith" }.should route_to( + :controller => "profiles", + :action => "show", + :username => "jsmith" + ) + end + + it "does not expose a list of profiles" do + { :get => "/profiles" }.should_not be_routable + end + end + +## `route_to` + +Delegates to Rails' assert_routing. + +## `be_routable` + +Passes if the path is recognized by Rails' routing. This is primarily intended +to be used with `should_not` to specify routes that should not be routable. + # Helper specs Helper specs live in spec/helpers, and mix in ActionView::TestCase::Behavior. diff --git a/lib/rspec/rails/example/controller_example_group.rb b/lib/rspec/rails/example/controller_example_group.rb index d5215a6874..564c440073 100644 --- a/lib/rspec/rails/example/controller_example_group.rb +++ b/lib/rspec/rails/example/controller_example_group.rb @@ -36,6 +36,7 @@ module RSpec::Rails # describe WidgetsController do # describe "GET index" do # fixtures :widgets + # # it "assigns all widgets to @widgets" do # get :index # assigns(:widgets).should eq(Widget.all) diff --git a/lib/rspec/rails/example/request_example_group.rb b/lib/rspec/rails/example/request_example_group.rb index be22923d4d..e3babddade 100644 --- a/lib/rspec/rails/example/request_example_group.rb +++ b/lib/rspec/rails/example/request_example_group.rb @@ -2,6 +2,18 @@ require 'webrat' module RSpec::Rails + # Extends ActionDispatch::Integration::Runner to work with RSpec. + # + # == Matchers + # + # In addition to the stock matchers from rspec-expectations, request + # specs add these matchers, which delegate to rails' assertions: + # + # response.should render_template(*args) + # => delegates to assert_template(*args) + # + # response.should redirect_to(destination) + # => delegates to assert_redirected_to(destination) module RequestExampleGroup extend ActiveSupport::Concern