1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Some tests for javascript drivers

This commit is contained in:
Jonas Nicklas 2009-11-05 17:35:45 +01:00
parent cbe0153950
commit 7b02830985
8 changed files with 58 additions and 3 deletions

View file

@ -1,6 +1,5 @@
require 'culerity'
require 'rack'
require 'net/http'
class Webcat::Driver::Culerity
class Node < Struct.new(:node)

View file

@ -1,3 +1,5 @@
require 'net/http'
class Webcat::Server
attr_reader :app

View file

@ -7,4 +7,5 @@ describe Webcat::Driver::Culerity do
end
it_should_behave_like "driver"
it_should_behave_like "driver with javascript support"
end

View file

@ -55,3 +55,12 @@ shared_examples_for 'driver' do
end
end
shared_examples_for "driver with javascript support" do
describe '#find' do
it "should find dynamically changed nodes" do
@driver.visit('/with_js')
@driver.find('//p').first.text.should == 'I changed it'
end
end
end

19
spec/public/jquery.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -7,4 +7,4 @@ require 'sinatra/base'
require 'rack'
require 'test_app'
alias :running :lambda
alias :running :lambda

View file

@ -1,5 +1,6 @@
class TestApp < Sinatra::Base
set :views, File.dirname(__FILE__) + '/views'
set :root, File.dirname(__FILE__)
set :static, true
get '/' do
'Hello world!'
@ -13,6 +14,10 @@ class TestApp < Sinatra::Base
erb :with_html
end
get '/with_js' do
erb :with_js
end
get '/with_simple_html' do
erb :with_simple_html
end

20
spec/views/with_js.erb Normal file
View file

@ -0,0 +1,20 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<title>with_js</title>
<script src="/jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
//<![CDATA[
$(function() {
$('#change').text('I changed it');
});
//]]>
</script>
</head>
<body id="with_js">
<h1>FooBar</h1>
<p id="change">This is text</p>
</body>
</html>