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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ce1815fb5ecd5df03042ee7a5397339bc2f240a3
4
- data.tar.gz: 73720085f120a27120f67bb0eeb8b2418ca4eccd
3
+ metadata.gz: 6740212641a3522f8954bc1780fc8e8ffe9a24e7
4
+ data.tar.gz: 540c13321035accfb11835d5b167ba4c80c3e89b
5
5
  SHA512:
6
- metadata.gz: 4951c5067482ad3de6a6757cd5c31205b020932acb4ed9ac51b7c132a4ceb36e4353015ca10394018f8dd8b65ebfd23f8b553734baa3ed8d3b562c2db06a26df
7
- data.tar.gz: 66e4149bd2111fc289535a6c35f9fba6e710acfe72968c61a43cebcdd3c1e60bbf88350df14952a2b4bbefa1099aff597556ab29ff2f3eab33a38f265293eb8c
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 #{File.join('test', 'extension')} #{File.join('test', 'extension.bxt.manual')}"
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 #{File.join('test', 'default_selector.bxt.manual')}"
48
+ ruby "-Ilib bin/bauxite -v -s css test/default_selector.bxt.manual"
49
49
 
50
- system("ruby -Ilib bin/bauxite #{File.join('test', 'test.bxt.manual')}")
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 ========================================================= #
@@ -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"># =&gt; 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"># =&gt; 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">&#39;__CAPTURE_SEQ__&#39;</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">&#39;__TEST__&#39;</span>]
561
+ <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-string">&#39;__CAPTURE_SEQ__&#39;</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">&quot;#{@ctx.variables[&#39;__FILE__&#39;]}_#{seq}&quot;</span>
564
+ <span class="ruby-identifier">file</span> = <span class="ruby-node">&quot;#{test}_#{file}&quot;</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">&#39;_&#39;</span>) <span class="ruby-operator">+</span> <span class="ruby-string">&#39;.png&#39;</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">&#39;__OUTPUT__&#39;</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">&#39;__CAPTURE__&#39;</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-keyword">if</span> <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">try_exec_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>)
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">&#39;__TIMEOUT__&#39;</span> =<span class="ruby-operator">&gt;</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">&quot;Assertion did not failed as expected:#{action} #{args.join(&#39; &#39;)}&quot;</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">&quot;/John/i&quot;</span> <span class="ruby-string">&quot;${name}&quot;</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"># =&gt; 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">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">try_exec_action</span>(<span class="ruby-identifier">action</span>, <span class="ruby-identifier">args</span>)
1355
- <span class="ruby-ivar">@ctx</span>.<span class="ruby-identifier">variables</span>[<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">value</span>
1356
- <span class="ruby-keyword">true</span>
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">&#39;ERROR&#39;</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">&#39;__RAISE_ERROR__&#39;</span> =<span class="ruby-operator">&gt;</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">&#39;__RAISE_ERROR__&#39;</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-string">&#39;__TEST__&#39;</span> =<span class="ruby-operator">&gt;</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">&#39;OK&#39;</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">&gt;</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">&lt;&lt;</span> {
1554
- <span class="ruby-value">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">file</span>,
1637
+ <span class="ruby-value">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">name</span>,
1555
1638
  <span class="ruby-value">:status</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">status</span>,
1556
1639
  <span class="ruby-value">:time</span> =<span class="ruby-operator">&gt;</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">&gt;</span> <span class="ruby-identifier">error</span>