rwebspec 1.8.2 → 1.9

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  CHANGELOG
2
2
  =========
3
+ 1.9
4
+ [Upgrade] support Watir 2 syntax
5
+ alias tr row
6
+ alias a link
7
+
8
+
3
9
  1.8.2
4
10
  Add javascript_dialog in driver to support Watir 1.9
5
11
 
data/Rakefile CHANGED
@@ -70,7 +70,7 @@ end
70
70
  spec = Gem::Specification.new do |s|
71
71
  s.platform= Gem::Platform::RUBY
72
72
  s.name = "rwebspec"
73
- s.version = "1.8.2"
73
+ s.version = "1.9"
74
74
  s.summary = "Executable functional specification for web applications in RSpec syntax and Watir"
75
75
  # s.description = ""
76
76
 
@@ -279,6 +279,9 @@ module RWebSpec
279
279
  alias td cell
280
280
  alias check_box checkbox # seems watir doc is wrong, checkbox not check_box
281
281
  alias tr row
282
+ alias a link
283
+ alias img image
284
+
282
285
 
283
286
  [:back, :forward, :refresh].each do |method|
284
287
  define_method(method) do
@@ -289,12 +292,17 @@ module RWebSpec
289
292
  alias go_back back
290
293
  alias go_forward forward
291
294
 
292
- [:images, :links, :buttons, :select_lists, :checkboxes, :radios, :text_fields].each do |method|
295
+ [:images, :links, :buttons, :select_lists, :checkboxes, :radios, :text_fields, :divs, :dls, :dds, :dts, :ems, :lis, :maps, :spans, :strongs, :ps, :pres, :labels, :cells, :rows].each do |method|
293
296
  define_method method do
294
297
  perform_operation { @web_browser.send(method) if @web_browser }
295
298
  end
296
299
  end
300
+ alias as links
301
+ alias trs rows
302
+ alias tds cells
303
+ alias imgs images
297
304
 
305
+
298
306
  # Check one or more checkboxes with same name, can accept a string or an array of string as values checkbox, pass array as values will try to set mulitple checkboxes.
299
307
  #
300
308
  # page.check_checkbox('bad_ones', 'Chicken Little')
@@ -425,7 +433,7 @@ module RWebSpec
425
433
  current_url =~ /(.*\/).*$/
426
434
  current_url_parent = $1
427
435
  if options[:replacement] && base_url =~ /^http:/
428
- File.new(file, "w").puts absolutize_page_hpricot(content, base_url, current_url_parent)
436
+ File.new(file, "w").puts absolutize_page_nokogiri(content, base_url, current_url_parent)
429
437
  else
430
438
  File.new(file, "w").puts content
431
439
  end
@@ -474,6 +482,21 @@ module RWebSpec
474
482
  rescue => e
475
483
  absolutize_page(content, base_url, parent_url)
476
484
  end
485
+ end
486
+
487
+ def absolutize_page_nokogiri(content, base_url, parent_url)
488
+ return absolutize_page(content, base_url, parent_url) if RUBY_PLATFORM == 'java'
489
+ begin
490
+ require 'nokogiri'
491
+ doc = Nokogiri::HTML(content)
492
+ base_url.slice!(-1) if ends_with?(base_url, "/")
493
+ (doc/'link').each { |e| e['href'] = absolutify_url(e['href'], base_url, parent_url) || "" }
494
+ (doc/'img').each { |e| e['src'] = absolutify_url(e['src'], base_url, parent_url) || "" }
495
+ (doc/'script').each { |e| e['src'] = absolutify_url(e['src'], base_url, parent_url) || "" }
496
+ return doc.to_html
497
+ rescue => e
498
+ absolutize_page(content, base_url, parent_url)
499
+ end
477
500
  end
478
501
 
479
502
  ##
@@ -172,6 +172,8 @@ module RWebSpec
172
172
  alias td cell
173
173
  alias check_box checkbox # seems watir doc is wrong, checkbox not check_box
174
174
  alias tr row
175
+ alias a link
176
+ alias img image
175
177
 
176
178
  # Wrapp of Watir's area to support Firefox and Watir
177
179
  #
@@ -285,12 +287,16 @@ module RWebSpec
285
287
  end
286
288
  end
287
289
 
288
- [:images, :links, :buttons, :select_lists, :checkboxes, :radios, :text_fields, :divs, :dls, :dds, :dts, :ems, :lis, :maps, :spans, :strongs, :ps, :pres, :labels].each do |method|
290
+ [:images, :links, :buttons, :select_lists, :checkboxes, :radios, :text_fields, :divs, :dls, :dds, :dts, :ems, :lis, :maps, :spans, :strongs, :ps, :pres, :labels, :cells, :rows].each do |method|
289
291
  define_method method do
290
292
  @browser.send(method)
291
293
  end
292
294
  end
293
-
295
+ alias as links
296
+ alias trs rows
297
+ alias tds cells
298
+ alias imgs images
299
+
294
300
  # current url
295
301
  def url
296
302
  @browser.url
@@ -509,7 +515,11 @@ module RWebSpec
509
515
  if values
510
516
  values.class == Array ? arys = values : arys = [values]
511
517
  arys.each {|cbx_value|
512
- checkbox(:name, checkBoxName, cbx_value).set
518
+ if Watir::VERSION =~ /^1/ then
519
+ checkbox(:name, checkBoxName, cbx_value).set
520
+ else
521
+ checkbox(:name => checkBoxName, :value => cbx_value).set
522
+ end
513
523
  }
514
524
  else
515
525
  checkbox(:name, checkBoxName).set
@@ -524,7 +534,11 @@ module RWebSpec
524
534
  if values
525
535
  values.class == Array ? arys = values : arys = [values]
526
536
  arys.each {|cbx_value|
527
- checkbox(:name, checkBoxName, cbx_value).clear
537
+ if Watir::VERSION =~ /^1/ then
538
+ checkbox(:name, checkBoxName, cbx_value).clear
539
+ else
540
+ checkbox(:name => checkBoxName, :value => cbx_value).clear
541
+ end
528
542
  }
529
543
  else
530
544
  checkbox(:name, checkBoxName).clear
@@ -536,7 +550,11 @@ module RWebSpec
536
550
  # Usage:
537
551
  # click_radio_option("country", "Australia")
538
552
  def click_radio_option(radio_group, radio_option)
539
- radio(:name, radio_group, radio_option).set
553
+ if Watir::VERSION =~ /^1/ then
554
+ radio(:name, radio_group, radio_option).set
555
+ else
556
+ radio(:name => radio_group, :value => radio_option).set
557
+ end
540
558
  end
541
559
  alias click_radio_button click_radio_option
542
560
 
@@ -544,7 +562,11 @@ module RWebSpec
544
562
  # Usage:
545
563
  # click_radio_option("country", "Australia")
546
564
  def clear_radio_option(radio_group, radio_option)
547
- radio(:name, radio_group, radio_option).clear
565
+ if Watir::VERSION =~ /^2/ then
566
+ radio(:name => radio_group, :value => radio_option).clear
567
+ else
568
+ radio(:name, radio_group, radio_option).clear
569
+ end
548
570
  end
549
571
  alias clear_radio_button clear_radio_option
550
572
 
metadata CHANGED
@@ -1,13 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rwebspec
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
6
  - 1
8
- - 8
9
- - 2
10
- version: 1.8.2
7
+ - 9
8
+ version: "1.9"
11
9
  platform: ruby
12
10
  authors:
13
11
  - Zhimin Zhan
@@ -15,18 +13,16 @@ autorequire: rwebspec
15
13
  bindir: bin
16
14
  cert_chain: []
17
15
 
18
- date: 2011-07-06 00:00:00 +10:00
16
+ date: 2011-08-11 00:00:00 +10:00
19
17
  default_executable:
20
18
  dependencies:
21
19
  - !ruby/object:Gem::Dependency
22
20
  name: rspec
23
21
  prerelease: false
24
22
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - "="
28
25
  - !ruby/object:Gem::Version
29
- hash: 11
30
26
  segments:
31
27
  - 1
32
28
  - 1
@@ -38,11 +34,9 @@ dependencies:
38
34
  name: commonwatir
39
35
  prerelease: false
40
36
  requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ">="
44
39
  - !ruby/object:Gem::Version
45
- hash: 53
46
40
  segments:
47
41
  - 1
48
42
  - 8
@@ -94,27 +88,23 @@ rdoc_options: []
94
88
  require_paths:
95
89
  - lib
96
90
  required_ruby_version: !ruby/object:Gem::Requirement
97
- none: false
98
91
  requirements:
99
92
  - - ">="
100
93
  - !ruby/object:Gem::Version
101
- hash: 3
102
94
  segments:
103
95
  - 0
104
96
  version: "0"
105
97
  required_rubygems_version: !ruby/object:Gem::Requirement
106
- none: false
107
98
  requirements:
108
99
  - - ">="
109
100
  - !ruby/object:Gem::Version
110
- hash: 3
111
101
  segments:
112
102
  - 0
113
103
  version: "0"
114
104
  requirements:
115
105
  - none
116
106
  rubyforge_project: rwebspec
117
- rubygems_version: 1.4.2
107
+ rubygems_version: 1.3.6
118
108
  signing_key:
119
109
  specification_version: 3
120
110
  summary: Executable functional specification for web applications in RSpec syntax and Watir