added test for clicking link by title

This commit is contained in:
mike.gaffney 2009-06-01 12:17:29 -05:00
parent b6d26480ea
commit 5430930bac
8 changed files with 53 additions and 22 deletions

View File

@ -0,0 +1,7 @@
class LinksController < ApplicationController
def show
if params[:value]
render :text => "Link:#{params[:value]}"
end
end
end

View File

@ -5,38 +5,38 @@ class FakeModel
end end
class WebratController < ApplicationController class WebratController < ApplicationController
def form def form
end end
def buttons def buttons
end end
def submit def submit
render :text => "OK <a href='/' id='link_id'>Test Link Text</a>" render :text => "OK <a href='/' id='link_id'>Test Link Text</a>"
end end
def internal_redirect def internal_redirect
redirect_to submit_path redirect_to submit_path
end end
def infinite_redirect def infinite_redirect
redirect_to infinite_redirect_path redirect_to infinite_redirect_path
end end
def external_redirect def external_redirect
redirect_to "http://google.com" redirect_to "http://google.com"
end end
def before_redirect_form def before_redirect_form
end end
def redirect_to_show_params def redirect_to_show_params
redirect_to show_params_path(:custom_param => "123") redirect_to show_params_path(:custom_param => "123")
end end
def show_params def show_params
render :text => params.to_json render :text => params.to_json
end end
end end

View File

@ -0,0 +1,2 @@
module LinksHelper
end

View File

@ -0,0 +1,4 @@
<h1>Webrat Links Page</h1>
<a href="/links?value=LinkByText">LinkByText</a><br />
<a href="/links?value=link_by_id" id="link_by_id">id</a><br />
<a href="/links?value=LinkByTitle" title="LinkByTitle">title</a>

View File

@ -12,4 +12,5 @@ ActionController::Routing::Routes.draw do |map|
webrat.buttons "/buttons", :action => "buttons" webrat.buttons "/buttons", :action => "buttons"
webrat.root :action => "form" webrat.root :action => "form"
end end
map.resource 'links'
end end

View File

@ -0,0 +1,8 @@
require 'test_helper'
class LinksControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -0,0 +1,21 @@
require 'test_helper'
class LinkClickTest < ActionController::IntegrationTest
test "should click link by text" do
visit links_path
click_link "LinkByText"
assert_contain("Link:LinkByText")
end
test "should click link by id" do
visit links_path
click_link "link_by_id"
assert_contain("Link:link_by_id")
end
test "should click link by title" do
visit links_path
click_link "LinkByTitle"
assert_contain("Link:LinkByTitle")
end
end

View File

@ -49,18 +49,6 @@ class WebratTest < ActionController::IntegrationTest
assert response.redirect? assert response.redirect?
end end
test "should click link by text" do
visit internal_redirect_path
click_link "Test Link Text"
assert_contain("Webrat Form")
end
test "should click link by id" do
visit internal_redirect_path
click_link "link_id"
assert_contain("Webrat Form")
end
test "should be able to assert xpath" do test "should be able to assert xpath" do
visit root_path visit root_path
assert_have_xpath "//h1" assert_have_xpath "//h1"