rubinium 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. data/CHANGES +7 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README +137 -0
  4. data/Rakefile +139 -0
  5. data/TODO +7 -0
  6. data/doc/examples/rtc_site_live.rb +12 -0
  7. data/doc/examples/rts_main.rb +9 -0
  8. data/doc/examples/rts_shared_code.rb +25 -0
  9. data/lib/rubinium.rb +9 -0
  10. data/lib/rubinium/string.rb +3 -0
  11. data/lib/rubinium/test_base.rb +80 -0
  12. data/lib/rubinium/test_suite.rb +53 -0
  13. data/lib/rubinium/validator.rb +16 -0
  14. data/test/selenium_tests/test_click.rb +22 -0
  15. data/test/selenium_tests/test_open.rb +11 -0
  16. data/test/tc_file_creation.rb +60 -0
  17. data/test/ts_rubinium.rb +1 -0
  18. data/vendor/selenium-0.6.0/install-readme.txt +9 -0
  19. data/vendor/selenium-0.6.0/selenium/SeleneseRunner.html +253 -0
  20. data/vendor/selenium-0.6.0/selenium/SeleniumLog.html +61 -0
  21. data/vendor/selenium-0.6.0/selenium/TestRunner-splash.html +55 -0
  22. data/vendor/selenium-0.6.0/selenium/TestRunner.hta +146 -0
  23. data/vendor/selenium-0.6.0/selenium/TestRunner.html +146 -0
  24. data/vendor/selenium-0.6.0/selenium/devtests/TestClickInFrame.html +58 -0
  25. data/vendor/selenium-0.6.0/selenium/devtests/TestOpenInFrame.html +48 -0
  26. data/vendor/selenium-0.6.0/selenium/devtests/TestOpenInNewWindow.html +78 -0
  27. data/vendor/selenium-0.6.0/selenium/devtests/TestOpenMeta.html +43 -0
  28. data/vendor/selenium-0.6.0/selenium/devtests/TestSuite.html +39 -0
  29. data/vendor/selenium-0.6.0/selenium/devtests/meta/page.html +5 -0
  30. data/vendor/selenium-0.6.0/selenium/dom-images/butmin.gif +0 -0
  31. data/vendor/selenium-0.6.0/selenium/dom-images/butplus.gif +0 -0
  32. data/vendor/selenium-0.6.0/selenium/dom-styles/default.css +298 -0
  33. data/vendor/selenium-0.6.0/selenium/domviewer.html +16 -0
  34. data/vendor/selenium-0.6.0/selenium/html-xpath/carnation.jpg +0 -0
  35. data/vendor/selenium-0.6.0/selenium/html-xpath/example.html +75 -0
  36. data/vendor/selenium-0.6.0/selenium/html-xpath/html-xpath-patched.js +657 -0
  37. data/vendor/selenium-0.6.0/selenium/html-xpath/html-xpath.js +610 -0
  38. data/vendor/selenium-0.6.0/selenium/html-xpath/license.txt +504 -0
  39. data/vendor/selenium-0.6.0/selenium/html-xpath/rainbow.jpg +0 -0
  40. data/vendor/selenium-0.6.0/selenium/htmlutils.js +283 -0
  41. data/vendor/selenium-0.6.0/selenium/index.html +60 -0
  42. data/vendor/selenium-0.6.0/selenium/jsmock/mock-tests.html +205 -0
  43. data/vendor/selenium-0.6.0/selenium/jsmock/mock.js +124 -0
  44. data/vendor/selenium-0.6.0/selenium/selenium-api.js +683 -0
  45. data/vendor/selenium-0.6.0/selenium/selenium-browserbot.js +930 -0
  46. data/vendor/selenium-0.6.0/selenium/selenium-commandhandlers.js +286 -0
  47. data/vendor/selenium-0.6.0/selenium/selenium-domviewer.js +188 -0
  48. data/vendor/selenium-0.6.0/selenium/selenium-executionloop.js +250 -0
  49. data/vendor/selenium-0.6.0/selenium/selenium-fitrunner.js +597 -0
  50. data/vendor/selenium-0.6.0/selenium/selenium-logging.js +88 -0
  51. data/vendor/selenium-0.6.0/selenium/selenium-logo.png +0 -0
  52. data/vendor/selenium-0.6.0/selenium/selenium-tableparser.js +50 -0
  53. data/vendor/selenium-0.6.0/selenium/selenium.css +211 -0
  54. data/vendor/selenium-0.6.0/selenium/tests/ErrorCheckingTestSuite.html +36 -0
  55. data/vendor/selenium-0.6.0/selenium/tests/GoogleTestSearch.html +69 -0
  56. data/vendor/selenium-0.6.0/selenium/tests/GoogleTestSuite.html +32 -0
  57. data/vendor/selenium-0.6.0/selenium/tests/JsUnitSuite.html +38 -0
  58. data/vendor/selenium-0.6.0/selenium/tests/TestClick.html +128 -0
  59. data/vendor/selenium-0.6.0/selenium/tests/TestClickJavascriptHref.html +115 -0
  60. data/vendor/selenium-0.6.0/selenium/tests/TestCommandError.html +79 -0
  61. data/vendor/selenium-0.6.0/selenium/tests/TestConfirmations.html +77 -0
  62. data/vendor/selenium-0.6.0/selenium/tests/TestErrorChecking.html +71 -0
  63. data/vendor/selenium-0.6.0/selenium/tests/TestFailingAssert.html +59 -0
  64. data/vendor/selenium-0.6.0/selenium/tests/TestFailingVerifications.html +198 -0
  65. data/vendor/selenium-0.6.0/selenium/tests/TestFocusOnBlur.html +53 -0
  66. data/vendor/selenium-0.6.0/selenium/tests/TestGoBack.html +81 -0
  67. data/vendor/selenium-0.6.0/selenium/tests/TestImplicitLocators.html +81 -0
  68. data/vendor/selenium-0.6.0/selenium/tests/TestJavascriptParameters.html +91 -0
  69. data/vendor/selenium-0.6.0/selenium/tests/TestLocators.html +161 -0
  70. data/vendor/selenium-0.6.0/selenium/tests/TestModalDialog.html +58 -0
  71. data/vendor/selenium-0.6.0/selenium/tests/TestModalDialogDialog.html +48 -0
  72. data/vendor/selenium-0.6.0/selenium/tests/TestOpen.html +66 -0
  73. data/vendor/selenium-0.6.0/selenium/tests/TestPatternMatching.html +127 -0
  74. data/vendor/selenium-0.6.0/selenium/tests/TestPause.html +78 -0
  75. data/vendor/selenium-0.6.0/selenium/tests/TestPrompting.html +82 -0
  76. data/vendor/selenium-0.6.0/selenium/tests/TestProxy.html +62 -0
  77. data/vendor/selenium-0.6.0/selenium/tests/TestSelect.html +111 -0
  78. data/vendor/selenium-0.6.0/selenium/tests/TestSelectWindow.html +106 -0
  79. data/vendor/selenium-0.6.0/selenium/tests/TestStore.html +165 -0
  80. data/vendor/selenium-0.6.0/selenium/tests/TestSuite-InternetExplorer.html +79 -0
  81. data/vendor/selenium-0.6.0/selenium/tests/TestSuite-Konqueror.html +75 -0
  82. data/vendor/selenium-0.6.0/selenium/tests/TestSuite-Safari.html +75 -0
  83. data/vendor/selenium-0.6.0/selenium/tests/TestSuite.html +75 -0
  84. data/vendor/selenium-0.6.0/selenium/tests/TestType.html +79 -0
  85. data/vendor/selenium-0.6.0/selenium/tests/TestUserExtensions.html +81 -0
  86. data/vendor/selenium-0.6.0/selenium/tests/TestVerifications.html +164 -0
  87. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyAlerts.html +80 -0
  88. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyAlertsFailures.html +108 -0
  89. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyConfirmationFailures.html +86 -0
  90. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyEditable.html +70 -0
  91. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyEditableFailures.html +95 -0
  92. data/vendor/selenium-0.6.0/selenium/tests/TestVisibility.html +91 -0
  93. data/vendor/selenium-0.6.0/selenium/tests/TestVisibilityFailures.html +131 -0
  94. data/vendor/selenium-0.6.0/selenium/tests/TestWait.html +112 -0
  95. data/vendor/selenium-0.6.0/selenium/tests/TestWaitFor.html +63 -0
  96. data/vendor/selenium-0.6.0/selenium/tests/TestWaitInPopupWindow.html +94 -0
  97. data/vendor/selenium-0.6.0/selenium/tests/TestXPathLocators.html +98 -0
  98. data/vendor/selenium-0.6.0/selenium/tests/browserbot/alert-handling-tests.html +79 -0
  99. data/vendor/selenium-0.6.0/selenium/tests/browserbot/assert-tests.html +113 -0
  100. data/vendor/selenium-0.6.0/selenium/tests/browserbot/browserbot-tests.html +123 -0
  101. data/vendor/selenium-0.6.0/selenium/tests/browserbot/command-factory-tests.html +290 -0
  102. data/vendor/selenium-0.6.0/selenium/tests/browserbot/command-handler-tests.html +115 -0
  103. data/vendor/selenium-0.6.0/selenium/tests/browserbot/confirm-handling-tests.html +97 -0
  104. data/vendor/selenium-0.6.0/selenium/tests/browserbot/error-checking-command-tests.html +198 -0
  105. data/vendor/selenium-0.6.0/selenium/tests/browserbot/event-bubble-tests.html +106 -0
  106. data/vendor/selenium-0.6.0/selenium/tests/browserbot/optionlocator-tests.html +180 -0
  107. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-accessor-tests.html +65 -0
  108. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-action-tests.html +200 -0
  109. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-attribute-tests.html +98 -0
  110. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-locator-tests-include.html +33 -0
  111. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-locator-tests.html +258 -0
  112. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-property-tests.html +49 -0
  113. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pattern-matcher-tests.html +66 -0
  114. data/vendor/selenium-0.6.0/selenium/tests/browserbot/selenium-api-tests.html +412 -0
  115. data/vendor/selenium-0.6.0/selenium/tests/browserbot/selenium-parameter-tests.html +98 -0
  116. data/vendor/selenium-0.6.0/selenium/tests/browserbot/suite.html +52 -0
  117. data/vendor/selenium-0.6.0/selenium/tests/browserbot/testloop-handle-error-tests.html +74 -0
  118. data/vendor/selenium-0.6.0/selenium/tests/events/TestButtonEvents.html +72 -0
  119. data/vendor/selenium-0.6.0/selenium/tests/events/TestCheckboxEvents.html +107 -0
  120. data/vendor/selenium-0.6.0/selenium/tests/events/TestFireEvents.html +75 -0
  121. data/vendor/selenium-0.6.0/selenium/tests/events/TestLinkEvents.html +43 -0
  122. data/vendor/selenium-0.6.0/selenium/tests/events/TestRadioEvents.html +149 -0
  123. data/vendor/selenium-0.6.0/selenium/tests/events/TestSelectEvents.html +122 -0
  124. data/vendor/selenium-0.6.0/selenium/tests/events/TestTextEvents.html +87 -0
  125. data/vendor/selenium-0.6.0/selenium/tests/events/readme.txt +26 -0
  126. data/vendor/selenium-0.6.0/selenium/tests/html/banner.gif +0 -0
  127. data/vendor/selenium-0.6.0/selenium/tests/html/test_async_event.html +36 -0
  128. data/vendor/selenium-0.6.0/selenium/tests/html/test_click_javascript_page.html +34 -0
  129. data/vendor/selenium-0.6.0/selenium/tests/html/test_click_page1.html +31 -0
  130. data/vendor/selenium-0.6.0/selenium/tests/html/test_click_page2.html +30 -0
  131. data/vendor/selenium-0.6.0/selenium/tests/html/test_confirm.html +34 -0
  132. data/vendor/selenium-0.6.0/selenium/tests/html/test_dummy_page.html +26 -0
  133. data/vendor/selenium-0.6.0/selenium/tests/html/test_editable.html +36 -0
  134. data/vendor/selenium-0.6.0/selenium/tests/html/test_focus_on_blur.html +33 -0
  135. data/vendor/selenium-0.6.0/selenium/tests/html/test_form_events.html +98 -0
  136. data/vendor/selenium-0.6.0/selenium/tests/html/test_framed_page.html +7 -0
  137. data/vendor/selenium-0.6.0/selenium/tests/html/test_just_text.html +22 -0
  138. data/vendor/selenium-0.6.0/selenium/tests/html/test_locators.html +34 -0
  139. data/vendor/selenium-0.6.0/selenium/tests/html/test_modal_dialog.html +29 -0
  140. data/vendor/selenium-0.6.0/selenium/tests/html/test_modal_dialog_dialog.html +35 -0
  141. data/vendor/selenium-0.6.0/selenium/tests/html/test_open.html +23 -0
  142. data/vendor/selenium-0.6.0/selenium/tests/html/test_prompt.html +34 -0
  143. data/vendor/selenium-0.6.0/selenium/tests/html/test_reload_onchange_page.html +32 -0
  144. data/vendor/selenium-0.6.0/selenium/tests/html/test_select.html +35 -0
  145. data/vendor/selenium-0.6.0/selenium/tests/html/test_select_window.html +29 -0
  146. data/vendor/selenium-0.6.0/selenium/tests/html/test_select_window_popup.html +28 -0
  147. data/vendor/selenium-0.6.0/selenium/tests/html/test_slowloading_page.html +27 -0
  148. data/vendor/selenium-0.6.0/selenium/tests/html/test_store_value.html +23 -0
  149. data/vendor/selenium-0.6.0/selenium/tests/html/test_type_page1.html +37 -0
  150. data/vendor/selenium-0.6.0/selenium/tests/html/test_type_page2.html +61 -0
  151. data/vendor/selenium-0.6.0/selenium/tests/html/test_verifications.html +42 -0
  152. data/vendor/selenium-0.6.0/selenium/tests/html/test_verify_alert.html +46 -0
  153. data/vendor/selenium-0.6.0/selenium/tests/html/test_visibility.html +53 -0
  154. data/vendor/selenium-0.6.0/selenium/tests/readme.txt +1 -0
  155. data/vendor/selenium-0.6.0/selenium/tests/tableparser/tableparser-tests.html +122 -0
  156. data/vendor/selenium-0.6.0/selenium/tests/tinyWebServer.py +70 -0
  157. data/vendor/selenium-0.6.0/selenium/user-extensions.js.sample +62 -0
  158. data/vendor/selenium-0.6.0/selenium/version.txt +1 -0
  159. data/vendor/selenium-0.6.0/selenium/xmlextras.js +153 -0
  160. data/vendor/selenium-0.6.0/selenium/xpath.js +3910 -0
  161. metadata +216 -0
data/CHANGES ADDED
@@ -0,0 +1,7 @@
1
+ = Rubinium Changelog
2
+
3
+ == Version 0.1.1
4
+
5
+ This is the initial release. It generates Selenium HTML tests from the corresponding Rubinium tests. Rubinium tests look almost identical to Selenium tests, except they're written in Ruby. This allows the test writer to drop into ruby when they need some extra juice.
6
+
7
+ * Initial import
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2005, 2006 Alex Garrett
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
data/README ADDED
@@ -0,0 +1,137 @@
1
+ = Rubinium: The Ruby code generator for Selenium
2
+
3
+ Rubinium is a tool that makes writing Selenium[http://www.openqa.org/selenium/] tests easier. Here's a quick comparison:
4
+
5
+ A Selenium test:
6
+
7
+ <html><head><title>HelloWorld</title><head>
8
+ <body>
9
+ <table border="1">
10
+ <tr><td colspan="3">HelloWorld Test</td></tr>
11
+ <tr><td>open</td><td>/index.php</td><td>&nbsp;</td></tr>
12
+ <tr><td>assertTitle</td><td>Hello World</td><td>&nbsp;</td></tr>
13
+ <tr><td>assertLocation</td><td>/index.php</td><td>&nbsp;</td></tr>
14
+ <tr><td>assertTextPresent</td><td>Hello World</td><td>&nbsp;</td></tr>
15
+ </table>
16
+ </body>
17
+ </html>
18
+
19
+ And here's the corresponding Rubinium test:
20
+
21
+ class HelloWorld < Rubinium::TestBase
22
+ open "/index.php"
23
+ assertTitle "Hello World"
24
+ assertLocation "/index.php"
25
+ assertTextPresent "Hello World"
26
+ end
27
+
28
+ The added immediate benefit is that the Rubinium test can be executed and if the actions/assertions aren't valid the test will raise an exception. If the actions/assertions are valid, the test will exit without generating any output.
29
+
30
+ == Download
31
+
32
+ The latest version of Rubinium can be found at
33
+
34
+ * http://rubyforge.org/project/showfiles.php?group_id=1179
35
+
36
+ == GEM Installation
37
+
38
+ Download and install rubinium with the following.
39
+
40
+ gem install --remote rubinium
41
+
42
+ == Simple Example
43
+
44
+ Here's a simple example that shows a mixture of Selenium and ruby:
45
+
46
+ require 'rubygems'
47
+ require_gem 'rubinium'
48
+
49
+ class SiteLive < Rubinium::TestBase
50
+ HOST = "http://localhost:8080"
51
+ MAIN_PAGE = "/index.html"
52
+
53
+ open HOST
54
+ assertLocation MAIN_PAGE
55
+ end
56
+
57
+ Notice that the host and main page are represented as ruby constants and the constants are used in the test, rather than storing the value directly in the test. This helps keep your tests DRY[http://c2.com/cgi/wiki?DontRepeatYourself].
58
+
59
+ Here's the Selenium test that gets generated:
60
+
61
+ <html><head><title>SiteLive</title></head>
62
+ <body>
63
+ <table border="1">
64
+ <tbody>
65
+ <tr><td colspan="3">SiteLive Test</td></tr>
66
+ <tr><td>open</td><td>http://localhost:8080</td><td>&nbsp;</td></tr>
67
+ <tr><td>assertLocation</td><td>/index.html</td><td>&nbsp;</td></tr>
68
+ </tbody>
69
+ </table>
70
+ </body>
71
+ </html>
72
+
73
+ Test cases get aggregated into test suites. Here's a simple test suite that contains the test case from above:
74
+
75
+ require 'rubygems'
76
+ require_gem 'rubinium'
77
+
78
+ Rubinium::TestSuite.new do |suite|
79
+ suite.name = "MainSuite"
80
+ suite.filename = "main-suite.html"
81
+ suite.basedir = File.dirname(__FILE__)
82
+ suite << SiteLive
83
+ end.generate
84
+
85
+ The easiest way to create a test suite is to use the (probably familiar) block syntax. Individual tests are appended to the suite using the <tt>&lt;&lt;</tt> operator. After the suite has been initialized, you should invoke the <tt>generate</tt> method to generate the actual Selenium tests.
86
+
87
+ A test suite has three attributes, all optional: <tt>name</tt>, <tt>filename</tt>, and <tt>basedir</tt>. The first two allow you to set the name that will be displayed in the Selenium test and the filename of the generated Selenium suite. The <tt>basedir</tt> attribute is the directory where the files will be generated. While you can set the <tt>basedir</tt> directly in the suite, a more common way of setting it is by passing it as a command line parameter. E.g.,
88
+
89
+ ruby rts_main.rb tests/generated-tests
90
+
91
+ This usage is particularly amenable to Rake[http://rake.rubyforge.org] tasks:
92
+
93
+ TEST_PATH = "test/tests"
94
+ GENERATED_TEST_PATH = "test/generated-tests"
95
+
96
+ ACCEPTANCE_TESTS = %w(
97
+ rts_main.rb
98
+ ).map {|test| File.join(TEST_PATH, test)}
99
+
100
+ desc "Generate selenium tests from rubinium tests"
101
+ task :rubinium => [:clean, :environment] do
102
+ ACCEPTANCE_TESTS.each do |test|
103
+ ruby "#{test} #{GENERATED_TEST_PATH}"
104
+ end
105
+ end
106
+
107
+ NB: If <tt>basedir</tt> is supplied both as a command line parameter and as an explicit attribute in the suite, the command line parameter will be ignored.
108
+
109
+ More examples of Rubinium tests and suites are provided in the doc/examples directory.
110
+
111
+ == Credits
112
+
113
+ [<b>The Folks at Thoughtworks</b>] For creating Selenium.
114
+
115
+ [<b>Jim Weirich</b>] For creating Rake[http://rake.rubyforge.org] and writing extensively and clearly about DSLs and metaprogramming in Ruby.
116
+
117
+ [<b>why_the_lucky_stiff</b>] For inspiring me with Dwemthy's Array
118
+
119
+ [<b>Stephen Baker</b>] For the RSpec[http://rspec.rubyforge.org] Rakefile I liberally pillaged from.
120
+
121
+ == License
122
+
123
+ Rubinium is available under an MIT-style license.
124
+
125
+ :include: MIT-LICENSE
126
+
127
+ == Support
128
+
129
+ The Rubinium homepage is http://rubinium.thinkpig.org. You can find the Rubinium
130
+ RubyForge page at http://rubyforge.org/projects/rubinium.
131
+
132
+ Feel free to submit commits or feature requests. If you send a patch,
133
+ remember to update the corresponding unit tests. Patches are much less likely to be adopted if I have to write the tests.
134
+
135
+ For other information, feel free to contact mailto:ljagged@thinkpig.org.
136
+
137
+ ----
@@ -0,0 +1,139 @@
1
+ require 'rubygems'
2
+ require 'rake/gempackagetask'
3
+ require 'meta_project'
4
+ require 'rake/rdoctask'
5
+ require 'rake/testtask'
6
+ require 'rake/clean'
7
+ require 'rake/contrib/xforge'
8
+ require 'rake/contrib/rubyforgepublisher'
9
+
10
+ PKG_NAME = 'rubinium'
11
+ PKG_VERSION = "0.1.1"
12
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
13
+
14
+ PKG_FILES = FileList.new
15
+ PKG_FILES.add %w{ Rakefile README CHANGES MIT-LICENSE TODO }
16
+ PKG_FILES.add %w{ lib/**/*.rb }
17
+ PKG_FILES.add %w{ test/**/*.rb }
18
+ PKG_FILES.add %w{ doc/**/* }
19
+ PKG_FILES.add %w{ vendor/**/* }
20
+
21
+ CLEAN.add %w{ pkg html }
22
+
23
+ spec = Gem::Specification.new do |s|
24
+ s.name = PKG_NAME
25
+ s.summary = "Code generator for Selenium with test validation"
26
+ s.email = 'ljagged(at)thinkpig.org'
27
+ s.author = 'Alex Garrett'
28
+ s.homepage = 'http://rubinium.thinkpig.org'
29
+ s.rubyforge_project = "rubinium"
30
+ s.platform = Gem::Platform::RUBY
31
+ s.version = PKG_VERSION
32
+ s.files = PKG_FILES
33
+ s.requirements << 'none'
34
+ s.require_path = 'lib'
35
+ s.autorequire = 'rubinium'
36
+ s.test_file = 'test/ts_rubinium.rb'
37
+ s.has_rdoc = true
38
+ s.extra_rdoc_files = ['README', "CHANGES", "TODO", "MIT-LICENSE"]
39
+ s.description = <<EOF
40
+ Rubinium is a FIT-style code generator for Selenium. It supports validation and allows the user to
41
+ include arbitrary ruby in the test.
42
+ EOF
43
+ end
44
+
45
+ task :default => [:test]
46
+
47
+ Rake::TestTask.new do |t|
48
+ t.libs << "test"
49
+ t.test_files = ['ts_rubinium.rb']
50
+ t.verbose = true
51
+ end
52
+
53
+ task :test => [:clean]
54
+
55
+ Rake::RDocTask.new do |rd|
56
+ rd.main = "README"
57
+ rd.title = "Rubinium"
58
+ rd.options << '--line-numbers' << '--inline-source'
59
+ rd.rdoc_files.include("README", "CHANGES", "TODO", "lib/**/*.rb")
60
+ end
61
+
62
+ Rake::GemPackageTask.new(spec) do |pkg|
63
+ pkg.need_zip = true
64
+ pkg.need_tar = true
65
+ end
66
+
67
+ def egrep(pattern)
68
+ Dir['**/*.rb'].each do |fn|
69
+ count = 0
70
+ open(fn) do |f|
71
+ while line = f.gets
72
+ count += 1
73
+ if line =~ pattern
74
+ puts "#{fn}:#{count}:#{line}"
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ desc "Look for TODO and FIXME tags in the code"
82
+ task :todo do
83
+ egrep /#.*(FIXME|TODO|TBD)/
84
+ end
85
+
86
+ desc "Generate agiledox-like documentation for tests"
87
+ task :agiledox do
88
+ tests = FileList['test/**/tc_*.rb']
89
+ tests.each do |file|
90
+ m = %r".*/tc_([^/].*).rb".match(file)
91
+ puts m[1]+" should:\n"
92
+ test_definitions = File::readlines(file).select {|line| line =~ /.*def test.*/}
93
+ test_definitions.each do |definition|
94
+ m = %r"test_(should_)?(.*)".match(definition)
95
+ puts " - "+m[2].gsub(/_/," ")
96
+ end
97
+ puts "\n"
98
+ end
99
+ end
100
+
101
+ task :release => [:verify_env_vars, :release_files, :publish_doc, :publish_news]
102
+
103
+ task :verify_env_vars do
104
+ raise "RUBYFORGE_USER environment variable not set!" unless ENV['RUBYFORGE_USER']
105
+ raise "RUBYFORGE_PASSWORD environment variable not set!" unless ENV['RUBYFORGE_PASSWORD']
106
+ end
107
+
108
+ desc "Release gem to RubyForge. MAKE SURE PKG_VERSION is aligned with the CHANGELOG file"
109
+ task :release_files => [:gem] do
110
+ release_files = FileList[
111
+ "pkg/#{PKG_FILE_NAME}.gem"
112
+ ]
113
+
114
+ Rake::XForge::Release.new(MetaProject::Project::XForge::RubyForge.new(PKG_NAME)) do |xf|
115
+ # Never hardcode user name and password in the Rakefile!
116
+ xf.user_name = ENV['RUBYFORGE_USER']
117
+ xf.password = ENV['RUBYFORGE_PASSWORD']
118
+ xf.files = release_files.to_a
119
+ xf.release_name = "Rubinium #{PKG_VERSION}"
120
+ end
121
+ end
122
+
123
+ desc "Publish documentation"
124
+ task :publish_doc => [:rdoc] do
125
+ Rake::RubyForgePublisher.new(PKG_NAME, ENV['RUBYFORGE_USER']).upload
126
+ end
127
+
128
+ desc "Publish news on RubyForge"
129
+ task :publish_news => [:gem] do
130
+ release_files = FileList[
131
+ "pkg/#{PKG_FILE_NAME}.gem"
132
+ ]
133
+
134
+ Rake::XForge::NewsPublisher.new(MetaProject::Project::XForge::RubyForge.new(PKG_NAME)) do |news|
135
+ # Never hardcode user name and password in the Rakefile!
136
+ news.user_name = ENV['RUBYFORGE_USER']
137
+ news.password = ENV['RUBYFORGE_PASSWORD']
138
+ end
139
+ end
data/TODO ADDED
@@ -0,0 +1,7 @@
1
+ = Rubinium Project -- To Do List
2
+
3
+ Send suggestions for this list to mailto:ljagged@thinkpig.org.
4
+
5
+ === To Do
6
+ * Add validation to Rubinium::TestBase
7
+ * Allow loading of test fixtures that contain common or shared data
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require_gem 'rubinium'
3
+
4
+ class SiteLiveTest < Rubinium::TestBase
5
+ HOST = "http://localhost:8080"
6
+ MAIN_PAGE = "/index.html"
7
+
8
+ open HOST
9
+ assertLocation MAIN_PAGE
10
+ end
11
+
12
+ puts SiteLiveTest.generate
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require_gem 'rubinium'
3
+
4
+ Rubinium::TestSuite.new() do |suite|
5
+ suite.name = "MainSuite"
6
+ suite.filename = "main-suite.html"
7
+ suite.basedir = File.dirname(__FILE__)
8
+ suite << SiteLive
9
+ end.generate
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require_gem 'rubinium'
3
+
4
+ class FeatureSpecTest < Rubinium::TestBase
5
+ def self.addFeature
6
+ open 'index.jsp'
7
+ end
8
+ end
9
+
10
+ class HappyPath < FeatureSpecTest
11
+ addFeature
12
+ assertTextPresent "Added successfully"
13
+ end
14
+
15
+ class SadPath < FeatureSpecTest
16
+ addFeature
17
+ assertTextPresent "Feature already added"
18
+ end
19
+
20
+ Rubinium::TestSuite.new do |suite|
21
+ suite.name = "TestSuite"
22
+ suite.filename = "test-suite.html"
23
+ suite << HappyPath
24
+ suite << SadPath
25
+ end.generate
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+
3
+ RUBINIUM_ROOT = File.dirname(__FILE__)
4
+ SELENIUM_ROOT = ENV['SELENIUM_ROOT'] || File.join(RUBINIUM_ROOT, "../vendor/selenium-0.6.0")
5
+ SELENIUM_API = File.join(SELENIUM_ROOT, 'selenium/selenium-api.js')
6
+
7
+ require RUBINIUM_ROOT + '/rubinium/validator'
8
+ require RUBINIUM_ROOT + '/rubinium/test_base'
9
+ require RUBINIUM_ROOT + '/rubinium/test_suite'
@@ -0,0 +1,3 @@
1
+ class String
2
+ def down_first; self.gsub(/^(.)/, $1.downcase) if self =~ /^(.)/; end
3
+ end
@@ -0,0 +1,80 @@
1
+ require File.dirname(__FILE__) + '/string'
2
+
3
+ module Rubinium
4
+ class TestBase
5
+ def self.metaclass; class << self; self; end; end
6
+
7
+ metaclass.class_eval do
8
+ include Validator
9
+ attr_accessor :filename
10
+ end
11
+ # TODO: Add cattr_accessor, etc.
12
+
13
+ methods = File.open(SELENIUM_API) do |f|
14
+ api = f.read
15
+ actions = api.grep(/^Selenium\.prototype\.do(\w+)/) { |match| $1.down_first }.inject([]) do |acc, elem|
16
+ acc << elem
17
+ acc << "#{elem}AndWait"
18
+ end << "pause" # special case
19
+ asserts = api.grep(/^Selenium\.prototype\.assert(\w+)/) { |match| $1 }.inject([]) do |acc, elem|
20
+ acc << "assert#{elem}"
21
+ acc << "verify#{elem}"
22
+ acc
23
+ end
24
+ accessors = api.grep(/^Selenium.prototype.get(\w+)/) { |match| $1 }.inject([]) do |acc, elem|
25
+ acc << "get#{elem}"
26
+ acc << "verify#{elem}"
27
+ acc << "assert#{elem}"
28
+ acc << "verifyNot#{elem}"
29
+ acc << "assertNot#{elem}"
30
+ end
31
+ actions + asserts + accessors
32
+ end
33
+ methods.each do |verb|
34
+ metaclass.class_eval do
35
+ define_method(verb) do |*object|
36
+ @test_actions ||= []
37
+ @test_actions << [verb, object]
38
+ if @validators and validator = @validators[verb]
39
+ self.send(validator, self, object)
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ def self.validate(*actions)
46
+ actions.each do |action|
47
+ @validators ||= {}
48
+ @validators[action] = :validateOpen
49
+ end
50
+ end
51
+ def self.generate(io = "")
52
+ script = @test_actions.map do |line|
53
+ verb, object = line
54
+ target = object[0]
55
+ value = object[1] || "&nbsp;"
56
+ "#{" " * 6}<tr><td>#{verb}</td><td>#{target}</td><td>#{value}</td></tr>"
57
+ end.join("\n")
58
+ fullscript = <<EOF
59
+ <html><head><title>#{self.name.to_s}</title></head>
60
+ <body>
61
+ <table border="1">
62
+ <tbody>
63
+ <tr><td colspan="3">#{self.to_s} Test</td></tr>
64
+ #{script}
65
+ </tbody>
66
+ </table>
67
+ </body>
68
+ </html>
69
+ EOF
70
+ io << fullscript
71
+ io
72
+ end
73
+ def self.filename
74
+ @filename || self.to_s + ".html"
75
+ end
76
+ def self.errors
77
+ @errors ||= []
78
+ end
79
+ end
80
+ end