rwebspec 3.1.0 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/Rakefile +4 -4
- data/lib/plugins/testwise_plugin.rb +4 -3
- data/lib/rwebspec/driver.rb +13 -13
- data/lib/rwebspec/rspec_helper.rb +1 -1
- data/lib/rwebspec/test_utils.rb +38 -0
- data/lib/rwebspec/web_browser.rb +4 -4
- data/lib/rwebspec/web_page.rb +2 -2
- data/lib/rwebspec.rb +1 -1
- metadata +3 -3
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
2
|
+
require 'rspec/core/rake_task'
|
3
3
|
require 'rake/rdoctask'
|
4
4
|
require 'rake/gempackagetask'
|
5
5
|
require 'rdoc' # require rdoc 2
|
@@ -23,10 +23,10 @@ task :clean do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
desc 'Run all specs'
|
26
|
-
|
26
|
+
RSpec::Core::RakeTask.new('spec') do |t|
|
27
27
|
t.spec_opts = ['--format', 'specdoc', '--colour']
|
28
28
|
# t.libs = ["lib", "server/lib" ]
|
29
|
-
t.
|
29
|
+
t.pattern = Dir['spec/**/*_spec.rb'].sort
|
30
30
|
end
|
31
31
|
|
32
32
|
# Generate the RDoc documentation
|
@@ -71,7 +71,7 @@ end
|
|
71
71
|
spec = Gem::Specification.new do |s|
|
72
72
|
s.platform= Gem::Platform::RUBY
|
73
73
|
s.name = "rwebspec"
|
74
|
-
s.version = "3.1.
|
74
|
+
s.version = "3.1.3"
|
75
75
|
s.summary = "Web application functional specification in Ruby"
|
76
76
|
s.description = "Executable functional specification for web applications in RSpec syntax and Watir"
|
77
77
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'socket'
|
2
2
|
|
3
3
|
MAX_MESSAGE_LENGTH = 8192 # < 10K
|
4
|
+
$testwise_support = true
|
4
5
|
|
5
6
|
module RWebSpec
|
6
7
|
module TestWisePlugin
|
@@ -28,7 +29,7 @@ module RWebSpec
|
|
28
29
|
sleep($TESTWISE_OPERATION_DELAY / 1000)
|
29
30
|
end
|
30
31
|
|
31
|
-
while $TESTWISE_PAUSE
|
32
|
+
while $TESTWISE_PAUSE
|
32
33
|
Thread.pass
|
33
34
|
debug("Paused, waiting ...")
|
34
35
|
sleep 1
|
@@ -45,7 +46,7 @@ module RWebSpec
|
|
45
46
|
|
46
47
|
# find out the line (and file) the execution is on, and notify iTest via Socket
|
47
48
|
def dump_caller_stack
|
48
|
-
return unless ($TESTWISE_TRACE_EXECUTION
|
49
|
+
return unless ($TESTWISE_TRACE_EXECUTION)
|
49
50
|
begin
|
50
51
|
trace_lines = []
|
51
52
|
trace_file = nil
|
@@ -83,7 +84,7 @@ module RWebSpec
|
|
83
84
|
if @last_message == the_message then # ignore the message same as preivous one
|
84
85
|
return
|
85
86
|
end
|
86
|
-
itest_port = $TESTWISE_TRACE_PORT ||
|
87
|
+
itest_port = $TESTWISE_TRACE_PORT || 7025
|
87
88
|
itest_socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
|
88
89
|
itest_socket.connect(Socket.pack_sockaddr_in(itest_port, '127.0.0.1'))
|
89
90
|
itest_socket.puts(the_message)
|
data/lib/rwebspec/driver.rb
CHANGED
@@ -38,7 +38,7 @@ module RWebSpec
|
|
38
38
|
end
|
39
39
|
|
40
40
|
base_url ||= $TESTWISE_PROJECT_BASE_URL
|
41
|
-
base_url ||= $
|
41
|
+
base_url ||= $TESTWISE_PROJECT_BASE_URL
|
42
42
|
base_url ||= $BASE_URL
|
43
43
|
raise "base_url must be set" if base_url.nil?
|
44
44
|
|
@@ -50,8 +50,8 @@ module RWebSpec
|
|
50
50
|
:go => true}
|
51
51
|
|
52
52
|
options = default_options.merge options
|
53
|
-
options[:firefox] = true if "Firefox" == $
|
54
|
-
($TESTWISE_HIDE_BROWSER || $
|
53
|
+
options[:firefox] = true if "Firefox" == $TESTWISE_BROWSER || "Firefox" == $TESTWISE_BROWSER || "Firefox" == $BROWSER
|
54
|
+
($TESTWISE_HIDE_BROWSER || $TESTWISE_HIDE_BROWSER) ? $HIDE_IE = true : $HIDE_IE = false
|
55
55
|
|
56
56
|
if base_url =~ /^file:/
|
57
57
|
uri_base = base_url
|
@@ -89,7 +89,7 @@ module RWebSpec
|
|
89
89
|
def close_browser
|
90
90
|
if @web_browser
|
91
91
|
# Old TestWise version
|
92
|
-
# @web_browser.close_browser unless $
|
92
|
+
# @web_browser.close_browser unless $TESTWISE_LEAVE_BROWSER_OPEN_AFTER_RUN
|
93
93
|
@web_browser.close_browser
|
94
94
|
else
|
95
95
|
close_all_browsers
|
@@ -104,7 +104,7 @@ module RWebSpec
|
|
104
104
|
if @web_browser
|
105
105
|
Watir::IE.close_all
|
106
106
|
else
|
107
|
-
browser_type = $
|
107
|
+
browser_type = $TESTWISE_BROWSER ? $TESTWISE_BROWSER.downcase.to_sym : :ie
|
108
108
|
WebBrowser.close_all_browsers(browser_type)
|
109
109
|
end
|
110
110
|
end
|
@@ -185,7 +185,7 @@ module RWebSpec
|
|
185
185
|
if url && url =~ /^http/
|
186
186
|
http_response = client.get(url).body
|
187
187
|
else
|
188
|
-
base_url = $TESTWISE_PROJECT_BASE_URL || $
|
188
|
+
base_url = $TESTWISE_PROJECT_BASE_URL || $TESTWISE_PROJECT_BASE_URL || $BASE_URL
|
189
189
|
http_response = client.get("#{base_url}#{url}").body
|
190
190
|
end
|
191
191
|
|
@@ -281,14 +281,14 @@ module RWebSpec
|
|
281
281
|
alias go_back back
|
282
282
|
alias go_forward forward
|
283
283
|
|
284
|
-
[:images, :links, :buttons, :select_lists, :checkboxes, :radios, :text_fields, :divs, :dls, :dds, :dts, :ems, :lis, :maps, :spans, :strongs, :ps, :pres, :labels, :
|
284
|
+
[:images, :links, :buttons, :select_lists, :checkboxes, :radios, :text_fields, :divs, :dls, :dds, :dts, :ems, :lis, :maps, :spans, :strongs, :ps, :pres, :labels, :tds, :trs].each do |method|
|
285
285
|
define_method method do
|
286
286
|
perform_operation { @web_browser.send(method) if @web_browser }
|
287
287
|
end
|
288
288
|
end
|
289
289
|
alias as links
|
290
|
-
alias trs
|
291
|
-
alias tds
|
290
|
+
alias rows trs
|
291
|
+
alias cells tds
|
292
292
|
alias imgs images
|
293
293
|
|
294
294
|
|
@@ -386,12 +386,12 @@ module RWebSpec
|
|
386
386
|
end
|
387
387
|
|
388
388
|
def default_dump_dir
|
389
|
-
if ($TESTWISE_RUNNING_SPEC_ID && $TESTWISE_WORKING_DIR) || ($
|
389
|
+
if ($TESTWISE_RUNNING_SPEC_ID && $TESTWISE_WORKING_DIR) || ($TESTWISE_RUNNING_SPEC_ID && $TESTWISE_WORKING_DIR)
|
390
390
|
|
391
|
-
$TESTWISE_DUMP_DIR = $
|
392
|
-
FileUtils.mkdir($
|
391
|
+
$TESTWISE_DUMP_DIR = $TESTWISE_DUMP_DIR = File.join($TESTWISE_WORKING_DIR, "dump")
|
392
|
+
FileUtils.mkdir($TESTWISE_DUMP_DIR) unless File.exists?($TESTWISE_DUMP_DIR)
|
393
393
|
|
394
|
-
spec_run_id = $TESTWISE_RUNNING_SPEC_ID || $
|
394
|
+
spec_run_id = $TESTWISE_RUNNING_SPEC_ID || $TESTWISE_RUNNING_SPEC_ID
|
395
395
|
spec_run_dir_name = spec_run_id.to_s.rjust(4, "0") unless spec_run_id == "unknown"
|
396
396
|
to_dir = File.join($TESTWISE_DUMP_DIR, spec_run_dir_name)
|
397
397
|
else
|
@@ -80,7 +80,7 @@ module RWebSpec
|
|
80
80
|
|
81
81
|
# When running
|
82
82
|
def debugging?
|
83
|
-
($
|
83
|
+
($TESTWISE_DEBUGGING && $TESTWISE_RUNNING_AS == "test_case")
|
84
84
|
end
|
85
85
|
|
86
86
|
# RSpec Matchers
|
data/lib/rwebspec/test_utils.rb
CHANGED
@@ -388,5 +388,43 @@ module RWebSpec
|
|
388
388
|
array.inject(0.0) { |sum, e| sum + e }
|
389
389
|
end
|
390
390
|
|
391
|
+
## Data Driven Tests
|
392
|
+
#
|
393
|
+
# Processing each row in a CSV file, must have heading rows
|
394
|
+
#
|
395
|
+
# Usage:
|
396
|
+
#
|
397
|
+
# process_each_row_in_csv_file(@csv_file) { |row|
|
398
|
+
# goto_page("/")
|
399
|
+
# enter_text("username", row[1])
|
400
|
+
# enter_text("password", row[2])
|
401
|
+
# click_button("Sign in")
|
402
|
+
# page_text.should contain(row[3])
|
403
|
+
# failsafe{ click_link("Sign off") }
|
404
|
+
# }
|
405
|
+
#
|
406
|
+
def process_each_row_in_csv_file(csv_file, &block)
|
407
|
+
require 'faster_csv'
|
408
|
+
connect_to_testwise("CSV_START", csv_file) if $testwise_support
|
409
|
+
has_error = false
|
410
|
+
idx = 0
|
411
|
+
FasterCSV.foreach(csv_file, :headers => :first_row, :encoding => 'u') do |row|
|
412
|
+
connect_to_testwise("CSV_ON_ROW", idx.to_s) if $testwise_support
|
413
|
+
begin
|
414
|
+
yield row
|
415
|
+
connect_to_testwise("CSV_ROW_PASS", idx.to_s) if $testwise_support
|
416
|
+
rescue => e
|
417
|
+
connect_to_testwise("CSV_ROW_FAIL", idx.to_s) if $testwise_support
|
418
|
+
has_error = true
|
419
|
+
ensure
|
420
|
+
idx += 1
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
connect_to_testwise("CSV_END", "") if $testwise_support
|
425
|
+
raise "Test failed on data" if has_error
|
426
|
+
end
|
427
|
+
|
428
|
+
|
391
429
|
end
|
392
430
|
end
|
data/lib/rwebspec/web_browser.rb
CHANGED
@@ -68,7 +68,7 @@ module RWebSpec
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def self.reuse(base_url, options)
|
71
|
-
if self.is_windows? && ($TESTWISE_BROWSER != "Firefox" && $
|
71
|
+
if self.is_windows? && ($TESTWISE_BROWSER != "Firefox" && $TESTWISE_BROWSER != "Firefox")
|
72
72
|
require 'watir-classic/ie'
|
73
73
|
# try to avoid
|
74
74
|
# lib/ruby/1.8/dl/win32.rb:11:in `sym': unknown type specifier 'v'
|
@@ -205,14 +205,14 @@ module RWebSpec
|
|
205
205
|
end
|
206
206
|
end
|
207
207
|
|
208
|
-
[:images, :links, :buttons, :select_lists, :checkboxes, :radios, :text_fields, :divs, :dls, :dds, :dts, :ems, :lis, :maps, :spans, :strongs, :ps, :pres, :labels, :
|
208
|
+
[:images, :links, :buttons, :select_lists, :checkboxes, :radios, :text_fields, :divs, :dls, :dds, :dts, :ems, :lis, :maps, :spans, :strongs, :ps, :pres, :labels, :tds, :trs].each do |method|
|
209
209
|
define_method method do
|
210
210
|
@browser.send(method)
|
211
211
|
end
|
212
212
|
end
|
213
213
|
alias as links
|
214
|
-
alias trs
|
215
|
-
alias tds
|
214
|
+
alias rows trs
|
215
|
+
alias cells tds
|
216
216
|
alias imgs images
|
217
217
|
|
218
218
|
# current url
|
data/lib/rwebspec/web_page.rb
CHANGED
@@ -34,8 +34,8 @@ module RWebSpec
|
|
34
34
|
@web_browser = @browser = @web_tester = the_browser
|
35
35
|
@page_specific_text = page_specific_text
|
36
36
|
begin
|
37
|
-
snapshot if $TESTWISE_DUMP_PAGE || $
|
38
|
-
delay = $TESTWISE_PAGE_DELAY || $
|
37
|
+
snapshot if $TESTWISE_DUMP_PAGE || $TESTWISE_DUMP_PAGE
|
38
|
+
delay = $TESTWISE_PAGE_DELAY || $TESTWISE_PAGE_DELAY
|
39
39
|
sleep(delay)
|
40
40
|
rescue => e
|
41
41
|
end
|
data/lib/rwebspec.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 3
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 3.1.
|
8
|
+
- 3
|
9
|
+
version: 3.1.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Zhimin Zhan
|
@@ -14,7 +14,7 @@ autorequire: rwebspec
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2012-
|
17
|
+
date: 2012-06-20 00:00:00 +10:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|