rwebunit 1.0.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +68 -4
- data/README +32 -32
- data/Rakefile +38 -26
- data/lib/rspec_extensions.rb +22 -86
- data/lib/rwebunit/assert.rb +241 -130
- data/lib/rwebunit/context.rb +1 -1
- data/lib/rwebunit/driver.rb +436 -271
- data/lib/rwebunit/itest_plugin.rb +23 -2
- data/lib/rwebunit/popup.rb +147 -0
- data/lib/rwebunit/rspec_helper.rb +12 -56
- data/lib/rwebunit/test_script.rb +8 -0
- data/lib/rwebunit/test_utils.rb +96 -23
- data/lib/rwebunit/using_pages.rb +49 -0
- data/lib/rwebunit/web_browser.rb +27 -5
- data/lib/rwebunit/web_page.rb +13 -17
- data/lib/rwebunit.rb +4 -4
- metadata +17 -12
- data/docs/html/index.html +0 -129
- data/test/mock_page.rb +0 -8
- data/test/setup.rb +0 -10
- data/test/test.html +0 -129
- data/test/test_assert.rb +0 -64
- data/test/test_driver.rb +0 -57
- data/test/test_test_utils.rb +0 -76
data/CHANGELOG
CHANGED
@@ -1,9 +1,73 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
=========
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
|
4
|
+
1.3
|
5
|
+
add new syntax for including pages
|
6
|
+
extend RWebUnit::UsingPages
|
7
|
+
pages :login_page, :receipt_page, :page_dir => 'c:/temp'
|
8
|
+
|
9
|
+
1.2.4
|
10
|
+
Generate new rdoc
|
11
|
+
|
12
|
+
1.2.3
|
13
|
+
New - support_unicode
|
14
|
+
More alias assert_select_label_not_present assert_option_not_present
|
15
|
+
New - click_button_with_name
|
16
|
+
|
17
|
+
1.2.2
|
18
|
+
|
19
|
+
save_current_page save to ITEST2
|
20
|
+
|
21
|
+
1.2.1 (2009-04-02)
|
22
|
+
|
23
|
+
Fixes - base_url is file://
|
24
|
+
New - set_hidden_field
|
25
|
+
New - allowing
|
26
|
+
New - try { } handles boolean values as well
|
27
|
+
Doc update
|
28
|
+
|
29
|
+
1.2
|
30
|
+
REVISIT all APIs
|
31
|
+
- assertions
|
32
|
+
- assert_not (new)
|
33
|
+
- assert_text_field_value (new)
|
34
|
+
- assert_text_present_in_table (renamed)
|
35
|
+
- assert_element_present (removed, use assert div(:id, "").exists?)
|
36
|
+
- driver.rb
|
37
|
+
- wait_until (new)
|
38
|
+
- repeat_try_util (new)
|
39
|
+
- try (add more clear messages when block failed)
|
40
|
+
- add unit tests
|
41
|
+
- run unit test against the test page in Firefox Browser
|
42
|
+
- major documentation update
|
43
|
+
|
44
|
+
1.1.3
|
45
|
+
add open_existing_browser
|
46
|
+
|
47
|
+
1.1.2 (2009-03-13)
|
48
|
+
added goto_url
|
49
|
+
|
50
|
+
1.1.1
|
51
|
+
add open_browser.rb, check for firefox with jssh is running
|
52
|
+
added assert_exists, assert_not_exists
|
53
|
+
|
54
|
+
1.1
|
55
|
+
|
56
|
+
Changed dependency (Assertions) for test-unit 2.0.2, ruby 1.9.1 ready
|
57
|
+
Extract popup.rb out
|
58
|
+
Added repeat_try in driver.rb
|
59
|
+
remove should_not_allow, should_allow. Important!!! don't define methods start with should_not_, should_
|
60
|
+
|
61
|
+
1.0.4
|
62
|
+
Added: WebBrowser.html WebBrowser.text
|
63
|
+
Added: random method in test_utils
|
64
|
+
Enhancemet: close_browser works even no browser started in the test
|
65
|
+
move open_browser to driver.rb
|
66
|
+
fixed include rwebunit causing stack too deep error
|
6
67
|
|
68
|
+
1.0.3
|
69
|
+
- New set of samples (real life tests)
|
70
|
+
|
7
71
|
1.0.2
|
8
72
|
- add more unit tests
|
9
73
|
Fixes cell_with_id
|
@@ -14,7 +78,7 @@ CHANGELOG
|
|
14
78
|
1.0 (2008-11-25)
|
15
79
|
|
16
80
|
TODO:
|
17
|
-
Firefox: check the element is hidden or showing,
|
81
|
+
Firefox: check the element is hidden or showing,
|
18
82
|
Checkfor driver.rb: ajax_call_complete_after_element_hidden
|
19
83
|
does not support outerHtml yet
|
20
84
|
Firefox: attach browser,
|
data/README
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
|
2
|
-
rWebUnit wraps the popular web testing framework WATIR with RSpec Syntax to provide better easy to read automated web test cases. By using iTest/Watir recorder, the rWebUnit test scripts can be recorded in Firefox. iTest2 makes editing/executing test cases with ease.
|
3
|
-
|
4
|
-
Sample rWebUnit Test:
|
5
|
-
|
6
|
-
require 'rwebunit'
|
7
|
-
|
8
|
-
spec "Locate a Suncorp Branch" do
|
9
|
-
include RWebUnit::RSpecHelper
|
10
|
-
|
11
|
-
before(:all) do
|
12
|
-
open_browser_with("http://suncorp.com.au/")
|
13
|
-
end
|
14
|
-
|
15
|
-
before(:each) do
|
16
|
-
goto_page("/locator")
|
17
|
-
end
|
18
|
-
|
19
|
-
after(:all) do
|
20
|
-
close_browser
|
21
|
-
end
|
22
|
-
|
23
|
-
scenario "Find by extended trading hours" do
|
24
|
-
checkbox(:id, "OpenExtendedTradingHoursSerivceId").click # using Watir directly
|
25
|
-
enter_text("Postcode_Locator__Postcode", "4061")
|
26
|
-
click_button_with_image("search_button.gif")
|
27
|
-
page_source.should include("Queen St Mall")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
iTest2 Homepage: http://www.itest2.com
|
1
|
+
|
2
|
+
rWebUnit wraps the popular web testing framework WATIR with RSpec Syntax to provide better easy to read automated web test cases. By using iTest/Watir recorder, the rWebUnit test scripts can be recorded in Firefox. iTest2 makes editing/executing test cases with ease.
|
3
|
+
|
4
|
+
Sample rWebUnit Test:
|
5
|
+
|
6
|
+
require 'rwebunit'
|
7
|
+
|
8
|
+
spec "Locate a Suncorp Branch" do
|
9
|
+
include RWebUnit::RSpecHelper
|
10
|
+
|
11
|
+
before(:all) do
|
12
|
+
open_browser_with("http://suncorp.com.au/")
|
13
|
+
end
|
14
|
+
|
15
|
+
before(:each) do
|
16
|
+
goto_page("/locator")
|
17
|
+
end
|
18
|
+
|
19
|
+
after(:all) do
|
20
|
+
close_browser
|
21
|
+
end
|
22
|
+
|
23
|
+
scenario "Find by extended trading hours" do
|
24
|
+
checkbox(:id, "OpenExtendedTradingHoursSerivceId").click # using Watir directly
|
25
|
+
enter_text("Postcode_Locator__Postcode", "4061")
|
26
|
+
click_button_with_image("search_button.gif")
|
27
|
+
page_source.should include("Queen St Mall")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
iTest2 Homepage: http://www.itest2.com
|
33
33
|
|
data/Rakefile
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'rake/
|
2
|
+
require 'spec/rake/spectask'
|
3
3
|
require 'rake/rdoctask'
|
4
|
-
|
5
|
-
Gem::manage_gems
|
6
4
|
require 'rake/gempackagetask'
|
5
|
+
require 'rdoc' # require rdoc 2
|
6
|
+
gem 'darkfish-rdoc'
|
7
|
+
# require 'darkfish-rdoc'
|
7
8
|
|
8
9
|
$:.unshift(File.dirname(__FILE__) + "/lib")
|
9
10
|
#require 'rwebunit'
|
10
11
|
|
11
12
|
desc "Default task"
|
12
|
-
task :default => [ :clean, :
|
13
|
+
task :default => [ :clean, :spec, :rdoc, :gem]
|
13
14
|
|
14
15
|
desc "Clean generated files"
|
15
16
|
task :clean do
|
@@ -17,32 +18,45 @@ task :clean do
|
|
17
18
|
rm_rf 'doc'
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
-
Rake::
|
22
|
-
t.
|
23
|
-
t.
|
24
|
-
|
21
|
+
desc 'Run all specs'
|
22
|
+
Spec::Rake::SpecTask.new('spec') do |t|
|
23
|
+
t.spec_opts = ['--format', 'specdoc', '--colour']
|
24
|
+
# t.libs = ["lib", "server/lib" ]
|
25
|
+
t.spec_files = Dir['spec/**/*_spec.rb'].sort
|
26
|
+
end
|
25
27
|
|
26
28
|
# Generate the RDoc documentation
|
27
|
-
Rake::RDocTask.new { |rdoc|
|
29
|
+
# Rake::RDocTask.new { |rdoc|
|
30
|
+
# rdoc.rdoc_dir = 'doc'
|
31
|
+
# rdoc.title = 'rWebUnit'
|
32
|
+
# rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
33
|
+
# rdoc.rdoc_files.include('README')
|
34
|
+
# rdoc.rdoc_files.include('lib/rwebunit.rb')
|
35
|
+
# rdoc.rdoc_files.include('lib/rwebunit/*.rb')
|
36
|
+
# }
|
37
|
+
|
38
|
+
# using DarkFish - http://deveiate.org/projects/Darkfish-Rdoc/
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
28
40
|
rdoc.rdoc_dir = 'doc'
|
29
41
|
rdoc.title = 'rWebUnit'
|
30
|
-
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
31
|
-
rdoc.rdoc_files.include('README')
|
32
42
|
rdoc.rdoc_files.include('lib/rwebunit.rb')
|
33
43
|
rdoc.rdoc_files.include('lib/rwebunit/*.rb')
|
34
|
-
|
44
|
+
rdoc.options += [
|
45
|
+
'-SHN',
|
46
|
+
'-f', 'darkfish', # This is the important bit
|
47
|
+
]
|
48
|
+
end
|
35
49
|
|
36
50
|
spec = Gem::Specification.new do |s|
|
37
51
|
s.platform= Gem::Platform::RUBY
|
38
52
|
s.name = "rwebunit"
|
39
|
-
s.version = "1.0
|
53
|
+
s.version = "1.3.0"
|
40
54
|
s.summary = "An wrap of WATIR/FireWatir for functional testing of web applications"
|
41
|
-
# s.description = ""
|
55
|
+
# s.description = ""
|
42
56
|
|
43
57
|
s.author = "Zhimin Zhan"
|
44
58
|
s.email = "zhimin@agileway.net"
|
45
|
-
s.homepage= "http://
|
59
|
+
s.homepage= "http://github.com/zhimin/rwebunit/tree/master"
|
46
60
|
s.rubyforge_project = "rwebunit"
|
47
61
|
|
48
62
|
s.has_rdoc = true
|
@@ -51,19 +65,17 @@ spec = Gem::Specification.new do |s|
|
|
51
65
|
s.autorequire = "rwebunit"
|
52
66
|
|
53
67
|
s.files = [ "Rakefile", "README", "CHANGELOG", "MIT-LICENSE" ]
|
54
|
-
|
55
|
-
s.files = s.files + Dir.glob( "
|
56
|
-
s.files = s.files + Dir.glob( "
|
57
|
-
s.files = s.files + Dir.glob( "
|
58
|
-
s.
|
59
|
-
s.add_dependency(%q<rspec>, ["= 1.1.4"])
|
68
|
+
s.files = s.files + Dir.glob( "lib/**/*" )
|
69
|
+
s.files = s.files + Dir.glob( "test/**/*" )
|
70
|
+
s.files = s.files + Dir.glob( "sample/**/*")
|
71
|
+
s.files = s.files + Dir.glob( "docs/**/*" )
|
72
|
+
s.add_dependency(%q<rspec>, ["= 1.1.12"])
|
60
73
|
s.add_dependency("commonwatir", ">= 1.6.2")
|
61
|
-
|
62
|
-
# s.add_dependency("
|
74
|
+
s.add_dependency("test-unit", ">= 2.0.2")
|
75
|
+
# s.add_dependency("watir", ">= 1.6.2")
|
76
|
+
# s.add_dependency("firewatir", ">= 1.6.2")
|
63
77
|
end
|
64
78
|
|
65
79
|
Rake::GemPackageTask.new(spec) do |pkg|
|
66
80
|
pkg.need_zip = true
|
67
81
|
end
|
68
|
-
|
69
|
-
|
data/lib/rspec_extensions.rb
CHANGED
@@ -11,105 +11,41 @@ module Spec
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
# For RSpec 1.1.12
|
15
15
|
module Spec
|
16
|
-
module
|
17
|
-
module
|
18
|
-
|
19
|
-
alias_method :scenario, :it
|
20
|
-
alias_method :story, :it
|
21
|
-
alias_method :test_case, :it
|
22
|
-
alias_method :test, :it
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
16
|
+
module DSL
|
17
|
+
module Main
|
26
18
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
find_above(source, line_number, /^\s*(context|describe|specification|spec|test_suite|suite)\s+(.*)\s+do/)
|
32
|
-
end
|
19
|
+
alias :spec :describe
|
20
|
+
alias :specification :describe
|
21
|
+
alias :test_suite :describe
|
22
|
+
alias :suite :describe
|
33
23
|
|
34
|
-
def example_at_line(source, line_number)
|
35
|
-
find_above(source, line_number, /^\s*(specify|it|story|scenario|test_case|test)\s+(.*)\s+do/)
|
36
|
-
end
|
37
24
|
end
|
38
25
|
end
|
39
26
|
end
|
40
27
|
|
28
|
+
# ZZ patches to RSpec 1.1.4
|
29
|
+
# - add to_s method to example_group
|
41
30
|
module Spec
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
31
|
+
module Example
|
32
|
+
class ExampleGroup
|
33
|
+
def to_s
|
34
|
+
@_defined_description
|
47
35
|
end
|
48
36
|
end
|
37
|
+
end
|
49
38
|
end
|
50
39
|
|
51
40
|
module Spec
|
52
|
-
|
53
|
-
|
54
|
-
def translate_line(line)
|
55
|
-
# Translate deprecated mock constraints
|
56
|
-
line.gsub!(/:any_args/, 'any_args')
|
57
|
-
line.gsub!(/:anything/, 'anything')
|
58
|
-
line.gsub!(/:boolean/, 'boolean')
|
59
|
-
line.gsub!(/:no_args/, 'no_args')
|
60
|
-
line.gsub!(/:numeric/, 'an_instance_of(Numeric)')
|
61
|
-
line.gsub!(/:string/, 'an_instance_of(String)')
|
62
|
-
|
63
|
-
return line if line =~ /(should_not|should)_receive/
|
64
|
-
|
65
|
-
line.gsub!(/(^\s*)context([\s*|\(]['|"|A-Z])/, '\1describe\2')
|
66
|
-
line.gsub!(/(^\s*)test_suite([\s*|\(]['|"|A-Z])/, '\1describe\2')
|
67
|
-
line.gsub!(/(^\s*)suite([\s*|\(]['|"|A-Z])/, '\1describe\2')
|
68
|
-
line.gsub!(/(^\s*)spec([\s*|\(]['|"|A-Z])/, '\1describe\2') #new
|
69
|
-
line.gsub!(/(^\s*)specification([\s*|\(]['|"|A-Z])/, '\1describe\2') #new
|
70
|
-
line.gsub!(/(^\s*)specify([\s*|\(]['|"|A-Z])/, '\1it\2')
|
71
|
-
line.gsub!(/(^\s*)scenario([\s*|\(]['|"|A-Z])/, '\1it\2') #new
|
72
|
-
line.gsub!(/(^\s*)story([\s*|\(]['|"|A-Z])/, '\1it\2') #new
|
73
|
-
line.gsub!(/(^\s*)test_case([\s*|\(]['|"|A-Z])/, '\1it\2') #new
|
74
|
-
line.gsub!(/(^\s*)test([\s*|\(]['|"|A-Z])/, '\1it\2') #new
|
75
|
-
line.gsub!(/(^\s*)context_setup(\s*[do|\{])/, '\1before(:all)\2')
|
76
|
-
line.gsub!(/(^\s*)context_teardown(\s*[do|\{])/, '\1after(:all)\2')
|
77
|
-
line.gsub!(/(^\s*)setup(\s*[do|\{])/, '\1before(:each)\2')
|
78
|
-
line.gsub!(/(^\s*)teardown(\s*[do|\{])/, '\1after(:each)\2')
|
79
|
-
|
80
|
-
if line =~ /(.*\.)(should_not|should)(?:_be)(?!_)(.*)/m
|
81
|
-
pre = $1
|
82
|
-
should = $2
|
83
|
-
post = $3
|
84
|
-
be_or_equal = post =~ /(<|>)/ ? "be" : "equal"
|
85
|
-
|
86
|
-
return "#{pre}#{should} #{be_or_equal}#{post}"
|
87
|
-
end
|
88
|
-
|
89
|
-
if line =~ /(.*\.)(should_not|should)_(?!not)\s*(.*)/m
|
90
|
-
pre = $1
|
91
|
-
should = $2
|
92
|
-
post = $3
|
93
|
-
|
94
|
-
post.gsub!(/^raise/, 'raise_error')
|
95
|
-
post.gsub!(/^throw/, 'throw_symbol')
|
96
|
-
|
97
|
-
unless standard_matcher?(post)
|
98
|
-
post = "be_#{post}"
|
99
|
-
end
|
100
|
-
|
101
|
-
# Add parenthesis
|
102
|
-
post.gsub!(/^(\w+)\s+([\w|\.|\,|\(.*\)|\'|\"|\:|@| ]+)(\})/, '\1(\2)\3') # inside a block
|
103
|
-
post.gsub!(/^(redirect_to)\s+(.*)/, '\1(\2)') # redirect_to, which often has http:
|
104
|
-
post.gsub!(/^(\w+)\s+([\w|\.|\,|\(.*\)|\{.*\}|\'|\"|\:|@| ]+)/, '\1(\2)')
|
105
|
-
post.gsub!(/(\s+\))/, ')')
|
106
|
-
post.gsub!(/\)\}/, ') }')
|
107
|
-
post.gsub!(/^(\w+)\s+(\/.*\/)/, '\1(\2)') #regexps
|
108
|
-
line = "#{pre}#{should} #{post}"
|
109
|
-
end
|
41
|
+
module Example
|
42
|
+
module ExampleGroupMethods
|
110
43
|
|
111
|
-
|
44
|
+
alias_method :scenario, :it
|
45
|
+
alias_method :story, :it
|
46
|
+
alias_method :test_case, :it
|
47
|
+
alias_method :use_case, :it
|
48
|
+
alias_method :test, :it
|
112
49
|
end
|
113
50
|
end
|
114
|
-
end
|
115
|
-
|
51
|
+
end
|