rwebspec-webdriver 0.4 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/Rakefile +5 -5
- data/lib/rwebspec-webdriver.rb +1 -1
- data/lib/rwebspec-webdriver/driver.rb +4 -2
- data/lib/rwebspec-webdriver/test_utils.rb +37 -1
- data/lib/rwebspec-webdriver/testwise_plugin.rb +1 -0
- metadata +3 -2
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 'rdoc/task'
|
4
4
|
require 'rake/gempackagetask'
|
5
5
|
require 'rdoc' # require rdoc 2
|
@@ -22,10 +22,10 @@ task :clean do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
desc 'Run all specs'
|
25
|
-
|
25
|
+
RSpec::Core::RakeTask.new('spec') do |t|
|
26
26
|
t.spec_opts = ['--format', 'specdoc', '--colour']
|
27
27
|
# t.libs = ["lib", "server/lib" ]
|
28
|
-
t.
|
28
|
+
t.pattern = Dir['spec/**/*_spec.rb'].sort
|
29
29
|
end
|
30
30
|
|
31
31
|
# Generate the RDoc documentation
|
@@ -41,7 +41,7 @@ end
|
|
41
41
|
# using DarkFish - http://deveiate.org/projects/Darkfish-Rdoc/
|
42
42
|
Rake::RDocTask.new do |rdoc|
|
43
43
|
rdoc.rdoc_dir = 'doc'
|
44
|
-
rdoc.title = 'RWebSpec'
|
44
|
+
rdoc.title = 'RWebSpec-WebDriver'
|
45
45
|
rdoc.rdoc_files.include('lib/rwebspec-webdriver.rb')
|
46
46
|
rdoc.rdoc_files.include('lib/rwebspec-webdriver/*.rb')
|
47
47
|
rdoc.rdoc_files.delete("lib/rwebspec-webdriver/web_testcase.rb")
|
@@ -69,7 +69,7 @@ end
|
|
69
69
|
spec = Gem::Specification.new do |s|
|
70
70
|
s.platform= Gem::Platform::RUBY
|
71
71
|
s.name = "rwebspec-webdriver"
|
72
|
-
s.version = "0.4"
|
72
|
+
s.version = "0.4.2"
|
73
73
|
s.summary = "Executable functional specification for web applications in RSpec syntax and Selenium-WebDriver"
|
74
74
|
# s.description = ""
|
75
75
|
|
data/lib/rwebspec-webdriver.rb
CHANGED
@@ -75,13 +75,15 @@ module RWebSpec
|
|
75
75
|
else
|
76
76
|
@web_browser = WebBrowser.reuse(uri_base, options) # Reuse existing browser
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
if base_url =~ /^file:/
|
80
80
|
goto_url(base_url) # for files, no base url
|
81
81
|
else
|
82
82
|
(uri.path.length == 0) ? begin_at(base_url) : begin_at(uri.path) if options[:go]
|
83
83
|
end
|
84
84
|
|
85
|
+
# remembering browser handle for debugging need
|
86
|
+
$browser = @web_browser
|
85
87
|
return @web_browser
|
86
88
|
end
|
87
89
|
|
@@ -218,7 +220,7 @@ module RWebSpec
|
|
218
220
|
# use_current_browser(:title, /.*/) # use what ever browser window
|
219
221
|
# use_current_browser(:title, "TestWise") # use browser window with title "TestWise"
|
220
222
|
def use_current_browser(how = :title, what = /.*/)
|
221
|
-
@web_browser = WebBrowser.attach_browser(how, what)
|
223
|
+
@web_browser = $browser || WebBrowser.attach_browser(how, what)
|
222
224
|
end
|
223
225
|
|
224
226
|
[:back, :forward, :refresh].each do |method|
|
@@ -370,7 +370,43 @@ module RWebSpec
|
|
370
370
|
array.inject(0.0) { |sum, e| sum + e }
|
371
371
|
end
|
372
372
|
|
373
|
-
|
373
|
+
## Data Driven Tests
|
374
|
+
#
|
375
|
+
# Processing each row in a CSV file, must have heading rows
|
376
|
+
#
|
377
|
+
# Usage:
|
378
|
+
#
|
379
|
+
# process_each_row_in_csv_file(@csv_file) { |row|
|
380
|
+
# goto_page("/")
|
381
|
+
# enter_text("username", row[1])
|
382
|
+
# enter_text("password", row[2])
|
383
|
+
# click_button("Sign in")
|
384
|
+
# page_text.should contain(row[3])
|
385
|
+
# failsafe{ click_link("Sign off") }
|
386
|
+
# }
|
387
|
+
#
|
388
|
+
def process_each_row_in_csv_file(csv_file, &block)
|
389
|
+
require 'faster_csv'
|
390
|
+
connect_to_testwise("CSV_START", csv_file) if $testwise_support
|
391
|
+
has_error = false
|
392
|
+
idx = 0
|
393
|
+
FasterCSV.foreach(csv_file, :headers => :first_row, :encoding => 'u') do |row|
|
394
|
+
connect_to_testwise("CSV_ON_ROW", idx.to_s) if $testwise_support
|
395
|
+
begin
|
396
|
+
yield row
|
397
|
+
connect_to_testwise("CSV_ROW_PASS", idx.to_s) if $testwise_support
|
398
|
+
rescue => e
|
399
|
+
connect_to_testwise("CSV_ROW_FAIL", idx.to_s) if $testwise_support
|
400
|
+
has_error = true
|
401
|
+
ensure
|
402
|
+
idx += 1
|
403
|
+
end
|
404
|
+
end
|
405
|
+
|
406
|
+
connect_to_testwise("CSV_END", "") if $testwise_support
|
407
|
+
raise "Test failed on data" if has_error
|
408
|
+
end
|
409
|
+
|
374
410
|
end
|
375
411
|
end
|
376
412
|
end
|
metadata
CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
|
8
|
+
- 2
|
9
|
+
version: 0.4.2
|
9
10
|
platform: ruby
|
10
11
|
authors:
|
11
12
|
- Zhimin Zhan
|
@@ -13,7 +14,7 @@ autorequire: rwebspec-webdriver
|
|
13
14
|
bindir: bin
|
14
15
|
cert_chain: []
|
15
16
|
|
16
|
-
date: 2012-
|
17
|
+
date: 2012-06-16 00:00:00 +10:00
|
17
18
|
default_executable:
|
18
19
|
dependencies:
|
19
20
|
- !ruby/object:Gem::Dependency
|