Created
June 3, 2015 12:52
-
-
Save bilus/7213a2914a8bb33cefb7 to your computer and use it in GitHub Desktop.
Capybara vs RSpec 3 within issue
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 'sinatra' | |
get '/' do | |
<<HTML | |
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title></title> | |
</head> | |
<body> | |
<h1>Title</h1> | |
<form id="main-form" action="/" method="post"> | |
<input type="text" name="email"> | |
<br> | |
<input type="text" name="name"> | |
<br> | |
<input type="submit" value="submit"> | |
</form> | |
</body> | |
</html> | |
HTML | |
end | |
post '/' do | |
'Congratulations' | |
end | |
require 'capybara' | |
require 'minitest/autorun' | |
require 'minitest/assertions' | |
require 'rspec' | |
Capybara.app = Sinatra::Application | |
class TestApp < MiniTest::Unit::TestCase | |
include Capybara::DSL | |
include RSpec::Matchers | |
def test_title_exists | |
visit '/' | |
within('#main-form') do | |
fill_in 'email', with: '[email protected]' | |
fill_in 'name', with: 'Joe Public' | |
click_button 'submit' | |
end | |
assert has_content?('Congratulations') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment