casper 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +85 -0
- data/lib/casper.rb +115 -0
- data/lib/libxdo.rb +256 -0
- data/test/Vagrantfile +20 -0
- data/test/casper_test.rb +116 -0
- data/test/cookbooks/application/recipes/default.rb +6 -0
- data/test/cookbooks/application/recipes/vagrant.rb +1 -0
- data/test/cookbooks/application/templates/default/application.erb +11 -0
- data/test/cookbooks/apt/README.md +44 -0
- data/test/cookbooks/apt/files/default/apt-cacher +9 -0
- data/test/cookbooks/apt/files/default/apt-cacher.conf +144 -0
- data/test/cookbooks/apt/files/default/apt-proxy-v2.conf +50 -0
- data/test/cookbooks/apt/metadata.json +38 -0
- data/test/cookbooks/apt/metadata.rb +12 -0
- data/test/cookbooks/apt/recipes/cacher.rb +42 -0
- data/test/cookbooks/apt/recipes/default.rb +33 -0
- data/test/cookbooks/apt/recipes/proxy.rb +34 -0
- data/test/cookbooks/rvm/files/default/rvm-install-system-wide +99 -0
- data/test/cookbooks/rvm/files/default/source-rvm +1 -0
- data/test/cookbooks/rvm/recipes/default.rb +47 -0
- data/test/cookbooks/testing/files/default/Xwrapper.config +14 -0
- data/test/cookbooks/testing/files/default/xorg.conf +58 -0
- data/test/cookbooks/testing/recipes/default.rb +59 -0
- data/test/lib/public/jquery-ui.js +1012 -0
- data/test/lib/public/jquery.js +6240 -0
- data/test/lib/public/rxin_test.js +7 -0
- data/test/lib/server.rb +34 -0
- data/test/lib/test_helper.rb +69 -0
- metadata +166 -0
@@ -0,0 +1,7 @@
|
|
1
|
+
$(document).ready(function() {
|
2
|
+
$(".target").
|
3
|
+
live("mouseover" , function() { $(this).addClass("mouseover"); }).
|
4
|
+
live("mouseout" , function() { $(this).removeClass("mouseover"); }).
|
5
|
+
live("mousedown" , function() { $(this).addClass("mousedown"); }).
|
6
|
+
live("mouseup" , function() { $(this).removeClass("mousedown"); });
|
7
|
+
});
|
data/test/lib/server.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
class Server < Sinatra::Base
|
2
|
+
set :public, File.dirname(__FILE__) + '/public'
|
3
|
+
|
4
|
+
get "/" do
|
5
|
+
haml <<-HAML
|
6
|
+
!!!
|
7
|
+
%head
|
8
|
+
%script{ :src => "jquery.js" }
|
9
|
+
%script{ :src => "jquery-ui.js" }
|
10
|
+
%script{ :src => "rxin_test.js" }
|
11
|
+
%body
|
12
|
+
%style{ :type => "text/css" }
|
13
|
+
:sass
|
14
|
+
body, html
|
15
|
+
:width 100%
|
16
|
+
:height 100%
|
17
|
+
:overflow hidden
|
18
|
+
:margin 0px
|
19
|
+
:padding 0px
|
20
|
+
body
|
21
|
+
:background-color #fff
|
22
|
+
.target
|
23
|
+
:background-color #000
|
24
|
+
:display block
|
25
|
+
:position absolute
|
26
|
+
:width 50px
|
27
|
+
:height 50px
|
28
|
+
&.mouseover
|
29
|
+
:background-color #f00
|
30
|
+
&.mousedown
|
31
|
+
:background-color #0f0
|
32
|
+
HAML
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
Dir[File.expand_path(File.dirname(__FILE__) + "/../..") + "/lib/"].each{ |lib| $:.unshift(lib) }
|
2
|
+
|
3
|
+
$:.unshift(File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require "rubygems"
|
6
|
+
require "ruby-debug"
|
7
|
+
require "sinatra"
|
8
|
+
require "test/unit"
|
9
|
+
require "contest"
|
10
|
+
require "capybara/dsl"
|
11
|
+
require "server"
|
12
|
+
require "casper"
|
13
|
+
|
14
|
+
Capybara.app = Server.prototype
|
15
|
+
Capybara.default_driver = :selenium
|
16
|
+
Server.set :environment, :test
|
17
|
+
|
18
|
+
class Test::Unit::TestCase
|
19
|
+
include Capybara
|
20
|
+
|
21
|
+
class << self
|
22
|
+
alias original_should should
|
23
|
+
|
24
|
+
def should(name, options={}, &block)
|
25
|
+
original_should(name) do
|
26
|
+
Capybara.with_driver(options[:driver]) do
|
27
|
+
instance_eval(&block)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Resize the browser window to the given width and height
|
34
|
+
def resize_browser(width, height)
|
35
|
+
evaluate_script %Q{window.resizeTo(#{width}, #{height});}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Finds the element with the given css selector and the given class
|
39
|
+
def has_class?(css, klass)
|
40
|
+
find(XPath.from_css(css + ".#{klass}"))
|
41
|
+
end
|
42
|
+
|
43
|
+
def assert_has_position?(selector, position)
|
44
|
+
actual_position = evaluate_script("$('#{selector}').position()")
|
45
|
+
assert(
|
46
|
+
(actual_position["left"].floor == position[:left].floor && actual_position["top"].floor == position[:top].floor),
|
47
|
+
"Expected position of \"#{selector}\" to be { left: #{position[:left].floor}, top: #{position[:top].floor} }, was { left: #{actual_position["left"].floor}, top: #{actual_position["top"].floor} }"
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
module Capybara
|
53
|
+
def self.with_driver(name)
|
54
|
+
old_driver = current_driver
|
55
|
+
self.current_driver = name
|
56
|
+
yield
|
57
|
+
ensure
|
58
|
+
self.current_driver = name
|
59
|
+
end
|
60
|
+
|
61
|
+
class XPath
|
62
|
+
alias original_add_field add_field
|
63
|
+
|
64
|
+
def add_field(locator, field, options={})
|
65
|
+
xpath = original_add_field(locator, field, options)
|
66
|
+
xpath.append("//input[@placeholder='#{locator}']")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: casper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Ben Alavi
|
14
|
+
- Chris Schneider
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2010-09-18 00:00:00 -07:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: contest
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: stories
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
type: :development
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: capybara
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
type: :development
|
63
|
+
version_requirements: *id003
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: sinatra
|
66
|
+
prerelease: false
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
type: :development
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: haml
|
80
|
+
prerelease: false
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
type: :development
|
91
|
+
version_requirements: *id005
|
92
|
+
description: ""
|
93
|
+
email:
|
94
|
+
- benalavi@gmail.com
|
95
|
+
- chris.schneider@citrusbyte.com
|
96
|
+
executables: []
|
97
|
+
|
98
|
+
extensions: []
|
99
|
+
|
100
|
+
extra_rdoc_files: []
|
101
|
+
|
102
|
+
files:
|
103
|
+
- lib/casper.rb
|
104
|
+
- lib/libxdo.rb
|
105
|
+
- README.md
|
106
|
+
- test/casper_test.rb
|
107
|
+
- test/cookbooks/application/recipes/default.rb
|
108
|
+
- test/cookbooks/application/recipes/vagrant.rb
|
109
|
+
- test/cookbooks/application/templates/default/application.erb
|
110
|
+
- test/cookbooks/apt/files/default/apt-cacher
|
111
|
+
- test/cookbooks/apt/files/default/apt-cacher.conf
|
112
|
+
- test/cookbooks/apt/files/default/apt-proxy-v2.conf
|
113
|
+
- test/cookbooks/apt/metadata.json
|
114
|
+
- test/cookbooks/apt/metadata.rb
|
115
|
+
- test/cookbooks/apt/README.md
|
116
|
+
- test/cookbooks/apt/recipes/cacher.rb
|
117
|
+
- test/cookbooks/apt/recipes/default.rb
|
118
|
+
- test/cookbooks/apt/recipes/proxy.rb
|
119
|
+
- test/cookbooks/rvm/files/default/rvm-install-system-wide
|
120
|
+
- test/cookbooks/rvm/files/default/source-rvm
|
121
|
+
- test/cookbooks/rvm/recipes/default.rb
|
122
|
+
- test/cookbooks/testing/files/default/xorg.conf
|
123
|
+
- test/cookbooks/testing/files/default/Xwrapper.config
|
124
|
+
- test/cookbooks/testing/recipes/default.rb
|
125
|
+
- test/lib/public/jquery-ui.js
|
126
|
+
- test/lib/public/jquery.js
|
127
|
+
- test/lib/public/rxin_test.js
|
128
|
+
- test/lib/server.rb
|
129
|
+
- test/lib/test_helper.rb
|
130
|
+
- test/Vagrantfile
|
131
|
+
has_rdoc: true
|
132
|
+
homepage: http://github.com/benalavi/casper
|
133
|
+
licenses: []
|
134
|
+
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
hash: 3
|
146
|
+
segments:
|
147
|
+
- 0
|
148
|
+
version: "0"
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
hash: 3
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
version: "0"
|
158
|
+
requirements: []
|
159
|
+
|
160
|
+
rubyforge_project: casper
|
161
|
+
rubygems_version: 1.3.7
|
162
|
+
signing_key:
|
163
|
+
specification_version: 3
|
164
|
+
summary: A DSL for automated mouse and keyboard input in X11.
|
165
|
+
test_files: []
|
166
|
+
|