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 CHANGED
@@ -1,6 +1,9 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ == 0.4.2
5
+ [Feature] use_current_browser will try to use $browser
6
+
4
7
  == 0.3.7
5
8
  [Fix] remove window_script_extenions (calling Watir)
6
9
 
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- require 'spec/rake/spectask'
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
- Spec::Rake::SpecTask.new('spec') do |t|
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.spec_files = Dir['spec/**/*_spec.rb'].sort
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
 
@@ -17,7 +17,7 @@ require 'rspec'
17
17
  require 'selenium-webdriver'
18
18
 
19
19
  unless defined? RWEBSPEC_WEBDRIVER_VERSION
20
- RWEBSPEC_WEBDRIVER_VERSION = "0.4"
20
+ RWEBSPEC_WEBDRIVER_VERSION = "0.4.2"
21
21
  end
22
22
 
23
23
 
@@ -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
@@ -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 WebDriver
metadata CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- version: "0.4"
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-05-28 00:00:00 +10:00
17
+ date: 2012-06-16 00:00:00 +10:00
17
18
  default_executable:
18
19
  dependencies:
19
20
  - !ruby/object:Gem::Dependency