Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions features/matchers/redirect_to_matcher.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,30 @@ Feature: `redirect_to` matcher
require "rails_helper"

RSpec.describe WidgetsController do

describe "#create" do
subject { post :create, :params => { :widget => { :name => "Foo" } } }

it "redirects to widget_url(@widget)" do
expect(subject).to redirect_to(widget_url(assigns(:widget)))
post :create, :params => { :widget => { :name => "Foo" } }

expect(response).to redirect_to(widget_url(assigns(:widget)))
end

it "redirects_to :action => :show" do
expect(subject).to redirect_to :action => :show,
post :create, :params => { :widget => { :name => "Foo" } }

expect(response).to redirect_to :action => :show,
:id => assigns(:widget).id
end

it "redirects_to(@widget)" do
expect(subject).to redirect_to(assigns(:widget))
post :create, :params => { :widget => { :name => "Foo" } }

expect(response).to redirect_to(assigns(:widget))
end

it "redirects_to /widgets/:id" do
expect(subject).to redirect_to("/widgets/#{assigns(:widget).id}")
post :create, :params => { :widget => { :name => "Foo" } }

expect(response).to redirect_to("/widgets/#{assigns(:widget).id}")
end
end
end
Expand Down
24 changes: 14 additions & 10 deletions features/matchers/render_template_matcher.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ Feature: `render_template` matcher

RSpec.describe GadgetsController do
describe "GET #index" do
subject { get :index }

it "renders the index template" do
expect(subject).to render_template(:index)
expect(subject).to render_template("index")
expect(subject).to render_template("gadgets/index")
get :index

expect(response).to render_template(:index)
expect(response).to render_template("index")
expect(response).to render_template("gadgets/index")
end

it "does not render a different template" do
expect(subject).to_not render_template("gadgets/show")
get :index

expect(response).to_not render_template("gadgets/show")
end
end
end
Expand All @@ -40,14 +42,16 @@ Feature: `render_template` matcher

RSpec.describe GadgetsController do
describe "GET #index" do
subject { get :index }

it "renders the application layout" do
expect(subject).to render_template("layouts/application")
get :index

expect(response).to render_template("layouts/application")
end

it "does not render a different layout" do
expect(subject).to_not render_template("layouts/admin")
get :index

expect(response).to_not render_template("layouts/admin")
end
end
end
Expand Down