ghostbuster 0.3.7 → 0.3.9
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 +6 -0
- data/Rakefile +1 -1
- data/lib/ghostbuster.coffee +25 -0
- data/lib/ghostbuster/version.rb +1 -1
- data/test/server1/views/form.erb +5 -0
- data/test/working_ghost/test_ghost.coffee +7 -0
- metadata +4 -4
data/README.md
CHANGED
@@ -135,6 +135,12 @@ If no path option is given, it will merely assert that the location changed.
|
|
135
135
|
|
136
136
|
This will fill in the matching form elements with the text given.
|
137
137
|
|
138
|
+
### select
|
139
|
+
|
140
|
+
*Arguments*: selector, newValue
|
141
|
+
|
142
|
+
This will set a select box to a given value
|
143
|
+
|
138
144
|
### wait
|
139
145
|
|
140
146
|
*Arguments*: seconds, callback
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ namespace :test do
|
|
8
8
|
task task_name do
|
9
9
|
print "#{task_name} ... "
|
10
10
|
Dir.chdir("test/working_ghost") do
|
11
|
-
matcher = [/
|
11
|
+
matcher = [/14 success, 0 failure, 1 pending/]
|
12
12
|
fork {
|
13
13
|
ENV['BUNDLE_GEMFILE'] = File.expand_path("./Gemfile")
|
14
14
|
`bundle install`
|
data/lib/ghostbuster.coffee
CHANGED
@@ -132,6 +132,31 @@ class Body
|
|
132
132
|
"
|
133
133
|
@test.page.evaluate(input)
|
134
134
|
|
135
|
+
select: (selector, newValue, opts) ->
|
136
|
+
opts ||= {}
|
137
|
+
test = @test
|
138
|
+
@test.assert opts, (withValue) ->
|
139
|
+
idx = opts.index || 0
|
140
|
+
eval "
|
141
|
+
var evaluator = function() {
|
142
|
+
var targets = document.querySelectorAll('#{selector}'),
|
143
|
+
idx = #{idx},
|
144
|
+
evt = document.createEvent('MutationEvents'),
|
145
|
+
newValue = '#{newValue}';
|
146
|
+
if (idx < targets.length) {
|
147
|
+
evt.initMutationEvent('change', true, true, window, targets[idx].value, newValue, 'value', MutationEvent.MODIFICATION);
|
148
|
+
targets[idx].value = newValue;
|
149
|
+
targets[idx].dispatchEvent(evt);
|
150
|
+
return true;
|
151
|
+
} else {
|
152
|
+
alert('Couldn\\'t find element #{idx} for selector #{selector}');
|
153
|
+
return false;
|
154
|
+
}
|
155
|
+
};
|
156
|
+
"
|
157
|
+
withValue @page.evaluate(evaluator)
|
158
|
+
|
159
|
+
|
135
160
|
click: (selector, opts) ->
|
136
161
|
opts ||= {}
|
137
162
|
test = @test
|
data/lib/ghostbuster/version.rb
CHANGED
data/test/server1/views/form.erb
CHANGED
@@ -6,6 +6,11 @@
|
|
6
6
|
<form>
|
7
7
|
<input type="text" id="in">
|
8
8
|
<input type="button" id="btn" onclick="document.getElementById('out').innerHTML = document.getElementById('in').value;">
|
9
|
+
<select id="sel" onchange="document.getElementById('out').innerHTML = document.getElementById('sel').value">
|
10
|
+
<option value="test">test</option>
|
11
|
+
<option value="test2">test2</option>
|
12
|
+
<option value="test3">test3</option>
|
13
|
+
</select>
|
9
14
|
</form>
|
10
15
|
<p id="out"></p>
|
11
16
|
</body>
|
@@ -25,6 +25,13 @@ phantom.test.add "Form input", ->
|
|
25
25
|
out.innerHTML == 'this is my input'
|
26
26
|
@succeed()
|
27
27
|
|
28
|
+
phantom.test.add "Select box input", ->
|
29
|
+
@get '/form', ->
|
30
|
+
@body.select "#sel", "test3"
|
31
|
+
@body.assertFirst '#out', (out) ->
|
32
|
+
out.innerHTML == 'test3'
|
33
|
+
@succeed()
|
34
|
+
|
28
35
|
phantom.test.add "Link traversal", ->
|
29
36
|
@get '/', ->
|
30
37
|
@body.click 'a'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghostbuster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 9
|
10
|
+
version: 0.3.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Josh Hull
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-11-03 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|