Skip to content

Instantly share code, notes, and snippets.

@robjshaw
Last active December 14, 2015 02:59
Show Gist options
  • Select an option

  • Save robjshaw/5017640 to your computer and use it in GitHub Desktop.

Select an option

Save robjshaw/5017640 to your computer and use it in GitHub Desktop.
#gem file config
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.11.0'
gem 'guard-rspec', '1.2.1'
end
group :test do
gem 'capybara', '1.1.2'
gem 'rb-fsevent', '0.9.1', :require => false
gem 'growl', '1.0.3'
end
#init guard
bundle exec guard init rspec
# create a test for the controller
rails generate integration_test static_pages
# spec/requests/static_pages_spec.rb - sample test
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
page.should have_content('Sample App')
end
end
# more complex test
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
page.should have_content('Sample App')
end
it "should have the title 'Home'" do
visit '/static_pages/home'
page.should have_selector('title',
:text => "Ruby on Rails Tutorial Sample App | Home")
end
end
# process tests
bundle exec rspec spec/requests/static_pages_spec.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment