Created
November 9, 2012 16:05
-
-
Save jgwhite/4046511 to your computer and use it in GitHub Desktop.
Testing Static HTML with RSpec & Capybara
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
<!doctype html> | |
<html> | |
<head> | |
<title>Example</title> | |
</head> | |
<body> | |
<h1>Hello World!</h1> | |
</body> | |
</html> |
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 'bundler/setup' | |
require 'rack/file' | |
require 'capybara/rspec' | |
Capybara.app = Rack::File.new File.dirname __FILE__ | |
describe "Example page", :type => :request do | |
it "contains an H1 with text 'Hello World!'" do | |
visit '/example.html' | |
page.should have_css 'h1', :text => 'Hello World!' | |
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
source :rubygems | |
gem 'capybara' | |
gem 'rack' | |
gem 'rspec' |
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
bundle exec rspec example_spec.rb --color --format=documentation |
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
gem install bundler | |
bundle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, I need to add to my spec_helper: config.include Capybara::DSL for it work.