-
Notifications
You must be signed in to change notification settings - Fork 0
Step04: First Static Page Test
Lev Brie edited this page Jul 27, 2013
·
1 revision
-
Checkout a new branch and then generate an integration_test spec:
$ git checkout -b step04-add-test-to-static-home $ rails generate integration_test static_pages
-
Test for Home Page Content that includes Rangular (or whatever your title is) in
spec/requests/static_pages_spec.rb
:require 'spec_helper' describe "StaticPages" do describe "Home page" do # we're describing the home page it "should have the content 'Rangular'" do # descriptive should visit '/static_pages/home' # actually visit this route (Capybara function visit) expect(page).to have_content('Rangular') # check for content and expect it using page variable # provided by Capybara # if the content's not there, fail end end end
-
Add
config.include Capybara::DSL
tospec/spec_helper.rb
to require the Capybara DSL in RSpec. -
Run the test with
$ bundle exec rspec spec/requests/static_pages_spec.rb
(it should fail) -
Replace the home page content in
app/views/static_pages/home.html.haml
with%h1 Rangular Home
and whatever else you want. Everything should now be passing. -
Commit your changes `git commit -am "First spec for static home page now passing" Now checkout the master, merge your changes, and push up to github:
$ git checkout master $ git merge step04-add-test-to-static-home $ git push