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
class WebratController < ApplicationController
def form
end
def buttons
end
def submit
render :text => "OK <a href='/' id='link_id'>Test Link Text</a>"
end
def internal_redirect
redirect_to submit_path
end
def infinite_redirect
redirect_to infinite_redirect_path
end
def external_redirect
redirect_to "http://google.com"
end
def before_redirect_form
end
def redirect_to_show_params
redirect_to show_params_path(:custom_param => "123")
end
def show_params
render :text => params.to_json
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.root :action => "form"
end
map.resource 'links'
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?
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
visit root_path
assert_have_xpath "//h1"