Last active
August 29, 2015 14:05
-
-
Save xander-miller/ce438e94323347276925 to your computer and use it in GitHub Desktop.
Keeping your RSpec Welcome Controller Spec DRY
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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