rspec does have a redirect matcher that works with hashes and strings.
The only syntax addition here is the ability to take a symbol as an
action name shortcut:
should redirect_to({:action => 'index'})
vs
should respond_with(:redirect).to(:index)
it makes the two examples equally brief.
As it stands now with rspec + shoulda
should redirect_to('
http://www.google.com')
should respond_with(:redirect)
_is_ a verbose (and redundant) test. Testing a redirect to a specific
location implies that the response is a redirect. You have just as
valid coverage by omitting the second spec:
should redirect_to('
http://www.google.com')
But, you lose out on the consistency of having all your response specs
use the same syntax and the sentence-like wording that differentiates
general redirect responses from specific redirects.
Shoulda seems to follow the pattern of using chained method calls to
describe specificity in expectations:
it { should assign_to(:user) }
it { should assign_to(:user).with(@user) }
it { should set_session(:user_id) }
it { should set_session(:user_id).to(@
user.id) }
For brevity's sake you could do away with `
set_the_flash.to`:
should set_the_flash(/created/)
should set_the_flash # no argument defaults value to rspec anything()
but I don't think that reads as nicely.