capybara-facebook 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Mathieu Fosse
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # capybara-facebook
2
+
3
+ capybara-facebook is a Facebook Driver for Capybara. It aims to easily test a Facebook application in your integration tests.
4
+
5
+
6
+ ## Installation
7
+
8
+
9
+ $ [sudo] gem install capybara-facebook
10
+
11
+
12
+ ## How to use it with Cucumber ?
13
+
14
+ Add these lines on your `features/support/env.rb` file :
15
+
16
+ require 'capybara-facebook'
17
+ require 'capybara-facebook/cucumber'
18
+
19
+ Important, if you use Cucumber with Rails you must require `capybara/rails` after the lines above.
20
+
21
+ For more information see [http://github.com/jnicklas/capybara](http://github.com/jnicklas/capybara)
22
+
23
+ Capybara Facebook added the method `facecebook_parameters!` to manage the facebook parameters sent with request.
24
+
25
+ For instance you can add a Cucumber step like this one :
26
+
27
+ Given /^I am logged in with Facebook uid "(\d+)"$/ do |facebook_uid|
28
+ facebook_parameters!({ "fb_sig_user" => facebook_uid })
29
+ end
30
+
31
+
32
+ ## Note on Patches/Pull Requests
33
+
34
+ * Fork the project.
35
+ * Make your feature addition or bug fix.
36
+ * Add tests for it. This is important so I don't break it in a
37
+ future version unintentionally.
38
+ * Commit, do not mess with rakefile, version, or history.
39
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
40
+ * Send me a pull request. Bonus points for topic branches.
41
+
42
+ ## Copyright
43
+
44
+ Copyright (c) 2010 Mathieu Fosse. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "capybara-facebook"
8
+ gem.summary = %Q{Facebook Driver for Capybara}
9
+ gem.description = %Q{Facebook Driver for Capybara}
10
+ gem.email = "mathieu@tigerlilyapps.com"
11
+ gem.homepage = "http://github.com/tigerlily/capybara-facebook"
12
+ gem.authors = ["Mathieu Fosse"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ gem.add_dependency "capybara", ">= 0.3.5"
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'spec/rake/spectask'
22
+ Spec::Rake::SpecTask.new(:spec) do |spec|
23
+ spec.libs << 'lib' << 'spec'
24
+ spec.spec_files = FileList['spec/**/*_spec.rb']
25
+ end
26
+
27
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
28
+ spec.libs << 'lib' << 'spec'
29
+ spec.pattern = 'spec/**/*_spec.rb'
30
+ spec.rcov = true
31
+ end
32
+
33
+ task :spec => :check_dependencies
34
+
35
+
36
+ task :default => :spec
37
+
38
+ require 'rake/rdoctask'
39
+ Rake::RDocTask.new do |rdoc|
40
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
+
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = "capybara-facebook #{version}"
44
+ rdoc.rdoc_files.include('README*')
45
+ rdoc.rdoc_files.include('lib/**/*.rb')
46
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,76 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{capybara-facebook}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Mathieu Fosse"]
12
+ s.date = %q{2010-03-27}
13
+ s.description = %q{Facebook Driver for Capybara}
14
+ s.email = %q{mathieu@tigerlilyapps.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "capybara-facebook.gemspec",
27
+ "config.ru",
28
+ "lib/capybara-facebook.rb",
29
+ "lib/capybara-facebook/cucumber.rb",
30
+ "lib/capybara-facebook/driver/base.rb",
31
+ "lib/capybara-facebook/driver/facebook_driver.rb",
32
+ "lib/capybara-facebook/session.rb",
33
+ "spec/driver/facebook_driver_spec.rb",
34
+ "spec/drivers_spec.rb",
35
+ "spec/spec.opts",
36
+ "spec/spec_helper.rb",
37
+ "spec/test_app.rb",
38
+ "spec/views/buttons.erb",
39
+ "spec/views/fieldsets.erb",
40
+ "spec/views/form.erb",
41
+ "spec/views/postback.erb",
42
+ "spec/views/tables.erb",
43
+ "spec/views/with_html.erb",
44
+ "spec/views/with_js.erb",
45
+ "spec/views/with_scope.erb",
46
+ "spec/views/with_simple_html.erb"
47
+ ]
48
+ s.homepage = %q{http://github.com/tigerlily/capybara-facebook}
49
+ s.rdoc_options = ["--charset=UTF-8"]
50
+ s.require_paths = ["lib"]
51
+ s.rubygems_version = %q{1.3.6}
52
+ s.summary = %q{Facebook Driver for Capybara}
53
+ s.test_files = [
54
+ "spec/driver/facebook_driver_spec.rb",
55
+ "spec/drivers_spec.rb",
56
+ "spec/spec_helper.rb",
57
+ "spec/test_app.rb"
58
+ ]
59
+
60
+ if s.respond_to? :specification_version then
61
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
62
+ s.specification_version = 3
63
+
64
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
65
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
66
+ s.add_runtime_dependency(%q<capybara>, [">= 0.3.5"])
67
+ else
68
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
69
+ s.add_dependency(%q<capybara>, [">= 0.3.5"])
70
+ end
71
+ else
72
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
73
+ s.add_dependency(%q<capybara>, [">= 0.3.5"])
74
+ end
75
+ end
76
+
data/config.ru ADDED
@@ -0,0 +1,6 @@
1
+ ## This is not needed for Thin > 1.0.0
2
+ ENV['RACK_ENV'] = "production"
3
+
4
+ require File.expand_path('spec/test_app', File.dirname(__FILE__))
5
+
6
+ run TestApp
@@ -0,0 +1,2 @@
1
+ require 'capybara'
2
+ require 'capybara-facebook/session'
@@ -0,0 +1,5 @@
1
+ require 'capybara/cucumber'
2
+
3
+ Before('@facebook') do
4
+ Capybara.current_driver = :facebook
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'capybara/driver/base'
2
+
3
+ Capybara::Driver::Base.class_eval do
4
+ def facebook_parameters!(params={})
5
+ raise NotImplementedError
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ require 'capybara-facebook/driver/base'
2
+ require 'capybara/driver/rack_test_driver'
3
+
4
+ class Capybara::Driver::Facebook < Capybara::Driver::RackTest
5
+
6
+ def visit(path, attributes = {})
7
+ return if path.gsub(/^#{current_path}/, '') =~ /^#/
8
+ get(path, facebook_default_params.merge(attributes), env)
9
+ follow_redirects!
10
+ cache_body
11
+ end
12
+
13
+ def facebook_parameters!(params={})
14
+ facebook_default_params.merge!(params)
15
+ end
16
+
17
+ private
18
+ def facebook_default_params
19
+ @facebook_default_params ||= {
20
+ "fb_sig_added" => "1",
21
+ "fb_sig_session_key" => "facebook_session_key",
22
+ "fb_sig_user" => "1234",
23
+ "fb_sig_expires" => "0",
24
+ "fb_sig_in_canvas" => "1",
25
+ "fb_sig_time" => Time.now.to_f
26
+ }
27
+ @facebook_default_params
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ require 'capybara/session'
2
+ require 'capybara-facebook/driver/facebook_driver'
3
+
4
+ Capybara::Session::DSL_METHODS << :facebook_parameters!
5
+
6
+ Capybara::Session.class_eval do
7
+ def driver_with_facebook
8
+ @driver ||= Capybara::Driver::Facebook.new(app) if mode == :facebook
9
+ driver_without_facebook
10
+ end
11
+
12
+ alias_method :driver_without_facebook, :driver
13
+ alias_method :driver, :driver_with_facebook
14
+
15
+ def facebook_parameters!(params)
16
+ driver.facebook_parameters!(params)
17
+ end
18
+ end
19
+
20
+
@@ -0,0 +1,43 @@
1
+ require File.expand_path('../spec_helper', File.dirname(__FILE__))
2
+
3
+ describe Capybara::Driver::Facebook do
4
+ before do
5
+ @driver = Capybara::Driver::Facebook.new(TestApp)
6
+ end
7
+
8
+ it_should_behave_like "driver"
9
+ it_should_behave_like "driver with header support"
10
+
11
+
12
+ describe "Facebook parameters" do
13
+ before do
14
+ @default_keys = %w(fb_sig_added fb_sig_session_key fb_sig_user fb_sig_expires fb_sig_in_canvas fb_sig_time)
15
+ end
16
+
17
+ it "should have Facebook default params" do
18
+ @driver.visit('/')
19
+ @driver.last_request.env["rack.request.query_hash"].should include(*@default_keys)
20
+ end
21
+
22
+ it "should be able to add a param to Facebook default params" do
23
+ @driver.facebook_parameters!({ :fb_sig_is_fan => "1" })
24
+ @driver.visit('/')
25
+ query_hash = @driver.last_request.env["rack.request.query_hash"]
26
+ query_hash.should have_key("fb_sig_is_fan")
27
+ query_hash["fb_sig_is_fan"].should == "1"
28
+ end
29
+
30
+ it "should be able to change a Facebook default param value" do
31
+ @driver.facebook_parameters!({ :fb_sig_in_canvas => "0" })
32
+ @driver.visit('/')
33
+
34
+ @driver.last_request.env["rack.request.query_hash"].should include(*@default_keys)
35
+
36
+ query_hash = @driver.last_request.env["rack.request.query_hash"]
37
+ query_hash.should have_key("fb_sig_in_canvas")
38
+ query_hash["fb_sig_in_canvas"].should == "0"
39
+ end
40
+ end
41
+
42
+
43
+ end
@@ -0,0 +1,128 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+ require 'capybara/wait_until'
3
+
4
+ shared_examples_for 'driver' do
5
+
6
+ describe '#visit' do
7
+ it "should move to another page" do
8
+ @driver.visit('/')
9
+ @driver.body.should include('Hello world!')
10
+ @driver.visit('/foo')
11
+ @driver.body.should include('Another World')
12
+ end
13
+
14
+ it "should show the correct URL" do
15
+ @driver.visit('/foo')
16
+ @driver.current_url.should include('/foo')
17
+ end
18
+ end
19
+
20
+ describe '#body' do
21
+ it "should return text reponses" do
22
+ @driver.visit('/')
23
+ @driver.body.should include('Hello world!')
24
+ end
25
+
26
+ it "should return the full response html" do
27
+ @driver.visit('/with_simple_html')
28
+ @driver.body.should include('Bar')
29
+ end
30
+ end
31
+
32
+ describe '#find' do
33
+ context "with xpath selector" do
34
+ before do
35
+ @driver.visit('/with_html')
36
+ end
37
+
38
+ it "should extract node texts" do
39
+ @driver.find('//a')[0].text.should == 'labore'
40
+ @driver.find('//a')[1].text.should == 'ullamco'
41
+ end
42
+
43
+ it "should extract node attributes" do
44
+ @driver.find('//a')[0][:href].should == '/with_simple_html'
45
+ @driver.find('//a')[0][:class].should == 'simple'
46
+ @driver.find('//a')[1][:href].should == '/foo'
47
+ @driver.find('//a')[1][:id].should == 'foo'
48
+ @driver.find('//a')[1][:rel].should be_nil
49
+ end
50
+
51
+ it "should extract boolean node attributes" do
52
+ @driver.find('//input[@id="checked_field"]')[0][:checked].should be_true
53
+ end
54
+
55
+ it "should allow assignment of field value" do
56
+ @driver.find('//input').first.value.should == 'monkey'
57
+ @driver.find('//input').first.set('gorilla')
58
+ @driver.find('//input').first.value.should == 'gorilla'
59
+ end
60
+
61
+ it "should extract node tag name" do
62
+ @driver.find('//a')[0].tag_name.should == 'a'
63
+ @driver.find('//a')[1].tag_name.should == 'a'
64
+ @driver.find('//p')[1].tag_name.should == 'p'
65
+ end
66
+
67
+ it "should extract node visibility" do
68
+ @driver.find('//a')[0].should be_visible
69
+
70
+ @driver.find('//div[@id="hidden"]')[0].should_not be_visible
71
+ @driver.find('//div[@id="hidden_via_ancestor"]')[0].should_not be_visible
72
+ end
73
+ end
74
+ end
75
+
76
+ describe "node relative searching" do
77
+ before do
78
+ @driver.visit('/tables')
79
+ @node = @driver.find('//body').first
80
+ end
81
+
82
+ it "should be able to navigate/search child node" do
83
+ @node.all('//table').size.should == 5
84
+ @node.find('//form').all('.//table').size.should == 1
85
+ @node.find('//form').find('.//table//caption').text.should == 'Agent'
86
+ if @driver.class == Capybara::Driver::Selenium
87
+ pending("Selenium gets this wrong, see http://code.google.com/p/selenium/issues/detail?id=403") do
88
+ @node.find('//form').all('//table').size.should == 5
89
+ end
90
+ else
91
+ @node.find('//form').all('//table').size.should == 5
92
+ end
93
+ end
94
+ end
95
+
96
+ end
97
+
98
+ shared_examples_for "driver with javascript support" do
99
+ before { @driver.visit('/with_js') }
100
+
101
+ describe '#find' do
102
+ it "should find dynamically changed nodes" do
103
+ @driver.find('//p').first.text.should == 'I changed it'
104
+ end
105
+ end
106
+
107
+ describe '#drag_to' do
108
+ it "should drag and drop an object" do
109
+ draggable = @driver.find('//div[@id="drag"]').first
110
+ droppable = @driver.find('//div[@id="drop"]').first
111
+ draggable.drag_to(droppable)
112
+ @driver.find('//div[contains(., "Dropped!")]').should_not be_nil
113
+ end
114
+ end
115
+
116
+ describe "#evaluate_script" do
117
+ it "should return the value of the executed script" do
118
+ @driver.evaluate_script('1+1').should == 2
119
+ end
120
+ end
121
+ end
122
+
123
+ shared_examples_for "driver with header support" do
124
+ it "should make headers available through response_headers" do
125
+ @driver.visit('/with_simple_html')
126
+ @driver.response_headers['Content-Type'].should == 'text/html'
127
+ end
128
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,18 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'rubygems'
5
+ require 'capybara'
6
+ require 'capybara-facebook'
7
+ require 'spec'
8
+ require 'spec/autorun'
9
+ require 'test_app'
10
+ require 'drivers_spec'
11
+
12
+ Capybara.default_wait_time = 0 # less timeout so tests run faster
13
+
14
+ Spec::Runner.configure do |config|
15
+ config.after do
16
+ Capybara.default_selector = :xpath
17
+ end
18
+ end
data/spec/test_app.rb ADDED
@@ -0,0 +1,71 @@
1
+ require 'sinatra/base'
2
+ require 'rack'
3
+ require 'yaml'
4
+
5
+ class TestApp < Sinatra::Base
6
+ set :root, File.dirname(__FILE__)
7
+ set :static, true
8
+
9
+ get '/' do
10
+ 'Hello world!'
11
+ end
12
+
13
+ get '/foo' do
14
+ 'Another World'
15
+ end
16
+
17
+ get '/redirect' do
18
+ redirect '/redirect_again'
19
+ end
20
+
21
+ get '/redirect_again' do
22
+ redirect '/landed'
23
+ end
24
+
25
+ get '/landed' do
26
+ "You landed"
27
+ end
28
+
29
+ get '/with-quotes' do
30
+ %q{"No," he said, "you can't do that."}
31
+ end
32
+
33
+ get '/form/get' do
34
+ '<pre id="results">' + params[:form].to_yaml + '</pre>'
35
+ end
36
+
37
+ get '/favicon.ico' do
38
+ nil
39
+ end
40
+
41
+ post '/redirect' do
42
+ redirect '/redirect_again'
43
+ end
44
+
45
+ get '/redirect_back' do
46
+ redirect back
47
+ end
48
+
49
+ get '/:view' do |view|
50
+ erb view.to_sym
51
+ end
52
+
53
+ post '/form' do
54
+ '<pre id="results">' + params[:form].to_yaml + '</pre>'
55
+ end
56
+
57
+ post '/upload' do
58
+ begin
59
+ buffer = []
60
+ buffer << "Content-type: #{params[:form][:document][:type]}"
61
+ buffer << "File content: #{params[:form][:document][:tempfile].read}"
62
+ buffer.join(' | ')
63
+ rescue
64
+ 'No file uploaded'
65
+ end
66
+ end
67
+ end
68
+
69
+ if __FILE__ == $0
70
+ Rack::Handler::Mongrel.run TestApp, :Port => 8070
71
+ end
@@ -0,0 +1,4 @@
1
+ <h1>Buttons</h1>
2
+ <button>Click me!</button>
3
+ <button id="click_me_123">Click me by id!</button>
4
+ <button value="click_me">Click me by value!</button>
@@ -0,0 +1,29 @@
1
+ <form action="/form" method="post">
2
+ <fieldset id="agent_fieldset">
3
+ <legend>Agent</legend>
4
+
5
+ <p>
6
+ <label for="form_agent_name">Name</label>
7
+ <input type="text" name="form[agent_name]" value="James" id="form_agent_name"/>
8
+ </p>
9
+
10
+ <p>
11
+ <input type="submit" value="Create"/>
12
+ </p>
13
+ </fieldset>
14
+ </form>
15
+
16
+ <form action="/form" method="post">
17
+ <fieldset id="villain_fieldset">
18
+ <legend>Villain</legend>
19
+
20
+ <p>
21
+ <label for="form_villain_name">Name</label>
22
+ <input type="text" name="form[villain_name]" value="Ernst" id="form_villain_name"/>
23
+ </p>
24
+
25
+ <p>
26
+ <input type="submit" value="Create"/>
27
+ </p>
28
+ </fieldset>
29
+ </form>
@@ -0,0 +1,227 @@
1
+ <h1>Form</h1>
2
+
3
+ <form action="/form" method="post">
4
+
5
+ <p>
6
+ <label for="form_title">Title</label>
7
+ <select name="form[title]" id="form_title">
8
+ <option>Mrs</option>
9
+ <option>Mr</option>
10
+ <option>Miss</option>
11
+ </select>
12
+ </p>
13
+
14
+ <p>
15
+ <label for="form_first_name">
16
+ First Name
17
+ <input type="text" name="form[first_name]" value="John" id="form_first_name"/>
18
+ </label>
19
+ </p>
20
+
21
+ <p>
22
+ <label for="form_last_name">Last Name</label>
23
+ <input type="text" name="form[last_name]" value="Smith" id="form_last_name"/>
24
+ </p>
25
+
26
+ <p>
27
+ <label for="form_name_explanation">Explanation of Name</label>
28
+ <textarea name="form[name_explanation]" id="form_name_explanation"></textarea>
29
+ </p>
30
+
31
+ <p>
32
+ <label for="form_name">Name</label>
33
+ <input type="text" name="form[name]" value="John Smith" id="form_name"/>
34
+ </p>
35
+
36
+ <p>
37
+ <label>Street<br/>
38
+ <input type="text" name="form[street]" value="Sesame street 66"/>
39
+ </label>
40
+ </p>
41
+
42
+ <p>
43
+ <label for="form_phone">Phone</label>
44
+ <input type="text" name="form[phone]" value="+1 555 7021" id="form_phone"/>
45
+ </p>
46
+
47
+ <p>
48
+ <label for="form_password">Password</label>
49
+ <input type="password" name="form[password]" value="seeekrit" id="form_password"/>
50
+ </p>
51
+
52
+ <p>
53
+ <label for="form_terms_of_use">Terms of Use</label>
54
+ <input type="hidden" name="form[terms_of_use]" value="0" id="form_terms_of_use_default">
55
+ <input type="checkbox" name="form[terms_of_use]" value="1" id="form_terms_of_use">
56
+ </p>
57
+
58
+ <p>
59
+ <label for="form_image">Image</label>
60
+ <input type="file" name="form[image]" id="form_image"/>
61
+ </p>
62
+
63
+ <p>
64
+ <input type="hidden" name="form[token]" value="12345" id="form_token"/>
65
+ </p>
66
+
67
+ <p>
68
+ <label for="form_locale">Locale</label>
69
+ <select name="form[locale]" id="form_locale">
70
+ <option value="sv">Swedish</option>
71
+ <option selected="selected" value="en">English</option>
72
+ <option value="fi">Finish</option>
73
+ <option value="no">Norwegian</option>
74
+ </select>
75
+ </p>
76
+
77
+ <p>
78
+ <label for="form_region">Region</label>
79
+ <select name="form[region]" id="form_region">
80
+ <option>Sweden</option>
81
+ <option selected="selected">Norway</option>
82
+ <option>Finland</option>
83
+ </select>
84
+ </p>
85
+
86
+ <p>
87
+ <label for="form_city">City</label>
88
+ <select name="form[city]" id="form_city">
89
+ <option>London</option>
90
+ <option>Stockholm</option>
91
+ <option>Paris</option>
92
+ </select>
93
+ </p>
94
+
95
+ <p>
96
+ <label for="form_tendency">Tendency</label>
97
+ <select name="form[tendency]" id="form_tendency"></select>
98
+ </p>
99
+
100
+ <p>
101
+ <label for="form_description">Description</label></br>
102
+ <textarea name="form[description]" id="form_description">Descriptive text goes here</textarea>
103
+ <p>
104
+
105
+ <p>
106
+ <input type="radio" name="form[gender]" value="male" id="gender_male"/>
107
+ <label for="gender_male">Male</label>
108
+ <input type="radio" name="form[gender]" value="female" id="gender_female" checked="checked"/>
109
+ <label for="gender_female">Female</label>
110
+ <input type="radio" name="form[gender]" value="both" id="gender_both"/>
111
+ <label for="gender_both">Both</label>
112
+ </p>
113
+
114
+ <p>
115
+ <input type="checkbox" value="dog" name="form[pets][]" id="form_pets_dog" checked="checked"/>
116
+ <label for="form_pets_dog">Dog</label>
117
+ <input type="checkbox" value="cat" name="form[pets][]" id="form_pets_cat"/>
118
+ <label for="form_pets_cat">Cat</label>
119
+ <input type="checkbox" value="hamster" name="form[pets][]" id="form_pets_hamster" checked="checked"/>
120
+ <label for="form_pets_hamster">Hamster</label>
121
+ </p>
122
+
123
+ <p>
124
+ <label for="form_languages">Languages</label>
125
+ <select name="form[languages][]" id="form_languages" multiple="multiple">
126
+ <option>Ruby</option>
127
+ <option>SQL</option>
128
+ <option>HTML</option>
129
+ <option>Javascript</option>
130
+ </select>
131
+ </p>
132
+
133
+ <p>
134
+ <label for="form_underwear">Underwear</label>
135
+ <select name="form[underwear][]" id="form_underwear" multiple="multiple">
136
+ <option selected="selected">Boxer Briefs</option>
137
+ <option>Boxers</option>
138
+ <option selected="selected">Briefs</option>
139
+ <option selected="selected">Commando</option>
140
+ </select>
141
+ </p>
142
+
143
+ <div style="display:none;">
144
+ <label for="form_first_name_hidden">
145
+ Super Secret
146
+ <input type="text" name="form[super_secret]" value="test123" id="form_super_secret"/>
147
+ </label>
148
+ </div>
149
+
150
+ <p>
151
+ <input type="button" name="form[fresh]" id="fresh_btn" value="i am fresh"/>
152
+ <input type="submit" name="form[awesome]" id="awe123" value="awesome"/>
153
+ <input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
154
+ <input type="image" name="form[okay]" id="okay556" value="okay" alt="oh hai thar"/>
155
+ <button type="submit" id="click_me_123" value="click_me">Click me!</button>
156
+ <button type="submit" name="form[no_value]">No Value!</button>
157
+ </p>
158
+ </form>
159
+
160
+ <form action="/form/get?foo=bar" method="get">
161
+ <p>
162
+ <label for="form_middle_name">Middle Name</label>
163
+ <input type="text" name="form[middle_name]" value="Darren" id="form_middle_name"/>
164
+ </p>
165
+
166
+ <p>
167
+ <input type="submit" name="form[mediocre]" id="mediocre" value="med"/>
168
+ <p>
169
+ </form>
170
+
171
+ <form action="/upload" method="post" enctype="multipart/form-data">
172
+ <p>
173
+ <label for="form_file_name">File Name</label>
174
+ <input type="file" name="form[file_name]" id="form_file_name"/>
175
+ </p>
176
+
177
+ <p>
178
+ <label for="form_document">Document</label>
179
+ <input type="file" name="form[document]" id="form_document"/>
180
+ </p>
181
+
182
+ <p>
183
+ <input type="submit" value="Upload"/>
184
+ <p>
185
+ </form>
186
+
187
+ <form action="/redirect" method="post">
188
+ <p>
189
+ <input type="submit" value="Go FAR"/>
190
+ </p>
191
+ </form>
192
+
193
+ <form action="/form" method="post">
194
+ <p>
195
+ <label for="html5_email">Html5 Email</label>
196
+ <input type="email" name="form[html5_email]" value="person@email.com" id="html5_email"/>
197
+ </p>
198
+ <p>
199
+ <label for="html5_url">Html5 Url</label>
200
+ <input type="url" name="form[html5_url]" value="http://www.example.com" id="html5_url"/>
201
+ </p>
202
+ <p>
203
+ <label for="html5_search">Html5 Search</label>
204
+ <input type="search" name="form[html5_search]" value="what are you looking for" id="html5_search"/>
205
+ </p>
206
+ <p>
207
+ <label for="html5_tel">Html5 Tel</label>
208
+ <input type="tel" name="form[html5_tel]" value="911" id="html5_tel"/>
209
+ </p>
210
+ <p>
211
+ <label for="html5_color">Html5 Color</label>
212
+ <input type="color" name="form[html5_color]" value="#FFF" id="html5_color"/>
213
+ </p>
214
+
215
+ <p>
216
+ <input type="submit" name="form[html5_submit]" value="html5_submit"/>
217
+ </p>
218
+ </form>
219
+
220
+ <form action="/form" method="post">
221
+ <p>
222
+ <button type="submit" name="form[button]" value="button_first">Just an input that came first</button>
223
+ <button type="submit" name="form[button]" value="button_second">Just an input</button>
224
+ <input type="submit" name="form[button]" value="Just a button that came first"/>
225
+ <input type="submit" name="form[button]" value="Just a button"/>
226
+ </p>
227
+ </form>
@@ -0,0 +1,13 @@
1
+ <h1>Postback</h1>
2
+
3
+ <form method="get">
4
+ <p>
5
+ <input type="submit" value="With no action">
6
+ </p>
7
+ </form>
8
+
9
+ <form action="" method="get">
10
+ <p>
11
+ <input type="submit" value="With blank action">
12
+ </p>
13
+ </form>
@@ -0,0 +1,122 @@
1
+ <form action="/form" method="post">
2
+ <table id="agent_table">
3
+ <caption>Agent</caption>
4
+
5
+ <tr>
6
+ <td>
7
+ <label for="form_agent_name">Name</label>
8
+ </td>
9
+ <td>
10
+ <input type="text" name="form[agent_name]" value="James" id="form_agent_name"/>
11
+ </td>
12
+ </tr>
13
+
14
+ <tr>
15
+ <td colspan="2">
16
+ <input type="submit" value="Create"/>
17
+ </td>
18
+ </tr>
19
+ </table>
20
+ </form>
21
+
22
+ <form action="/form" method="post">
23
+ <table id="girl_table">
24
+ <caption>Girl</caption>
25
+
26
+ <tr>
27
+ <td>
28
+ <label for="form_girl_name">Name</label>
29
+ </td>
30
+ <td>
31
+ <input type="text" name="form[girl_name]" value="Vesper" id="form_girl_name"/>
32
+ </td>
33
+ </tr>
34
+
35
+ <tr>
36
+ <td colspan="2">
37
+ <input type="submit" value="Create"/>
38
+ </td>
39
+ </tr>
40
+ </table>
41
+ </form>
42
+
43
+ <form action="/form" method="post">
44
+ <table id="villain_table">
45
+ <caption>Villain</caption>
46
+
47
+ <tr>
48
+ <td>
49
+ <label for="form_villain_name">Name</label>
50
+ </td>
51
+ <td>
52
+ <input type="text" name="form[villain_name]" value="Ernst" id="form_villain_name"/>
53
+ </td>
54
+ </tr>
55
+
56
+ <tr>
57
+ <td colspan="2">
58
+ <input type="submit" value="Create"/>
59
+ </td>
60
+ </tr>
61
+ </table>
62
+ </form>
63
+
64
+ <table>
65
+ <caption>Ransom</caption>
66
+
67
+ <thead>
68
+ <tr>
69
+ <th>Year</th>
70
+ <th>Governmental</th>
71
+ <th>Private</th>
72
+ </tr>
73
+ </thead>
74
+
75
+ <tbody>
76
+ <tr>
77
+ <th scope="row">2007</th>
78
+ <td>$300</td>
79
+ <td>$100</td>
80
+ </tr>
81
+ <tr>
82
+ <th scope="row">2008</th>
83
+ <td>$123</td>
84
+ <td>$897</td>
85
+ </tr>
86
+ <tr>
87
+ <th scope="row">2009</th>
88
+ <td>$543</td>
89
+ <td>$99</td>
90
+ </tr>
91
+ </tbody>
92
+ </table>
93
+
94
+ <table>
95
+ <caption>Deaths</caption>
96
+
97
+ <thead>
98
+ <tr>
99
+ <th>Year</th>
100
+ <th>Sharks with lasers</th>
101
+ <th>Flaming volcano</th>
102
+ </tr>
103
+ </thead>
104
+
105
+ <tbody>
106
+ <tr>
107
+ <th scope="row">2007</th>
108
+ <td>66</td>
109
+ <td>7</td>
110
+ </tr>
111
+ <tr>
112
+ <th scope="row">2008</th>
113
+ <td>123</td>
114
+ <td>12</td>
115
+ </tr>
116
+ <tr>
117
+ <th scope="row">2009</th>
118
+ <td>913</td>
119
+ <td>13</td>
120
+ </tr>
121
+ </tbody>
122
+ </table>
@@ -0,0 +1,38 @@
1
+ <h1>This is a test</h1>
2
+
3
+ <p id="first">
4
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
5
+ tempor incididunt ut <a href="/with_simple_html" title="awesome title" class="simple">labore</a>
6
+ et dolore magna aliqua. Ut enim ad minim veniam,
7
+ quis nostrud exercitation <a href="/foo" id="foo">ullamco</a> laboris nisi
8
+ ut aliquip ex ea commodo consequat.
9
+ <a href="/with_simple_html"><img src="http://www.foobar.sun/dummy_image.jpg" width="20" height="20" alt="awesome image" /></a>
10
+ </p>
11
+
12
+ <p id="second">
13
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
14
+ dolore eu fugiat <a href="/redirect" id="red">Redirect</a> pariatur. Excepteur sint occaecat cupidatat non proident,
15
+ sunt in culpa qui officia deserunt mollit anim id est laborum.
16
+ </p>
17
+
18
+ <p>
19
+ <input type="text" id="test_field" value="monkey"/>
20
+ <a href="/redirect_back">BackToMyself</a>
21
+ <a title="twas a fine link" href="/redirect">A link came first</a>
22
+ <a title="a fine link" href="/with_simple_html">A link</a>
23
+ <a>No Href</a>
24
+ <a href="">Blank Href</a>
25
+ <a href="#">Blank Anchor</a>
26
+ <a href="#anchor">Anchor</a>
27
+ <a href="/with_simple_html#anchor">Anchor on different page</a>
28
+ <a href="/with_html#anchor">Anchor on same page</a>
29
+ <input type="text" value="" id="test_field">
30
+ <input type="text" checked="checked" id="checked_field">
31
+ <a href="/redirect"><img src="http://www.foobar.sun/dummy_image.jpg" width="20" height="20" alt="very fine image" /></a>
32
+ <a href="/with_simple_html"><img src="http://www.foobar.sun/dummy_image.jpg" width="20" height="20" alt="fine image" /></a>
33
+ </p>
34
+
35
+ <div id="hidden" style="display: none;">
36
+ <div id="hidden_via_ancestor">Inside element with hidden ancestor</div>
37
+ <a href="/with_simple_html" title="awesome title" class="simple">hidden link</a>
38
+ </div>
@@ -0,0 +1,39 @@
1
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
2
+ <head>
3
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
4
+ <title>with_js</title>
5
+ <script src="/jquery.js" type="text/javascript" charset="utf-8"></script>
6
+ <script src="/jquery-ui.js" type="text/javascript" charset="utf-8"></script>
7
+ <script src="/test.js" type="text/javascript" charset="utf-8"></script>
8
+ </head>
9
+
10
+ <body id="with_js">
11
+ <h1>FooBar</h1>
12
+
13
+ <p id="change">This is text</p>
14
+ <div id="drag">
15
+ <p>This is a draggable element.</p>
16
+ </div>
17
+ <div id="drop">
18
+ <p>It should be dropped here.</p>
19
+ </div>
20
+
21
+ <p><a href="#" id="clickable">Click me</a></p>
22
+
23
+ <p>
24
+ <select id="waiter">
25
+ <option>Foo</option>
26
+ <option>My Waiting Option</option>
27
+ </select>
28
+ </p>
29
+
30
+ <p>
31
+ <input type="text" name="with_focus_event" value="" id="with_focus_event"/>
32
+ </p>
33
+
34
+ <p>
35
+ <input type="checkbox" id="checkbox_with_event"/>
36
+ </p>
37
+ </body>
38
+ </html>
39
+
@@ -0,0 +1,36 @@
1
+ <h1>This page is used for testing various scopes</h1>
2
+
3
+ <p id="for_foo">
4
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
5
+ incididunt ut labore et dolore magna aliqua. Ut enim ad minim venia.
6
+ <a href="/redirect">Go</a>
7
+ </p>
8
+
9
+ <div id="for_bar">
10
+ <ul>
11
+ <li>With Simple HTML: <a href="/with_simple_html">Go</a>
12
+ <form action="/redirect" method="post" accept-charset="utf-8">
13
+ <p>
14
+ <label for="simple_first_name">First Name</label>
15
+ <input type="text" name="first_name" value="John" id="simple_first_name"/>
16
+ </p>
17
+ <p><input type="submit" value="Go"/></p>
18
+ </form>
19
+ </li>
20
+ <li>Bar: <a href="/foo">Go</a>
21
+ <form action="/form" method="post" accept-charset="utf-8">
22
+ <p>
23
+ <label for="bar_first_name">First Name</label>
24
+ <input type="text" name="form[first_name]" value="Peter" id="bar_first_name"/>
25
+ </p>
26
+ <p><input type="submit" value="Go"/></p>
27
+ </form>
28
+ </li>
29
+ </ul>
30
+ </div>
31
+
32
+ <div id="another_foo">
33
+ <ul>
34
+ <li>With Simple HTML: <a href="/">Go</a>
35
+ </ul>
36
+ </div>
@@ -0,0 +1 @@
1
+ Bar
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capybara-facebook
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Mathieu Fosse
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-27 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
31
+ version: 1.2.9
32
+ type: :development
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: capybara
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ - 3
44
+ - 5
45
+ version: 0.3.5
46
+ type: :runtime
47
+ version_requirements: *id002
48
+ description: Facebook Driver for Capybara
49
+ email: mathieu@tigerlilyapps.com
50
+ executables: []
51
+
52
+ extensions: []
53
+
54
+ extra_rdoc_files:
55
+ - LICENSE
56
+ - README.md
57
+ files:
58
+ - .document
59
+ - .gitignore
60
+ - LICENSE
61
+ - README.md
62
+ - Rakefile
63
+ - VERSION
64
+ - capybara-facebook.gemspec
65
+ - config.ru
66
+ - lib/capybara-facebook.rb
67
+ - lib/capybara-facebook/cucumber.rb
68
+ - lib/capybara-facebook/driver/base.rb
69
+ - lib/capybara-facebook/driver/facebook_driver.rb
70
+ - lib/capybara-facebook/session.rb
71
+ - spec/driver/facebook_driver_spec.rb
72
+ - spec/drivers_spec.rb
73
+ - spec/spec.opts
74
+ - spec/spec_helper.rb
75
+ - spec/test_app.rb
76
+ - spec/views/buttons.erb
77
+ - spec/views/fieldsets.erb
78
+ - spec/views/form.erb
79
+ - spec/views/postback.erb
80
+ - spec/views/tables.erb
81
+ - spec/views/with_html.erb
82
+ - spec/views/with_js.erb
83
+ - spec/views/with_scope.erb
84
+ - spec/views/with_simple_html.erb
85
+ has_rdoc: true
86
+ homepage: http://github.com/tigerlily/capybara-facebook
87
+ licenses: []
88
+
89
+ post_install_message:
90
+ rdoc_options:
91
+ - --charset=UTF-8
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ segments:
106
+ - 0
107
+ version: "0"
108
+ requirements: []
109
+
110
+ rubyforge_project:
111
+ rubygems_version: 1.3.6
112
+ signing_key:
113
+ specification_version: 3
114
+ summary: Facebook Driver for Capybara
115
+ test_files:
116
+ - spec/driver/facebook_driver_spec.rb
117
+ - spec/drivers_spec.rb
118
+ - spec/spec_helper.rb
119
+ - spec/test_app.rb