Skip to content

Instantly share code, notes, and snippets.

@xander-miller
Last active August 29, 2015 14:05
Show Gist options
  • Save xander-miller/ce438e94323347276925 to your computer and use it in GitHub Desktop.
Save xander-miller/ce438e94323347276925 to your computer and use it in GitHub Desktop.
Keeping your RSpec Welcome Controller Spec DRY
require "spec_helper"
RSpec.describe WelcomeController, :type => :controller do
describe "GET home" do
it "returns http success" do
get :home
expect(response).to be_success
end
it "renders the home template" do
get :home
expect(response).to render_template("home")
end
end
describe "GET about" do
it "returns http success" do
get :about
expect(response).to be_success
end
it "renders the about template" do
get :about
expect(response).to render_template("about")
end
end
describe "GET contact" do
it "returns http success" do
get :contact
expect(response).to be_success
end
it "renders the contact template" do
get :contact
expect(response).to render_template("contact")
end
end
end
require "spec_helper"
RSpec.describe WelcomeController, :type => :controller do
welcomes = %w{portfolio about contact}
welcomes.each do |welcome|
describe "GET #{welcome}" do
it "returns http success" do
get welcome.to_sym
expect(response).to be_success
end
it "renders the #{welcome} template" do
get welcome.to_sym
expect(response).to render_template(welcome)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment