28 # spec/controllers/*.rb
29 describe MyController do
30 describe "POST update" do
31 render_views #optional
34 post :update, { user: { name: "john" } }
40 expect(response).to be_success
41 expect(response).to have_http_status(200)
42 expect(response).to render_template("index")
43 expect(response).to redirect_to '/..'
45 expect(assigns :article).to eq article
57 describe "home page" do
58 it "displays the user's username after successful login" do
60 post "/login", username: "jdoe", password: "secret"
62 expect(response.status).to eql 200
63 expect(response).to redirect_to(...)
64 expect(response).to render_template(:show)
65 expect(response.body).to include 'hello'
75 describe "routing to profiles" do
76 it "routes /profile/:username to profile#show for username" do
77 expect(get: "/profiles/jsmith").to route_to(
78 controller: "profiles",
84 it "does not expose a list of profiles" do
85 expect(get: "/profiles").not_to be_routable
94 describe EventsHelper do
95 describe "#link_to_event" do
96 it "displays the title, and formatted date" do
97 event = Event.new("Ruby Kaigi", Date.new(2010, 8, 27))
99 # helper is an instance of ActionView::Base configured with the
100 # EventsHelper and all of Rails' built-in helpers
101 expect(helper.link_to_event).to match /Ruby Kaigi, 27 Aug, 2010/
111 feature 'Signing in' do
112 given(:something) { "hi" }
115 User.make email: 'hi@gmail.com'
118 scenario 'Signing in with credentials' do
126 be_a_new(Widget) # new_record?
127 render_template("new")
128 render_template(partial: 'form', locals: {...})
129 redirect_to(widgets_path)
132 have_http_status(500)
133 have_http_status(:created)
139 travel_to Time.new(2014, 11, 14, 01, 04, 44)
143 travel_to Time.new(2014, 11, 14, 01, 04, 44) do