thoughtbot--shoulda-matchers/spec/shoulda/action_controller/redirect_to_matcher_spec.rb

38 lines
1002 B
Ruby
Raw Normal View History

require 'spec_helper'
2010-12-14 23:51:39 +00:00
describe Shoulda::ActionController::RedirectToMatcher do
context "a controller that redirects" do
before do
@controller = build_response { redirect_to '/some/url' }
end
it "should accept redirecting to that url" do
@controller.should redirect_to('/some/url')
end
it "should reject redirecting to a different url" do
@controller.should_not redirect_to('/some/other/url')
end
it "should accept redirecting to that url in a block" do
@controller.should redirect_to('somewhere') { '/some/url' }
end
it "should reject redirecting to a different url in a block" do
@controller.should_not redirect_to('somewhere else') { '/some/other/url' }
end
end
context "a controller that doesn't redirect" do
before do
@controller = build_response { render :text => 'hello' }
end
it "should reject redirecting to a url" do
@controller.should_not redirect_to('/some/url')
end
end
end