bauxite 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +20 -3
- data/doc/Bauxite/Action.html +92 -9
- data/doc/Bauxite/Context.html +63 -144
- data/doc/created.rid +8 -7
- data/doc/js/search_index.js +1 -1
- data/doc/table_of_contents.html +37 -37
- data/lib/bauxite/actions/capture.rb +66 -0
- data/lib/bauxite/actions/debug.rb +3 -1
- data/lib/bauxite/actions/failif.rb +8 -2
- data/lib/bauxite/actions/setif.rb +8 -4
- data/lib/bauxite/actions/test.rb +4 -3
- data/lib/bauxite/application.rb +16 -2
- data/lib/bauxite/core/context.rb +37 -88
- data/lib/bauxite.rb +1 -1
- data/test/capture/my_test.bxt +1 -0
- data/test/capture/page.html +7 -0
- data/test/capture.bxt.manual +20 -0
- data/test/debug.bxt.manual +1 -0
- data/test/failif/page.html +2 -1
- data/test/failif.bxt +1 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6740212641a3522f8954bc1780fc8e8ffe9a24e7
|
4
|
+
data.tar.gz: 540c13321035accfb11835d5b167ba4c80c3e89b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 151a8a6101170a95086868fea855898e3215cd57a2d3645e07549f4e6a44dd7af852eab6aeff691cb24a1cd11f49009b13238a57b5b06e45d6ea674039137008
|
7
|
+
data.tar.gz: a04566f762e65defa0efd70b3024363623237c0fffe1f940fb29daf81a19ceb049006fd5bdd5e56da53faf58730b919bed094470d7ce4f2e4bca85b49170723f
|
data/Rakefile
CHANGED
@@ -43,12 +43,29 @@ task :test do
|
|
43
43
|
test_files = Dir[File.join('test', '*.bxt')].select { |f| not File.directory? f }.join(' ')
|
44
44
|
ruby "-Ilib bin/bauxite -v #{test_files}"
|
45
45
|
|
46
|
-
ruby "-Ilib bin/bauxite -v -e
|
46
|
+
ruby "-Ilib bin/bauxite -v -e test/extension #{File.join('test', 'extension.bxt.manual')}"
|
47
47
|
|
48
|
-
ruby "-Ilib bin/bauxite -v -s css
|
48
|
+
ruby "-Ilib bin/bauxite -v -s css test/default_selector.bxt.manual"
|
49
49
|
|
50
|
-
system("ruby -Ilib bin/bauxite
|
50
|
+
system("ruby -Ilib bin/bauxite test/test.bxt.manual")
|
51
51
|
fail "The 'test' action test failed to return the expected exit status: the exit status was #{$?.exitstatus}" unless $?.exitstatus == 2
|
52
|
+
|
53
|
+
debug = `echo exit | ruby -Ilib bin/bauxite -l echo test/debug.bxt.manual -d`
|
54
|
+
puts debug
|
55
|
+
unless debug.include? 'debug> exit'
|
56
|
+
fail "The -d argument failed to open the debug console"
|
57
|
+
end
|
58
|
+
|
59
|
+
system('rm -rf /tmp/bauxite-test')
|
60
|
+
ruby "-Ilib bin/bauxite test/capture.bxt.manual --output /tmp/bauxite-test"
|
61
|
+
check = lambda { |f| fail "Captured file not found #{f}" unless File.exists? f }
|
62
|
+
check.call '/tmp/bauxite-test/test_capture_bxt_manual_0.png'
|
63
|
+
check.call '/tmp/bauxite-test/test_capture_bxt_manual_1.png'
|
64
|
+
check.call '/tmp/bauxite-test/test_capture_bxt_manual_2.png'
|
65
|
+
check.call '/tmp/bauxite-test/with_name.png'
|
66
|
+
check.call '/tmp/bauxite-test/capture_my_test_bxt_test_capture_my_test_bxt_3.png'
|
67
|
+
check.call '/tmp/bauxite-test/named_test_test_capture_my_test_bxt_3.png'
|
68
|
+
|
52
69
|
end
|
53
70
|
|
54
71
|
# === Documentation ========================================================= #
|
data/doc/Bauxite/Action.html
CHANGED
@@ -103,6 +103,8 @@
|
|
103
103
|
|
104
104
|
<li ><a href="#method-i-break_action">#break_action</a>
|
105
105
|
|
106
|
+
<li ><a href="#method-i-capture">#capture</a>
|
107
|
+
|
106
108
|
<li ><a href="#method-i-click">#click</a>
|
107
109
|
|
108
110
|
<li ><a href="#method-i-debug">#debug</a>
|
@@ -513,6 +515,76 @@ break_action.</p>
|
|
513
515
|
|
514
516
|
|
515
517
|
|
518
|
+
</div>
|
519
|
+
|
520
|
+
|
521
|
+
<div id="method-i-capture" class="method-detail ">
|
522
|
+
|
523
|
+
<div class="method-heading">
|
524
|
+
<span class="method-name">capture</span><span
|
525
|
+
class="method-args">(file = nil)</span>
|
526
|
+
|
527
|
+
<span class="method-click-advice">click to toggle source</span>
|
528
|
+
|
529
|
+
</div>
|
530
|
+
|
531
|
+
|
532
|
+
<div class="method-description">
|
533
|
+
|
534
|
+
<p>Captures a screenshot of the current browser window and saves it with
|
535
|
+
specified <code>file</code> name. If <code>file</code> is omitted a file
|
536
|
+
name will be generated based on the value of <code>__TEST__</code>,
|
537
|
+
<code>__FILE__</code> and <code><em>CAPTURE_SEQ</em></code>. If set, the
|
538
|
+
value of <code>__OUTPUT__</code> will be prefixed to <code>file</code>
|
539
|
+
(unless <code>file</code> is an absolute path). The last captured file name
|
540
|
+
will be stored in <code>__CAPTURE__</code>.</p>
|
541
|
+
|
542
|
+
<p>For example:</p>
|
543
|
+
|
544
|
+
<pre class="ruby"><span class="ruby-identifier">capture</span>
|
545
|
+
<span class="ruby-comment"># => this would capture the screenshot with a generated file name.</span>
|
546
|
+
|
547
|
+
<span class="ruby-identifier">capture</span> <span class="ruby-identifier">my_file</span>.<span class="ruby-identifier">png</span>
|
548
|
+
<span class="ruby-comment"># => this would capture the screenshot to my_file.png in the current</span>
|
549
|
+
<span class="ruby-comment"># working directory.</span>
|
550
|
+
</pre>
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
<div class="method-source-code" id="capture-source">
|
556
|
+
<pre><span class="ruby-comment"># File lib/bauxite/actions/capture.rb, line 42</span>
|
557
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">capture</span>(<span class="ruby-identifier">file</span> = <span class="ruby-keyword">nil</span>)
|
558
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">file</span>
|
559
|
+
<span class="ruby-identifier">seq</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__CAPTURE_SEQ__'</span>] <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
|
560
|
+
<span class="ruby-identifier">test</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__TEST__'</span>]
|
561
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__CAPTURE_SEQ__'</span>] = <span class="ruby-identifier">seq</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
|
562
|
+
|
563
|
+
<span class="ruby-identifier">file</span> = <span class="ruby-node">"#{@ctx.variables['__FILE__']}_#{seq}"</span>
|
564
|
+
<span class="ruby-identifier">file</span> = <span class="ruby-node">"#{test}_#{file}"</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">test</span>
|
565
|
+
<span class="ruby-identifier">file</span> = <span class="ruby-identifier">file</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/[^A-Z0-9_-]/i</span>, <span class="ruby-string">'_'</span>) <span class="ruby-operator">+</span> <span class="ruby-string">'.png'</span>
|
566
|
+
<span class="ruby-keyword">end</span>
|
567
|
+
|
568
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-constant">Pathname</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">file</span>).<span class="ruby-identifier">absolute?</span>
|
569
|
+
<span class="ruby-identifier">output</span> = <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__OUTPUT__'</span>]
|
570
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">output</span>
|
571
|
+
<span class="ruby-constant">Dir</span>.<span class="ruby-identifier">mkdir</span> <span class="ruby-identifier">output</span> <span class="ruby-keyword">unless</span> <span class="ruby-constant">Dir</span>.<span class="ruby-identifier">exists?</span> <span class="ruby-identifier">output</span>
|
572
|
+
<span class="ruby-identifier">file</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-identifier">output</span>, <span class="ruby-identifier">file</span>)
|
573
|
+
<span class="ruby-keyword">end</span>
|
574
|
+
<span class="ruby-keyword">end</span>
|
575
|
+
|
576
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">driver</span>.<span class="ruby-identifier">save_screenshot</span>(<span class="ruby-identifier">file</span>)
|
577
|
+
|
578
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">'__CAPTURE__'</span>] = <span class="ruby-identifier">file</span>
|
579
|
+
<span class="ruby-keyword">true</span>
|
580
|
+
<span class="ruby-keyword">end</span></pre>
|
581
|
+
</div>
|
582
|
+
|
583
|
+
</div>
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
|
516
588
|
</div>
|
517
589
|
|
518
590
|
|
@@ -793,10 +865,16 @@ href="Action.html#method-i-test">test</a>, etc.) is undefined.</p>
|
|
793
865
|
<div class="method-source-code" id="failif-source">
|
794
866
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/failif.rb, line 40</span>
|
795
867
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">failif</span>(<span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
796
|
-
<span class="ruby-
|
868
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_timeout</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span> <span class="ruby-keyword">do</span>
|
869
|
+
<span class="ruby-keyword">begin</span>
|
870
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_vars</span>({ <span class="ruby-string">'__TIMEOUT__'</span> =<span class="ruby-operator">></span> <span class="ruby-value">0</span>}) <span class="ruby-keyword">do</span>
|
871
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">exec_parsed_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>, <span class="ruby-keyword">false</span>)
|
872
|
+
<span class="ruby-keyword">end</span>
|
873
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>
|
874
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>
|
875
|
+
<span class="ruby-keyword">end</span>
|
797
876
|
<span class="ruby-identifier">raise</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>, <span class="ruby-node">"Assertion did not failed as expected:#{action} #{args.join(' ')}"</span>
|
798
877
|
<span class="ruby-keyword">end</span>
|
799
|
-
<span class="ruby-keyword">true</span>
|
800
878
|
<span class="ruby-keyword">end</span></pre>
|
801
879
|
</div>
|
802
880
|
|
@@ -1341,7 +1419,7 @@ execution fails, the value of <code>name</code> is left unchanged.</p>
|
|
1341
1419
|
|
1342
1420
|
<pre class="ruby"><span class="ruby-identifier">set</span> <span class="ruby-identifier">name</span> <span class="ruby-identifier">john</span>
|
1343
1421
|
<span class="ruby-identifier">setif</span> <span class="ruby-identifier">is_john</span> <span class="ruby-keyword">true</span> <span class="ruby-identifier">assertv</span> <span class="ruby-string">"/John/i"</span> <span class="ruby-string">"${name}"</span>
|
1344
|
-
<span class="ruby-identifier">assertv</span> <span class="ruby-keyword">true</span> ${<span class="ruby-identifier">is_john</span>
|
1422
|
+
<span class="ruby-identifier">assertv</span> <span class="ruby-keyword">true</span> ${<span class="ruby-identifier">is_john</span>}
|
1345
1423
|
<span class="ruby-comment"># => the assertion would pass</span>
|
1346
1424
|
</pre>
|
1347
1425
|
|
@@ -1351,9 +1429,13 @@ execution fails, the value of <code>name</code> is left unchanged.</p>
|
|
1351
1429
|
<div class="method-source-code" id="setif-source">
|
1352
1430
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/setif.rb, line 35</span>
|
1353
1431
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">setif</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">action</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
|
1354
|
-
<span class="ruby-keyword">
|
1355
|
-
|
1356
|
-
|
1432
|
+
<span class="ruby-keyword">begin</span>
|
1433
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">exec_parsed_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>, <span class="ruby-keyword">false</span>)
|
1434
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span>
|
1435
|
+
<span class="ruby-keyword">true</span>
|
1436
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">Bauxite</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">AssertionError</span>
|
1437
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span>
|
1438
|
+
<span class="ruby-keyword">end</span>
|
1357
1439
|
<span class="ruby-keyword">end</span></pre>
|
1358
1440
|
</div>
|
1359
1441
|
|
@@ -1537,21 +1619,22 @@ the execution continues with the next test context (if any).</p>
|
|
1537
1619
|
<pre><span class="ruby-comment"># File lib/bauxite/actions/test.rb, line 37</span>
|
1538
1620
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">test</span>(<span class="ruby-identifier">file</span>, <span class="ruby-identifier">name</span> = <span class="ruby-keyword">nil</span>)
|
1539
1621
|
<span class="ruby-identifier">delayed</span> = <span class="ruby-identifier">load</span>(<span class="ruby-identifier">file</span>)
|
1540
|
-
|
1622
|
+
<span class="ruby-identifier">name</span> = <span class="ruby-identifier">name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">file</span>
|
1541
1623
|
<span class="ruby-identifier">lambda</span> <span class="ruby-keyword">do</span>
|
1542
1624
|
<span class="ruby-keyword">begin</span>
|
1543
1625
|
<span class="ruby-identifier">t</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>
|
1544
1626
|
<span class="ruby-identifier">status</span> = <span class="ruby-string">'ERROR'</span>
|
1545
1627
|
<span class="ruby-identifier">error</span> = <span class="ruby-keyword">nil</span>
|
1546
|
-
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_vars</span>({ <span class="ruby-string">'__RAISE_ERROR__'</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">true</span> }) <span class="ruby-keyword">do</span>
|
1628
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">with_vars</span>({ <span class="ruby-string">'__RAISE_ERROR__'</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">true</span>, <span class="ruby-string">'__TEST__'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">name</span> }) <span class="ruby-keyword">do</span>
|
1547
1629
|
<span class="ruby-identifier">delayed</span>.<span class="ruby-identifier">call</span>
|
1548
1630
|
<span class="ruby-identifier">status</span> = <span class="ruby-string">'OK'</span>
|
1549
1631
|
<span class="ruby-keyword">end</span>
|
1550
1632
|
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">StandardError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
1633
|
+
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">print_error</span>(<span class="ruby-identifier">e</span>)
|
1551
1634
|
<span class="ruby-identifier">error</span> = <span class="ruby-identifier">e</span>
|
1552
1635
|
<span class="ruby-keyword">ensure</span>
|
1553
1636
|
<span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">tests</span> <span class="ruby-operator"><<</span> {
|
1554
|
-
<span class="ruby-value">:name</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">name</span
|
1637
|
+
<span class="ruby-value">:name</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">name</span>,
|
1555
1638
|
<span class="ruby-value">:status</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">status</span>,
|
1556
1639
|
<span class="ruby-value">:time</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">t</span>,
|
1557
1640
|
<span class="ruby-value">:error</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">error</span>
|