rwebspec 3.1.4 → 4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,15 @@
1
- #
2
- # clickJSDialog.rb
3
- #
4
- #
5
- # This file contains the JS clicker when it runs as a separate process
6
- require 'watir/winClicker'
7
-
8
- button = "OK"
9
- button = ARGV[0] unless ARGV[0] == nil
10
- sleepTime = 0
11
- sleepTime = ARGV[1] unless ARGV[1] == nil
12
-
13
- clicker= WinClicker.new
14
- result = clicker.clickJavaScriptDialog( button )
15
- clicker = nil
1
+ #
2
+ # clickJSDialog.rb
3
+ #
4
+ #
5
+ # This file contains the JS clicker when it runs as a separate process
6
+ require 'watir/winClicker'
7
+
8
+ button = "OK"
9
+ button = ARGV[0] unless ARGV[0] == nil
10
+ sleepTime = 0
11
+ sleepTime = ARGV[1] unless ARGV[1] == nil
12
+
13
+ clicker= WinClicker.new
14
+ result = clicker.clickJavaScriptDialog( button )
15
+ clicker = nil
@@ -1,24 +1,24 @@
1
- #***********************************************************
2
- #* Copyright (c) 2006 - 2009 Zhimin Zhan.
3
- #* Distributed open-source, see full license in MIT-LICENSE
4
- #***********************************************************
5
-
6
- module RWebSpec
7
-
8
- ##
9
- # Store test optionns
10
- #
11
- class Context
12
- attr_accessor :base_url
13
-
14
- def initialize(base_url)
15
- set_base_url(base_url)
16
- end
17
-
18
- def set_base_url(baseUrl)
19
- @base_url = baseUrl
20
- end
21
-
22
- end
23
-
24
- end
1
+ #***********************************************************
2
+ #* Copyright (c) 2006 - 2009 Zhimin Zhan.
3
+ #* Distributed open-source, see full license in MIT-LICENSE
4
+ #***********************************************************
5
+
6
+ module RWebSpec
7
+
8
+ ##
9
+ # Store test optionns
10
+ #
11
+ class Context
12
+ attr_accessor :base_url
13
+
14
+ def initialize(base_url)
15
+ set_base_url(base_url)
16
+ end
17
+
18
+ def set_base_url(baseUrl)
19
+ @base_url = baseUrl
20
+ end
21
+
22
+ end
23
+
24
+ end
File without changes
@@ -1,96 +1,96 @@
1
- require 'uri'
2
-
3
- # ZZ patches to RSpec 1.1.2 - 1.1.4
4
- # - add to_s method to example_group
5
- module Spec
6
- module Example
7
- class ExampleGroup
8
- def to_s
9
- @_defined_description
10
- end
11
- end
12
- end
13
- end
14
-
15
- # example
16
- # should link_by_text(text, options).size > 0
17
-
18
- module RWebSpec
19
- module RSpecHelper
20
- include RWebSpec::Driver
21
- include RWebSpec::Utils
22
- include RWebSpec::Assert
23
-
24
- # --
25
- # Content
26
- # --
27
-
28
- def table_source(table_id)
29
- table(:id, table_id).innerHTML
30
- # elem = @web_browser.document.getElementById(table_id)
31
- # raise "The element '#{table_id}' is not a table or there are multple elements with same id" unless elem.name.uppercase == "TABLE"
32
- # elem.innerHTML
33
- end
34
- alias table_source_by_id table_source
35
-
36
- def element_text(elem_id)
37
- @web_browser.element_value(elem_id)
38
- end
39
- alias element_text_by_id element_text
40
-
41
- #TODO: is it working?
42
- def element_source(elem_id)
43
- @web_browser.get_html_in_element(elem_id)
44
- end
45
-
46
-
47
- def button_by_id(button_id)
48
- button(:id, button_id)
49
- end
50
-
51
- def buttons_by_caption(text)
52
- button(:text, text)
53
- end
54
- alias buttons_by_text buttons_by_caption
55
-
56
- def link_by_id(link_id)
57
- link(:id, link_id)
58
- end
59
-
60
- # default options: exact => true
61
- def links_by_text(link_text, options = {})
62
- options.merge!({:exact=> true})
63
- matching_links = []
64
- links.each { |link|
65
- matching_links << link if (options[:exact] ? link.text == link_text : link.text.include?(link_text))
66
- }
67
- return matching_links
68
- end
69
- alias links_with_text links_by_text
70
-
71
- def save_page(file_name = nil)
72
- @web_browser.save_page(file_name)
73
- end
74
-
75
- def save_content_to_file(content, file_name = nil)
76
- file_name ||= Time.now.strftime("%Y%m%d%H%M%S") + ".html"
77
- puts "about to save page: #{File.expand_path(file_name)}"
78
- File.open(file_name, "w").puts content
79
- end
80
-
81
- # When running
82
- def debugging?
83
- ($TESTWISE_DEBUGGING && $TESTWISE_RUNNING_AS == "test_case")
84
- end
85
-
86
- # RSpec Matchers
87
- #
88
- # Example,
89
- # a_number.should be_odd_number
90
- def be_odd_number
91
- simple_matcher("must be odd number") { |actual| actual && actual.to_id % 2 == 1}
92
- end
93
-
94
- end
95
-
96
- end
1
+ require 'uri'
2
+
3
+ # ZZ patches to RSpec 1.1.2 - 1.1.4
4
+ # - add to_s method to example_group
5
+ module Spec
6
+ module Example
7
+ class ExampleGroup
8
+ def to_s
9
+ @_defined_description
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ # example
16
+ # should link_by_text(text, options).size > 0
17
+
18
+ module RWebSpec
19
+ module RSpecHelper
20
+ include RWebSpec::Driver
21
+ include RWebSpec::Utils
22
+ include RWebSpec::Assert
23
+
24
+ # --
25
+ # Content
26
+ # --
27
+
28
+ def table_source(table_id)
29
+ table(:id, table_id).innerHTML
30
+ # elem = @web_browser.document.getElementById(table_id)
31
+ # raise "The element '#{table_id}' is not a table or there are multple elements with same id" unless elem.name.uppercase == "TABLE"
32
+ # elem.innerHTML
33
+ end
34
+ alias table_source_by_id table_source
35
+
36
+ def element_text(elem_id)
37
+ @web_browser.element_value(elem_id)
38
+ end
39
+ alias element_text_by_id element_text
40
+
41
+ #TODO: is it working?
42
+ def element_source(elem_id)
43
+ @web_browser.get_html_in_element(elem_id)
44
+ end
45
+
46
+
47
+ def button_by_id(button_id)
48
+ button(:id, button_id)
49
+ end
50
+
51
+ def buttons_by_caption(text)
52
+ button(:text, text)
53
+ end
54
+ alias buttons_by_text buttons_by_caption
55
+
56
+ def link_by_id(link_id)
57
+ link(:id, link_id)
58
+ end
59
+
60
+ # default options: exact => true
61
+ def links_by_text(link_text, options = {})
62
+ options.merge!({:exact=> true})
63
+ matching_links = []
64
+ links.each { |link|
65
+ matching_links << link if (options[:exact] ? link.text == link_text : link.text.include?(link_text))
66
+ }
67
+ return matching_links
68
+ end
69
+ alias links_with_text links_by_text
70
+
71
+ def save_page(file_name = nil)
72
+ @web_browser.save_page(file_name)
73
+ end
74
+
75
+ def save_content_to_file(content, file_name = nil)
76
+ file_name ||= Time.now.strftime("%Y%m%d%H%M%S") + ".html"
77
+ puts "about to save page: #{File.expand_path(file_name)}"
78
+ File.open(file_name, "w").puts content
79
+ end
80
+
81
+ # When running
82
+ def debugging?
83
+ ($TESTWISE_DEBUGGING && $TESTWISE_RUNNING_AS == "test_case")
84
+ end
85
+
86
+ # RSpec Matchers
87
+ #
88
+ # Example,
89
+ # a_number.should be_odd_number
90
+ def be_odd_number
91
+ simple_matcher("must be odd number") { |actual| actual && actual.to_id % 2 == 1}
92
+ end
93
+
94
+ end
95
+
96
+ end
File without changes