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

@ -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"