win_gui 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) hide show
  1. data/.gitignore +21 -21
  2. data/HISTORY +7 -0
  3. data/LICENSE +20 -20
  4. data/README.rdoc +77 -114
  5. data/Rakefile +24 -58
  6. data/VERSION +1 -1
  7. data/features/support/env.rb +7 -4
  8. data/features/win_gui.feature +9 -9
  9. data/lib/version.rb +8 -0
  10. data/lib/win_gui/window.rb +78 -69
  11. data/lib/win_gui.rb +25 -3
  12. data/spec/spec.opts +1 -1
  13. data/spec/spec_helper.rb +90 -118
  14. data/spec/win_gui/window_spec.rb +120 -123
  15. data/tasks/common.rake +14 -0
  16. data/tasks/doc.rake +14 -0
  17. data/tasks/gem.rake +39 -0
  18. data/tasks/git.rake +34 -0
  19. data/tasks/spec.rake +19 -0
  20. data/tasks/version.rake +71 -0
  21. metadata +68 -188
  22. data/.document +0 -5
  23. data/book_code/early_success/bundle.rb +0 -34
  24. data/book_code/early_success/english.txt +0 -1
  25. data/book_code/early_success/jruby_basics.rb +0 -47
  26. data/book_code/early_success/windows_basics.rb +0 -97
  27. data/book_code/guessing/locknote.rb +0 -379
  28. data/book_code/guessing/monkeyshines.rb +0 -14
  29. data/book_code/guessing/note.rb +0 -120
  30. data/book_code/guessing/note_spec.rb +0 -175
  31. data/book_code/guessing/replay.rb +0 -21
  32. data/book_code/guessing/seed.rb +0 -9
  33. data/book_code/guessing/spec_helper.rb +0 -69
  34. data/book_code/guessing/windows_gui.rb +0 -247
  35. data/book_code/home_stretch/junquenote.rb +0 -151
  36. data/book_code/home_stretch/locknote.rb +0 -180
  37. data/book_code/home_stretch/note.rb +0 -144
  38. data/book_code/home_stretch/note_spec.rb +0 -191
  39. data/book_code/home_stretch/spec_helper.rb +0 -55
  40. data/book_code/home_stretch/swing_gui.rb +0 -50
  41. data/book_code/home_stretch/windows_gui.rb +0 -232
  42. data/book_code/junquenote/exports.sh +0 -10
  43. data/book_code/junquenote/jruby_mac.sh +0 -10
  44. data/book_code/junquenote/junquenote_app.rb +0 -262
  45. data/book_code/novite/Rakefile +0 -10
  46. data/book_code/novite/app/controllers/application.rb +0 -18
  47. data/book_code/novite/app/controllers/guests_controller.rb +0 -28
  48. data/book_code/novite/app/controllers/parties_controller.rb +0 -77
  49. data/book_code/novite/app/helpers/application_helper.rb +0 -11
  50. data/book_code/novite/app/helpers/guests_helper.rb +0 -10
  51. data/book_code/novite/app/helpers/parties_helper.rb +0 -10
  52. data/book_code/novite/app/models/guest.rb +0 -11
  53. data/book_code/novite/app/models/party.rb +0 -32
  54. data/book_code/novite/app/models/party_mailer.rb +0 -19
  55. data/book_code/novite/app/views/layouts/application.rhtml +0 -44
  56. data/book_code/novite/app/views/parties/new.html.erb +0 -42
  57. data/book_code/novite/app/views/parties/show.html.erb +0 -43
  58. data/book_code/novite/app/views/party_mailer/invite.erb +0 -17
  59. data/book_code/novite/config/boot.rb +0 -117
  60. data/book_code/novite/config/database.yml +0 -19
  61. data/book_code/novite/config/environment.rb +0 -67
  62. data/book_code/novite/config/environments/development.rb +0 -29
  63. data/book_code/novite/config/environments/production.rb +0 -27
  64. data/book_code/novite/config/environments/test.rb +0 -30
  65. data/book_code/novite/config/initializers/inflections.rb +0 -18
  66. data/book_code/novite/config/initializers/mime_types.rb +0 -13
  67. data/book_code/novite/config/routes.rb +0 -47
  68. data/book_code/novite/db/migrate/001_create_parties.rb +0 -26
  69. data/book_code/novite/db/migrate/002_create_guests.rb +0 -23
  70. data/book_code/novite/db/schema.rb +0 -41
  71. data/book_code/novite/log/empty.txt +0 -0
  72. data/book_code/novite/public/.htaccess +0 -40
  73. data/book_code/novite/public/404.html +0 -38
  74. data/book_code/novite/public/422.html +0 -38
  75. data/book_code/novite/public/500.html +0 -38
  76. data/book_code/novite/public/dispatch.cgi +0 -10
  77. data/book_code/novite/public/dispatch.fcgi +0 -24
  78. data/book_code/novite/public/dispatch.rb +0 -18
  79. data/book_code/novite/public/favicon.ico +0 -0
  80. data/book_code/novite/public/images/rails.png +0 -0
  81. data/book_code/novite/public/index.html +0 -285
  82. data/book_code/novite/public/javascripts/application.js +0 -10
  83. data/book_code/novite/public/javascripts/controls.js +0 -971
  84. data/book_code/novite/public/javascripts/dragdrop.js +0 -980
  85. data/book_code/novite/public/javascripts/effects.js +0 -1128
  86. data/book_code/novite/public/javascripts/prototype.js +0 -4233
  87. data/book_code/novite/public/robots.txt +0 -5
  88. data/book_code/novite/script/about +0 -3
  89. data/book_code/novite/script/console +0 -3
  90. data/book_code/novite/script/destroy +0 -3
  91. data/book_code/novite/script/generate +0 -3
  92. data/book_code/novite/script/performance/benchmarker +0 -3
  93. data/book_code/novite/script/performance/profiler +0 -3
  94. data/book_code/novite/script/performance/request +0 -3
  95. data/book_code/novite/script/plugin +0 -3
  96. data/book_code/novite/script/process/inspector +0 -3
  97. data/book_code/novite/script/process/reaper +0 -3
  98. data/book_code/novite/script/process/spawner +0 -3
  99. data/book_code/novite/script/runner +0 -3
  100. data/book_code/novite/script/server +0 -3
  101. data/book_code/novite/test/test_helper.rb +0 -46
  102. data/book_code/one_more_thing/applescript.rb +0 -68
  103. data/book_code/one_more_thing/note_spec.rb +0 -50
  104. data/book_code/one_more_thing/spec_helper.rb +0 -17
  105. data/book_code/one_more_thing/textedit-pure.rb +0 -28
  106. data/book_code/one_more_thing/textedit.applescript +0 -26
  107. data/book_code/one_more_thing/textedit.rb +0 -32
  108. data/book_code/one_more_thing/textnote.rb +0 -87
  109. data/book_code/simplify/junquenote.rb +0 -48
  110. data/book_code/simplify/locknote.rb +0 -46
  111. data/book_code/simplify/note.rb +0 -35
  112. data/book_code/simplify/note_spec.rb +0 -28
  113. data/book_code/simplify/swing_gui.rb +0 -45
  114. data/book_code/simplify/windows_gui.rb +0 -232
  115. data/book_code/simplify/windows_gui_spec.rb +0 -35
  116. data/book_code/story/invite.story +0 -19
  117. data/book_code/story/journal.txt +0 -29
  118. data/book_code/story/novite_stories.rb +0 -156
  119. data/book_code/story/party.rb +0 -149
  120. data/book_code/story/password.rb +0 -61
  121. data/book_code/story/password.story +0 -26
  122. data/book_code/story/rsvp.story +0 -29
  123. data/book_code/tables/TestTime.html +0 -93
  124. data/book_code/tables/TestTimeSample.html +0 -63
  125. data/book_code/tables/calculate_time.rb +0 -39
  126. data/book_code/tables/calculator.rb +0 -108
  127. data/book_code/tables/calculator_actions.rb +0 -27
  128. data/book_code/tables/calculator_spec.rb +0 -47
  129. data/book_code/tables/fit.rb +0 -32
  130. data/book_code/tables/matrix.rb +0 -109
  131. data/book_code/tables/pseudocode.rb +0 -17
  132. data/book_code/tubes/book_selenium.rb +0 -67
  133. data/book_code/tubes/book_watir.rb +0 -60
  134. data/book_code/tubes/dragdrop.html +0 -81
  135. data/book_code/tubes/html_capture.rb +0 -33
  136. data/book_code/tubes/joke_list.rb +0 -67
  137. data/book_code/tubes/list_spec.rb +0 -41
  138. data/book_code/tubes/search_spec.rb +0 -32
  139. data/book_code/tubes/selenium_example.rb +0 -66
  140. data/book_code/tubes/selenium_link.rb +0 -23
  141. data/book_code/tubes/web_server.rb +0 -14
  142. data/book_code/windows/wgui.rb +0 -29
  143. data/book_code/windows/wobj.rb +0 -25
  144. data/book_code/windows/wsh.rb +0 -25
  145. data/book_code/with_rspec/empty_spec.rb +0 -13
  146. data/book_code/with_rspec/junquenote.rb +0 -60
  147. data/book_code/with_rspec/locknote.rb +0 -129
  148. data/book_code/with_rspec/note_spec.rb +0 -32
  149. data/book_code/with_rspec/should_examples.rb +0 -18
  150. data/lib/note/java/jemmy.jar +0 -0
  151. data/lib/note/java/jnote.rb +0 -48
  152. data/lib/note/java/jruby_basics.rb +0 -37
  153. data/lib/note/java/junquenote_app.rb +0 -262
  154. data/lib/note/java/note_spec.rb +0 -20
  155. data/lib/note/win/locknote.rb +0 -19
  156. data/lib/note.rb +0 -15
  157. data/lib/win_gui/constants.rb +0 -82
  158. data/lib/win_gui/def_api.rb +0 -160
  159. data/lib/win_gui/string_extensions.rb +0 -36
  160. data/lib/win_gui/win_gui.rb +0 -437
  161. data/old/windows_basics.rb +0 -80
  162. data/old/wnote.rb +0 -80
  163. data/old/wnote_spec.rb +0 -20
  164. data/spec/note/win/locknote_spec.rb +0 -7
  165. data/spec/test_apps/locknote/LockNote.exe +0 -0
  166. data/spec/win_gui/def_api_spec.rb +0 -339
  167. data/spec/win_gui/string_extensions_spec.rb +0 -61
  168. data/spec/win_gui/win_gui_spec.rb +0 -537
  169. data/win_gui.gemspec +0 -215
@@ -1,29 +0,0 @@
1
- # START:rsvp_story
2
- Story: minimalist RSVPs
3
- As a guest with lots to do
4
- I want to RSVP to an invite with a minimum of mouse clicks
5
- So that I can get on with the rest of my tasks
6
- # END:rsvp_story
7
-
8
- # START:email_free
9
- Scenario: email-free RSVPs
10
- Given a party called "a disco anniversary"
11
- When I view the invitation
12
- Then I should see the party details
13
-
14
- When I answer that "Robert Bell" will not attend
15
- Then I should see "Robert Bell" in the list of decliners
16
- # END:email_free
17
-
18
- # START:rsvp_email
19
- Scenario: RSVP links from email
20
- Given a party called "a salute to e-mail"
21
- And a guest list of "one@example.com,two@example.com"
22
- When I view the invitation
23
- Then I should see that e-mail was sent to "one@example.com,two@example.com"
24
-
25
- When I view the e-mail that was sent to "one@example.com"
26
- Then I should see "Yes/No" links
27
- When I follow the "Yes" link
28
- Then I should see "one@example.com" in the list of partygoers
29
- # END:rsvp_email
@@ -1,93 +0,0 @@
1
- <!--
2
- ! Excerpted from "Scripted GUI Testing With Ruby",
3
- ! published by The Pragmatic Bookshelf.
4
- ! Copyrights apply to this code. It may not be used to create training material,
5
- ! courses, books, articles, and the like. Contact us if you are in doubt.
6
- ! We make no guarantees that this code is fit for any purpose.
7
- ! Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- -->
9
- <html>
10
-
11
- <head>
12
- <title>Calculator Test</title>
13
- <style type="text/css">
14
- table {
15
- background: silver;
16
- margin: 2px;
17
- padding: 0px;
18
- border: solid grey;
19
- border-width: 1px 0px 0px 1px;
20
- }
21
-
22
- td {
23
- border: solid grey;
24
- border-width: 0px 1px 1px 0px;
25
- padding: 1px 3px 1px 3px;
26
- }
27
- </style>
28
- </head>
29
-
30
- <body>
31
-
32
- <table border="1">
33
- <tbody>
34
- <tr><td colspan="3">fit.ActionFixture</td></tr>
35
- <tr><td>start</td><td colspan="2">CalculatorActions</td></tr>
36
- <tr><td>enter</td><td>number</td><td>2</td></tr>
37
- <tr><td>press</td><td colspan="2">plus</td></tr>
38
- <tr><td>enter</td><td>number</td><td>3</td></tr>
39
- <tr><td>press</td><td colspan="2">equals</td></tr>
40
- <tr><td>check</td><td>total_seconds</td><td>5</td></tr>
41
- </tbody>
42
- </table>
43
-
44
- <hr>
45
-
46
- <table border="1">
47
- <tbody>
48
- <tr><td colspan="8">CalculateTime</td></tr>
49
- <tr>
50
- <td><em>days</em></td>
51
- <td><em>hours</em></td>
52
- <td><em>mins</em></td>
53
- <td><em>secs</em></td>
54
-
55
- <td><em>days()</em></td>
56
- <td><em>hours()</em></td>
57
- <td><em>mins()</em></td>
58
- <td><em>secs()</em></td>
59
- </tr>
60
-
61
- <tr>
62
- <td>1</td><td>47</td><td>59</td><td>59</td>
63
- <td>2</td><td>23</td><td>59</td><td>59</td>
64
- </tr>
65
- <tr>
66
- <td>1</td><td>47</td><td>59</td><td>60</td>
67
- <td>3</td><td>0</td><td>0</td><td>0</td>
68
- </tr>
69
- <tr>
70
- <td>1</td><td>47</td><td>59</td><td>61</td>
71
- <td>3</td><td>0</td><td>0</td><td>1</td>
72
- </tr>
73
- <tr>
74
- <td>0</td><td>0</td><td>0</td><td>86399</td>
75
- <td>0</td><td>23</td><td>59</td><td>59</td>
76
- </tr>
77
- <tr>
78
- <td>0</td><td>0</td><td>0</td><td>86400</td>
79
- <td>1</td><td>0</td><td>0</td><td>0</td>
80
- </tr>
81
- <tr>
82
- <td>0</td><td>0</td><td>0</td><td>86401</td>
83
- <td>1</td><td>0</td><td>0</td><td>1</td>
84
- </tr>
85
- <tr>
86
- <td>0</td><td>0</td><td>0</td><td>9223372036854775807</td>
87
- <td>106751991167300</td><td>15</td><td>30</td><td>7</td>
88
- </tr>
89
- </tbody>
90
- </table>
91
-
92
- </body>
93
- </html>
@@ -1,63 +0,0 @@
1
- <!--
2
- ! Excerpted from "Scripted GUI Testing With Ruby",
3
- ! published by The Pragmatic Bookshelf.
4
- ! Copyrights apply to this code. It may not be used to create training material,
5
- ! courses, books, articles, and the like. Contact us if you are in doubt.
6
- ! We make no guarantees that this code is fit for any purpose.
7
- ! Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- -->
9
- <html>
10
-
11
- <head>
12
- <title>Calculator Test</title>
13
- <style type="text/css">
14
- table {
15
- background: silver;
16
- margin: 2px;
17
- padding: 0px;
18
- border: solid grey;
19
- border-width: 1px 0px 0px 1px;
20
- }
21
-
22
- td {
23
- border: solid grey;
24
- border-width: 0px 1px 1px 0px;
25
- padding: 1px 3px 1px 3px;
26
- }
27
- </style>
28
- </head>
29
-
30
- <body>
31
-
32
-
33
- <table border="1">
34
- <tbody>
35
- <tr><td colspan="8">CalculateTime</td></tr>
36
- <tr> <!-- (1) -->
37
- <td><em>days</em></td>
38
- <td><em>hours</em></td>
39
- <td><em>mins</em></td>
40
- <td><em>secs</em></td>
41
-
42
- <td><em>days()</em></td>
43
- <td><em>hours()</em></td>
44
- <td><em>mins()</em></td>
45
- <td><em>secs()</em></td>
46
- </tr>
47
-
48
- <tr>
49
- <td>1</td> <td>47</td> <td>59</td> <td>59</td>
50
- <td>2</td> <td>23</td> <td>59</td> <td>59</td>
51
- </tr>
52
- <tr>
53
- <td>1</td> <td>47</td> <td>59</td> <td>60</td>
54
- <td>3</td> <td>0</td> <td>0</td> <td>0</td>
55
- </tr>
56
-
57
- <!-- ... and so on -->
58
- </tbody>
59
- </table>
60
-
61
-
62
- </body>
63
- </html>
@@ -1,39 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- require 'rubygems'
10
-
11
-
12
- require 'fit/column_fixture'
13
- require 'calculator'
14
-
15
- class CalculateTime < Fit::ColumnFixture
16
- def initialize
17
- @calc = Calculator.single
18
- @days = @hours = @mins = @secs = nil
19
- end
20
- end
21
-
22
-
23
-
24
- class CalculateTime
25
- attr_accessor :days, :hours, :mins
26
- attr_reader :secs
27
-
28
- def secs=(value)
29
- @secs = value
30
-
31
- @calc.enter_time @days, @hours, @mins, @secs
32
- @calc.plus
33
- @calc.enter_number 0
34
- @calc.equals
35
-
36
- @days, @hours, @mins, @secs = @calc.time
37
- end
38
- end
39
-
@@ -1,108 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- require 'java'
10
- require 'jemmy.jar'
11
-
12
- $CLASSPATH << '.'
13
- include_class 'org.crocodile.timecalc.TimeCalcApp'
14
- include_class 'org.netbeans.jemmy.JemmyProperties'
15
- include_class 'org.netbeans.jemmy.TestOut'
16
-
17
- %w(Frame Label Button).each do |o|
18
- include_class "org.netbeans.jemmy.operators.#{o}Operator"
19
- end
20
-
21
- JemmyProperties.set_current_timeout 'DialogWaiter.WaitFrameTimeout', 3000
22
- JemmyProperties.set_current_output TestOut.get_null_output
23
-
24
- class Calculator
25
- def initialize
26
- TimeCalcApp.main nil
27
-
28
- @main_window = FrameOperator.new 'Time Calc'
29
- @result = LabelOperator.new @main_window
30
-
31
- keys = (0..9).to_a + [:days, :hours,
32
- :minutes, :seconds,
33
- :help, :off,
34
- '+', '-', '*', '/',
35
- '=', 'C']
36
-
37
- @buttons = {}
38
- keys.each do |k|
39
- @buttons[k] = ButtonOperator.new @main_window, k.to_s.capitalize
40
- end
41
- end
42
-
43
- def clear
44
- @buttons['C'].push
45
- end
46
-
47
- def plus
48
- @buttons['+'].push
49
- end
50
-
51
- def equals
52
- @buttons['='].push
53
- sleep 0.5
54
- end
55
-
56
- def off
57
- @buttons[:off].push
58
- end
59
-
60
- def enter_number(number)
61
- number.to_i.to_s.split(//).each do |n|
62
- @buttons[n.to_i].push
63
- end
64
- end
65
-
66
- def enter_time(days, hours, minutes, seconds)
67
- numbers = [days, hours, minutes, seconds]
68
- units = [:days, :hours, :minutes, :seconds]
69
- skip = true
70
-
71
- numbers.each_with_index do |number, index|
72
- skip &&= (0 == number)
73
-
74
- unless skip
75
- enter_number(number)
76
- @buttons[units[index]].push
77
- end
78
- end
79
- end
80
-
81
- def time
82
- result = {}
83
-
84
- text = @result.text
85
- text.scan(/[0-9]+[dhms]/).collect do |part|
86
- number = part.to_i
87
- units = part[-1..-1]
88
- result[units] = number
89
- end
90
-
91
- ['d', 'h', 'm', 's'].map {|u| result[u] || 0}
92
- end
93
-
94
- def total_seconds
95
- multipliers = [86400, 3600, 60, 1]
96
- time.zip(multipliers).inject(0) do |total, part|
97
- total + part[0] * part[1]
98
- end
99
- end
100
-
101
- def self.single
102
- @@single ||= Calculator.new
103
- end
104
- end
105
-
106
- if __FILE__ == $0
107
- Calculator.new
108
- end
@@ -1,27 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
-
10
- require 'fit/fixture'
11
- require 'calculator'
12
-
13
- class CalculatorActions < Fit::Fixture
14
- def initialize
15
- @calc = Calculator.single
16
- end
17
-
18
- def number(value)
19
- @calc.enter_number value
20
- end
21
-
22
- [:plus, :equals, :total_seconds].each do |name|
23
- define_method(name) do
24
- @calc.send name
25
- end
26
- end
27
- end
@@ -1,47 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- require 'calculator'
10
-
11
- describe 'a new calculator', :shared => true do
12
- before do
13
- @calc = Calculator.single
14
- @calc.clear
15
- end
16
- end
17
-
18
- module AdditionHelper
19
- def add_and_check(number, result)
20
- @calc.enter_number number
21
- @calc.equals
22
- @calc.total_seconds.should == result
23
- end
24
- end
25
-
26
-
27
- describe 'Starting with 1' do
28
- include AdditionHelper
29
-
30
- it_should_behave_like 'a new calculator'
31
-
32
- before do
33
- @calc.enter_number 1
34
- @calc.plus
35
- end
36
-
37
- it 'should add 0 correctly' do
38
- add_and_check(0, 1)
39
- end
40
-
41
- it 'should add 1 correctly' do
42
- add_and_check(1, 2)
43
- end
44
-
45
- # two more nearly-identical examples
46
- end
47
-
@@ -1,32 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- require 'calculator'
10
-
11
- $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
12
-
13
- require 'rubygems'
14
- require 'fit/parse'
15
- require 'fit/file_runner'
16
-
17
- report = ARGV[1]
18
- unless report.nil?
19
- Fit::Parse.footnote_path = File.dirname(report) + File::SEPARATOR
20
- end
21
-
22
-
23
- class CalcRunner < Fit::FileRunner
24
- def run(args)
25
- process_args args
26
- process
27
- $stderr.puts @fixture.totals
28
- Calculator.single.off # will exit
29
- end
30
- end
31
-
32
- CalcRunner.new.run(ARGV)
@@ -1,109 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- require 'rubygems'
10
-
11
-
12
- require 'test/unit'
13
- require 'test/unit/ui/console/testrunner'
14
- require 'functional_test_matrix'
15
- require 'spec'
16
-
17
- Test::Unit::TestCase.extend FunctionalTestMatrix
18
-
19
-
20
-
21
-
22
- require 'calculator'
23
-
24
- class CalculatorTest < Test::Unit::TestCase
25
- def setup
26
- @calc ||= Calculator.single #(1)
27
- @calc.clear
28
- end
29
- end
30
-
31
-
32
-
33
-
34
- class CalculatorTest
35
- Constants = {:huge => 2**63 - 2, :huge_1 => 2**63 - 1, :over => 0}
36
-
37
- def number_for(value) #(2)
38
- Constants[value.to_s.intern] || value.to_s.to_i
39
- end
40
-
41
- def matrix_init_addition(_, value)
42
- @seconds = number_for value
43
- @calc.enter_number @seconds
44
- end
45
-
46
- def matrix_setup_add(value)
47
- @adding = number_for value
48
-
49
- @calc.plus
50
- @calc.enter_number @adding
51
- @calc.equals
52
- end
53
-
54
- def matrix_test(expected)
55
- @calc.total_seconds.should == number_for(expected)
56
- end
57
- end
58
-
59
-
60
-
61
-
62
- class CalculatorTest
63
- alias_method :old_method_missing, :method_missing
64
-
65
- def method_missing(name, *args)
66
- case name.to_s
67
- when /matrix_setup_add_(.+)/
68
- matrix_setup_add $1
69
- when /matrix_test_(.+)/
70
- matrix_test $1
71
- else
72
- old_method_missing name, *args
73
- end
74
- end
75
- end
76
-
77
-
78
-
79
-
80
- class CalculatorTest
81
- matrix :addition, :to_0, :to_1, :to_2, :to_huge
82
- action :add_0, 0, 1, 2, :huge
83
- action :add_1, 1, 2, 3, :huge_1
84
- action :add_2, 2, 3, 4, :over
85
- action :add_huge, :huge, :huge_1, :over, :over
86
- end
87
-
88
-
89
-
90
-
91
- class CalculatorTest
92
- _ = :na
93
-
94
- matrix :addition, :to_0, :to_1, :to_2, :to_huge
95
- action :add_0, 0, _, _, _
96
- action :add_1, 1, 2, _, _
97
- action :add_2, 2, 3, 4, _
98
- action :add_huge, :huge, :huge_1, :over, :over
99
- end
100
-
101
-
102
-
103
-
104
- class CalculatorOff < Test::Unit::TestCase
105
- def test_off
106
- Thread.new {sleep 3; Calculator.single.off}
107
- end
108
- end
109
-
@@ -1,17 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
- fixture.days = 1
10
- fixture.hours = 47
11
- fixture.mins = 59
12
- fixture.secs = 59 #(1)
13
-
14
- passed = (fixture.days == 2)
15
- passed &&= (fixture.hours == 23)
16
- passed &&= (fixture.mins == 59)
17
- passed &&= (fixture.secs == 59)
@@ -1,67 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
-
10
- require 'rubygems'
11
- require 'selenium'
12
-
13
- class BookSearch
14
- def initialize
15
- @browser = Selenium::SeleniumDriver.new \
16
- 'localhost', 4444, '*firefox', 'http://www.pragprog.com', 10000
17
- @browser.start
18
- end
19
-
20
- def close
21
- @browser.stop
22
- end
23
- end
24
-
25
-
26
-
27
-
28
- class BookSearch
29
- ResultCounter = '//table[@id="bookshelf"]//tr' #(1)
30
- ResultReader = 'xpath=/descendant::td[@class="description"]'
31
-
32
- def find(term)
33
- @browser.open '/'
34
- @browser.type '//input[@id="q"]', term
35
- @browser.click '//button[@class="go"]'
36
- @browser.wait_for_page_to_load 5000
37
-
38
- num_results = @browser.get_xpath_count(ResultCounter).to_i
39
-
40
- (1..num_results).inject({}) do |results, i|
41
- full_title = @browser.get_text("#{ResultReader}[#{i}]/h4/a") #(2)
42
- byline = @browser.get_text("#{ResultReader}[#{i}]/p[@class='by-line']")
43
- url = @browser.get_attribute("#{ResultReader}[#{i}]/h4/a@href")
44
-
45
- title, subtitle = full_title.split ': '
46
- authors = authors_from byline #(3)
47
-
48
- results.merge title =>
49
- {
50
- :title => title,
51
- :subtitle => subtitle,
52
- :url => url,
53
- :authors => authors
54
- }
55
- end
56
- end
57
- end
58
-
59
-
60
-
61
-
62
- class BookSearch
63
- def authors_from(byline)
64
- byline[3..-1].gsub(/(,? and )|(,? with )/, ',').split(',')
65
- end
66
- end
67
-
@@ -1,60 +0,0 @@
1
- #---
2
- # Excerpted from "Scripted GUI Testing With Ruby",
3
- # published by The Pragmatic Bookshelf.
4
- # Copyrights apply to this code. It may not be used to create training material,
5
- # courses, books, articles, and the like. Contact us if you are in doubt.
6
- # We make no guarantees that this code is fit for any purpose.
7
- # Visit http://www.pragmaticprogrammer.com/titles/idgtr for more book information.
8
- #---
9
-
10
- require 'rubygems'
11
- require 'watir'
12
-
13
- class BookSearch
14
- def initialize
15
- @browser = Watir::IE.new
16
- end
17
-
18
- def close
19
- @browser.close
20
- end
21
- end
22
-
23
-
24
-
25
-
26
- class BookSearch
27
- def find(term)
28
- @browser.goto 'http://www.pragprog.com'
29
- @browser.text_field(:id, 'q').set('Ruby') #(1)
30
- @browser.button(:class, 'go').click #(2)
31
-
32
- bookshelf = @browser.table(:id, 'bookshelf')
33
- num_results = bookshelf.row_count
34
-
35
- (1..num_results).inject({}) do |results, i|
36
- book = bookshelf[i][2] #(3)
37
-
38
- full_title = book.h4(:index, 1).text
39
- byline = book.p(:class, 'by-line').text
40
- url = book.link(:index, 1).href
41
-
42
- title, subtitle = full_title.split ': '
43
- authors = authors_from byline
44
-
45
- results.merge title => {
46
- :title => title,
47
- :subtitle => subtitle,
48
- :url => url,
49
- :authors => authors }
50
- end
51
- end
52
- end
53
-
54
-
55
-
56
- class BookSearch
57
- def authors_from(byline)
58
- byline[3..-1].gsub(/(,? and )|(,? with )/, ',').split(',')
59
- end
60
- end