-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
redirect_to_matcher.feature
41 lines (32 loc) · 1.37 KB
/
redirect_to_matcher.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Feature: redirect_to matcher
The redirect_to matcher is used to specify that the redirect called
in the latest action ended with the intended behaviour. Essentially,
it delegates to "assert_redirect". For more info, please check out
the Rails documentation on this method.
It is available in controller specs (spec/controllers) and request
specs (spec/requests).
Scenario: redirect_to with four possible options
Given a file named "spec/controllers/widgets_controller_spec.rb" with:
"""
require "spec_helper"
describe WidgetsController do
describe "#create" do
subject { post :create, :widget => { :name => "Foo" } }
it "redirects to widget_url(@widget)" do
subject.should redirect_to(widget_url(assigns(:widget)))
end
it "redirects_to :action => :show" do
subject.should redirect_to :action => :show,
:id => assigns(:widget).id
end
it "redirects_to(@widget)" do
subject.should redirect_to(assigns(:widget))
end
it "redirects_to /widgets/:id" do
subject.should redirect_to("/widgets/#{assigns(:widget).id}")
end
end
end
"""
When I run "rspec spec/controllers/widgets_controller_spec.rb"
Then the output should contain "4 examples, 0 failures"