celerity 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 4
3
- :major: 0
4
2
  :minor: 7
3
+ :patch: 5
4
+ :major: 0
data/celerity.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{celerity}
8
- s.version = "0.7.4"
8
+ s.version = "0.7.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jari Bakken", "T. Alexander Lystad", "Knut Johannes Dahle"]
12
- s.date = %q{2009-10-09}
12
+ s.date = %q{2009-10-27}
13
13
  s.description = %q{Celerity is a JRuby wrapper around HtmlUnit – a headless Java browser with JavaScript support. It provides a simple API for programmatic navigation through web applications. Celerity provides a superset of Watir's API.}
14
14
  s.email = %q{jari.bakken@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -80,6 +80,7 @@ Gem::Specification.new do |s|
80
80
  "lib/celerity/watir_compatibility.rb",
81
81
  "lib/celerity/xpath_support.rb",
82
82
  "tasks/benchmark.rake",
83
+ "tasks/check.rake",
83
84
  "tasks/clean.rake",
84
85
  "tasks/fix.rake",
85
86
  "tasks/jar.rake",
@@ -46,7 +46,7 @@ module Celerity
46
46
  # @option opts :secure_ssl [Boolean] (true) Enable/disable secure SSL. Enabled by default.
47
47
  # @option opts :status_code_exceptions [Boolean] (false) Raise exceptions on failing status codes (404 etc.). Disabled by default.
48
48
  # @option opts :user_agent [String] Override the User-Agent set by the :browser option
49
- # @option opts :viewer [Boolean] (true) Connect to a CelerityViewer on port 6429 if available.
49
+ # @option opts :viewer [String, false] ("127.0.0.1:6429") Connect to a CelerityViewer if available.
50
50
  #
51
51
  # @return [Celerity::Browser] An instance of the browser.
52
52
  #
@@ -181,8 +181,8 @@ module Celerity
181
181
 
182
182
  if @page.respond_to?("getContent")
183
183
  string = @page.getContent.strip
184
- elsif @page.documentElement
185
- string = @page.documentElement.asText.strip
184
+ elsif doc = @page.documentElement
185
+ string = doc.asText.strip
186
186
  else
187
187
  string = ''
188
188
  end
@@ -346,7 +346,7 @@ module Celerity
346
346
 
347
347
  cookie = HtmlUnit::Util::Cookie.new(domain, name, value, path, max_age, secure)
348
348
  @webclient.getCookieManager.addCookie cookie
349
-
349
+
350
350
  cookie
351
351
  end
352
352
 
@@ -492,9 +492,10 @@ module Celerity
492
492
  end
493
493
 
494
494
  def trace_javascript(debugger_klass = Celerity::JavascriptDebugger, &blk)
495
- @webclient.getJavaScriptEngine.getContextFactory.setDebugger debugger_klass.new
495
+ context_factory = @webclient.getJavaScriptEngine.getContextFactory
496
+ context_factory.setDebugger debugger_klass.new
496
497
  yield
497
- @webclient.getJavaScriptEngine.getContextFactory.setDebugger nil
498
+ context_factory.setDebugger nil
498
499
  end
499
500
 
500
501
  #
@@ -528,8 +529,8 @@ module Celerity
528
529
  listener.add_listener(type, &block)
529
530
  end
530
531
 
531
- def remove_listener(type, &block)
532
- listener.remove_listener(type, &block)
532
+ def remove_listener(type, block)
533
+ listener.remove_listener(type, block)
533
534
  end
534
535
 
535
536
  #
@@ -697,10 +698,6 @@ module Celerity
697
698
  @webclient.useInsecureSSL = !bool
698
699
  end
699
700
 
700
- def secure_ssl
701
- !@webclient.useInsecureSSL
702
- end
703
-
704
701
  #
705
702
  # Turn on/off JavaScript execution
706
703
  #
@@ -857,7 +854,7 @@ module Celerity
857
854
  if viewer = ViewerConnection.create(host, port.to_i)
858
855
  @viewer = viewer
859
856
  end
860
- rescue Errno::ECONNREFUSED => e
857
+ rescue Errno::ECONNREFUSED, SocketError => e
861
858
  nil
862
859
  end
863
860
 
@@ -750,20 +750,6 @@ module Celerity
750
750
 
751
751
  private
752
752
 
753
- #
754
- # Used internally.
755
- #
756
- # @param [String] string The string to match against.
757
- # @param [Regexp, String, #to_s] what The match we're looking for.
758
- # @return [Fixnum, true, false, nil]
759
- #
760
- # @api private
761
- #
762
-
763
- def matches?(string, what)
764
- Regexp === what ? string =~ what : string == what.to_s
765
- end
766
-
767
753
  #
768
754
  # Rescues HtmlUnit::FailingHttpStatusCodeException and re-raises as
769
755
  # Celerity::NavigationException to avoid the huge JRuby backtrace
@@ -10,9 +10,6 @@ module Celerity
10
10
 
11
11
  attr_reader :container
12
12
 
13
- # number of spaces that separate the property from the value in the create_string method
14
- TO_S_SIZE = 14
15
-
16
13
  # HTML 4.01 Transitional DTD
17
14
  HTML_401_TRANSITIONAL = {
18
15
  :core => [:class, :id, :style, :title],
@@ -124,7 +121,7 @@ module Celerity
124
121
 
125
122
  def to_s
126
123
  assert_exists
127
- create_string(@object)
124
+ Celerity::Util.create_string @object
128
125
  end
129
126
 
130
127
  #
@@ -134,7 +131,7 @@ module Celerity
134
131
 
135
132
  def attribute_value(attribute)
136
133
  assert_exists
137
- @object.getAttribute(attribute.to_s)
134
+ @object.getAttribute attribute.to_s
138
135
  end
139
136
 
140
137
  #
@@ -274,24 +271,6 @@ module Celerity
274
271
 
275
272
  private
276
273
 
277
- def create_string(element)
278
- ret = []
279
-
280
- unless (tag = element.getTagName).empty?
281
- ret << "tag:".ljust(TO_S_SIZE) + tag
282
- end
283
-
284
- element.getAttributes.each do |attribute|
285
- ret << " #{attribute.getName}:".ljust(TO_S_SIZE+2) + attribute.getValue.to_s
286
- end
287
-
288
- unless (text = element.asText).empty?
289
- ret << " text:".ljust(TO_S_SIZE+2) + element.asText
290
- end
291
-
292
- ret.join("\n")
293
- end
294
-
295
274
  def identifier_string
296
275
  if @conditions.size == 1
297
276
  how, what = @conditions.to_a.first
@@ -98,7 +98,7 @@ module Celerity
98
98
  end
99
99
 
100
100
  def find_by_label(what)
101
- obj = elements_by_tag_names(%w[label]).find { |e| matches?(e.asText, what) }
101
+ obj = elements_by_tag_names(%w[label]).find { |e| Util.matches?(e.asText, what) }
102
102
 
103
103
  return nil unless obj && (ref = obj.getReferencedElement)
104
104
  return ref if @tags.include?(ref.getTagName)
@@ -118,27 +118,13 @@ module Celerity
118
118
 
119
119
  def get_by_idents(meth, idents)
120
120
  with_nullpointer_retry do
121
- all_elements.send(meth) do |e|
122
- next unless @tags.include?(e.getTagName)
123
- idents.any? { |id| element_matches_ident?(e, id) }
121
+ all_elements.send(meth) do |element|
122
+ next unless @tags.include?(element.getTagName)
123
+ idents.any? { |id| id.match?(element) }
124
124
  end
125
125
  end
126
126
  end
127
127
 
128
- def element_matches_ident?(element, ident)
129
- return false unless ident.tag == element.getTagName
130
-
131
- attr_result = ident.attributes.all? do |key, values|
132
- values.any? { |val| matches?(element.getAttribute(key.to_s), val) }
133
- end
134
-
135
- if ident.text
136
- attr_result && matches?(element.asText.strip, ident.text)
137
- else
138
- attr_result
139
- end
140
- end
141
-
142
128
  def elements_by_tag_names(tags = @tags)
143
129
  with_nullpointer_retry do
144
130
  # HtmlUnit's getHtmlElementsByTagNames won't get elements in the correct
@@ -169,9 +155,5 @@ module Celerity
169
155
  retry
170
156
  end
171
157
 
172
- def matches?(string, what)
173
- Regexp === what ? string.strip =~ what : string == what.to_s
174
- end
175
-
176
158
  end # ElementLocator
177
159
  end # Celerity
@@ -14,7 +14,17 @@ module Celerity
14
14
 
15
15
  # Attribute list is a little weird due to this class covering both <button>
16
16
  # and <input type="submit|reset|image|button" />
17
- ATTRIBUTES = ATTRIBUTES | [:type, :disabled, :tabindex, :accesskey, :onfocus, :onblur] | [:src, :usemap, :ismap]
17
+ ATTRIBUTES = ATTRIBUTES | [
18
+ :accesskey,
19
+ :disabled,
20
+ :ismap,
21
+ :onblur,
22
+ :onfocus,
23
+ :src,
24
+ :tabindex,
25
+ :type,
26
+ :usemap,
27
+ ]
18
28
  DEFAULT_HOW = :value
19
29
 
20
30
  #
@@ -22,9 +32,8 @@ module Celerity
22
32
  #
23
33
 
24
34
  def locate
25
- # We want the :value attribute to point to the inner HTML for <button> elements,
35
+ # We want the :value attribute to point to the inner text for <button> elements,
26
36
  # and to the value attribute for <input type="button"> elements.
27
-
28
37
  if (val = @conditions[:value])
29
38
  button_ident = Identifier.new('button')
30
39
  button_ident.text = val
@@ -5,7 +5,17 @@ module Celerity
5
5
  TAGS = [Identifier.new('form')]
6
6
 
7
7
  # HTML 4.01 Transitional DTD
8
- ATTRIBUTES = BASE_ATTRIBUTES | [:action, :method, :enctype, :accept, :name, :onsubmit, :onreset, :target, :'accept-charset']
8
+ ATTRIBUTES = BASE_ATTRIBUTES | [
9
+ :'accept-charset',
10
+ :accept,
11
+ :action,
12
+ :enctype,
13
+ :method,
14
+ :name,
15
+ :onreset,
16
+ :onsubmit,
17
+ :target,
18
+ ]
9
19
  DEFAULT_HOW = :name
10
20
 
11
21
  #
@@ -6,7 +6,16 @@ module Celerity
6
6
  attr_accessor :page
7
7
 
8
8
  TAGS = [Identifier.new('frame'), Identifier.new('iframe')]
9
- ATTRIBUTES = BASE_ATTRIBUTES | [:longdesc, :name, :src, :frameborder, :marginwidth, :marginheight, :noresize, :scrolling]
9
+ ATTRIBUTES = BASE_ATTRIBUTES | [
10
+ :frameborder,
11
+ :longdesc,
12
+ :marginheight,
13
+ :marginwidth,
14
+ :name,
15
+ :noresize,
16
+ :scrolling,
17
+ :src,
18
+ ]
10
19
  DEFAULT_HOW = :name
11
20
 
12
21
  #
@@ -59,7 +68,7 @@ module Celerity
59
68
 
60
69
  def to_s
61
70
  assert_exists
62
- create_string(@inline_frame_object)
71
+ Celerity::Util.create_string @inline_frame_object
63
72
  end
64
73
 
65
74
  def method_missing(meth, *args, &blk)
@@ -5,7 +5,20 @@ module Celerity
5
5
 
6
6
  TAGS = [ Identifier.new('img') ]
7
7
 
8
- ATTRIBUTES = BASE_ATTRIBUTES | [:src, :alt, :longdesc, :name, :height, :width, :usemap, :ismap, :align, :border, :hspace, :vspace]
8
+ ATTRIBUTES = BASE_ATTRIBUTES | [
9
+ :align,
10
+ :alt,
11
+ :border,
12
+ :height,
13
+ :hspace,
14
+ :ismap,
15
+ :longdesc,
16
+ :name,
17
+ :src,
18
+ :usemap,
19
+ :vspace,
20
+ :width,
21
+ ]
9
22
  DEFAULT_HOW = :src
10
23
 
11
24
  #
@@ -4,7 +4,12 @@ module Celerity
4
4
  include ClickableElement
5
5
 
6
6
  TAGS = [ Identifier.new('label') ]
7
- ATTRIBUTES = BASE_ATTRIBUTES | [:for, :accesskey, :onfocus, :onblur]
7
+ ATTRIBUTES = BASE_ATTRIBUTES | [
8
+ :accesskey,
9
+ :for,
10
+ :onblur,
11
+ :onfocus,
12
+ ]
8
13
  DEFAULT_HOW = :text
9
14
  end
10
15
 
@@ -3,9 +3,22 @@ module Celerity
3
3
  include ClickableElement
4
4
 
5
5
  TAGS = [ Identifier.new('a') ]
6
- ATTRIBUTES = BASE_ATTRIBUTES | [:charset, :type, :name, :href, :hreflang,
7
- :target, :rel, :rev, :accesskey, :shape,
8
- :coords, :tabindex, :onfocus, :onblur]
6
+ ATTRIBUTES = BASE_ATTRIBUTES | [
7
+ :accesskey,
8
+ :charset,
9
+ :coords,
10
+ :href,
11
+ :hreflang,
12
+ :name,
13
+ :onblur,
14
+ :onfocus,
15
+ :rel,
16
+ :rev,
17
+ :shape,
18
+ :tabindex,
19
+ :target,
20
+ :type,
21
+ ]
9
22
  DEFAULT_HOW = :href
10
23
 
11
24
  #
@@ -1,6 +1,13 @@
1
1
  module Celerity
2
2
  class Meta < Element
3
- ATTRIBUTES = [:name, :id, :'http-equiv', :content, :scheme] | HTML_401_TRANSITIONAL[:i18n]
3
+ ATTRIBUTES = HTML_401_TRANSITIONAL[:i18n] | [
4
+ :'http-equiv',
5
+ :content,
6
+ :id,
7
+ :name,
8
+ :scheme,
9
+ ]
10
+
4
11
  DEFAULT_HOW = :id
5
12
  TAGS = [ Identifier.new('meta') ]
6
13
  end
@@ -19,7 +19,17 @@ module Celerity
19
19
  #
20
20
 
21
21
  class Area < NonControlElement
22
- ATTRIBUTES = ATTRIBUTES | [:shape, :coords, :href, :nohref, :alt, :tabindex, :accesskey, :onfocus, :onblur]
22
+ ATTRIBUTES = ATTRIBUTES | [
23
+ :accesskey,
24
+ :alt,
25
+ :coords,
26
+ :href,
27
+ :nohref,
28
+ :onblur,
29
+ :onfocus,
30
+ :shape,
31
+ :tabindex,
32
+ ]
23
33
  TAGS = [ Identifier.new('area') ]
24
34
  end
25
35
 
@@ -9,7 +9,13 @@ module Celerity
9
9
  include DisabledElement
10
10
 
11
11
  TAGS = [ Identifier.new('option') ]
12
- ATTRIBUTES = BASE_ATTRIBUTES | [:selected, :disabled, :label, :value]
12
+ ATTRIBUTES = BASE_ATTRIBUTES | [
13
+ :disabled,
14
+ :label,
15
+ :selected,
16
+ :value,
17
+ ]
18
+
13
19
  DEFAULT_HOW = :text
14
20
 
15
21
  alias_method :select, :click
@@ -106,7 +106,6 @@ module Celerity
106
106
  assert_enabled
107
107
 
108
108
  if (value && !set?) || (!value && set?)
109
- Log.debug(@object.inspect)
110
109
  @object.click
111
110
  end
112
111
  end
@@ -9,9 +9,7 @@ module Celerity
9
9
 
10
10
  def options
11
11
  assert_exists
12
- @object.getOptions.map do |e|
13
- e.asText.empty? ? e.getLabelAttribute : e.asText
14
- end
12
+ @object.getOptions.map { |e| e.asText.empty? ? e.getLabelAttribute : e.asText }
15
13
  end
16
14
 
17
15
  #
@@ -29,7 +27,6 @@ module Celerity
29
27
 
30
28
  def clear
31
29
  # assert_exists called by SelectList#type here
32
- # TODO: should update page for each option changed?
33
30
  @object.getSelectedOptions.each { |e| e.setSelected(false) } unless type() == 'select-one'
34
31
  end
35
32
 
@@ -71,7 +68,7 @@ module Celerity
71
68
 
72
69
  def select_value(value)
73
70
  assert_exists
74
- selected = @object.getOptions.map { |e| e.click if matches?(e.getValueAttribute, value) }.compact.first
71
+ selected = @object.getOptions.map { |e| e.click if Util.matches?(e.getValueAttribute, value) }.compact.first
75
72
 
76
73
  unless selected
77
74
  raise NoValueFoundException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}"
@@ -143,7 +140,7 @@ module Celerity
143
140
  private
144
141
 
145
142
  def matches_option?(option, value)
146
- matches?(option.asText, value) || (option.hasAttribute("label") && matches?(option.getLabelAttribute, value))
143
+ Util.matches?(option.asText, value) || (option.hasAttribute("label") && Util.matches?(option.getLabelAttribute, value))
147
144
  end
148
145
 
149
146
  end # SelectList
@@ -6,8 +6,17 @@ module Celerity
6
6
  include Container
7
7
 
8
8
  TAGS = [ Identifier.new('table') ]
9
- ATTRIBUTES = BASE_ATTRIBUTES | [:summary, :width, :border, :frame, :rules,
10
- :cellspacing, :cellpadding, :align, :bgcolor]
9
+ ATTRIBUTES = BASE_ATTRIBUTES | [
10
+ :align,
11
+ :bgcolor,
12
+ :border,
13
+ :cellpadding,
14
+ :cellspacing,
15
+ :frame,
16
+ :rules,
17
+ :summary,
18
+ :width,
19
+ ]
11
20
  DEFAULT_HOW = :id
12
21
 
13
22
  def locate
@@ -6,8 +6,15 @@ module Celerity
6
6
  include Container
7
7
 
8
8
  TAGS = [ Identifier.new('td') ]
9
- ATTRIBUTES = BASE_ATTRIBUTES | CELLHALIGN_ATTRIBUTES |
10
- CELLVALIGN_ATTRIBUTES | [:abbr, :axis, :headers, :scope, :rowspan, :colspan]
9
+ ATTRIBUTES = BASE_ATTRIBUTES | CELLHALIGN_ATTRIBUTES | CELLVALIGN_ATTRIBUTES |
10
+ [
11
+ :abbr,
12
+ :axis,
13
+ :colspan,
14
+ :headers,
15
+ :rowspan,
16
+ :scope,
17
+ ]
11
18
 
12
19
  DEFAULT_HOW = :id
13
20
 
@@ -69,7 +69,6 @@ module Celerity
69
69
  @object.getValueAttribute
70
70
  end
71
71
  end
72
- alias_method :get_contents, :value
73
72
 
74
73
  #
75
74
  # Append the given value to the text in the text field.
@@ -1,10 +1,27 @@
1
1
  module Celerity
2
2
 
3
- Identifier = Struct.new(:tag, :attributes) do
3
+ class Identifier
4
4
  attr_accessor :text
5
+ attr_reader :tag, :attributes
5
6
 
6
- def initialize(t, a={})
7
- super(t, a)
7
+ def initialize(tag, attributes = {})
8
+ @tag = tag
9
+ @attributes = attributes
10
+ @text = nil
11
+ end
12
+
13
+ def match?(element)
14
+ return false unless @tag == element.getTagName
15
+
16
+ attr_result = @attributes.all? do |key, values|
17
+ values.any? { |val| Util.matches?(element.getAttribute(key.to_s), val) }
18
+ end
19
+
20
+ if @text
21
+ attr_result && Util.matches?(element.asText.strip, @text)
22
+ else
23
+ attr_result
24
+ end
8
25
  end
9
26
  end
10
27
 
@@ -54,11 +54,13 @@ module Celerity
54
54
  raise ArgumentError, "unknown listener type #{type.inspect}"
55
55
  end
56
56
 
57
+ procs = @procs[type]
58
+
57
59
  case proc_or_index
58
60
  when Fixnum
59
- @procs[type].delete_at proc_or_index
61
+ procs.delete_at proc_or_index
60
62
  when Proc
61
- @procs[type].delete proc_or_index
63
+ procs.delete proc_or_index
62
64
  else
63
65
  raise TypeError, "must give proc or index"
64
66
  end
@@ -69,7 +71,7 @@ module Celerity
69
71
  #
70
72
 
71
73
  def statusMessageChanged(page, message)
72
- @procs[:status].each { |h| h.call(page, message) }
74
+ @procs[:status].each { |handler| handler.call(page, message) }
73
75
  end
74
76
 
75
77
  #
@@ -77,7 +79,7 @@ module Celerity
77
79
  #
78
80
 
79
81
  def handleAlert(page, message)
80
- @procs[:alert].each { |h| h.call(page, message) }
82
+ @procs[:alert].each { |handler| handler.call(page, message) }
81
83
  end
82
84
 
83
85
  #
@@ -90,7 +92,7 @@ module Celerity
90
92
  #
91
93
 
92
94
  def handleConfirm(page, message)
93
- val = @procs[:confirm].map { |h| h.call(page, message) }.last
95
+ val = @procs[:confirm].map { |handler| handler.call(page, message) }.last
94
96
  val.nil? || !!val
95
97
  end
96
98
 
@@ -99,7 +101,7 @@ module Celerity
99
101
  #
100
102
 
101
103
  def handleAttachment(page)
102
- @procs[:attachment].each { |h| h.call(page) }
104
+ @procs[:attachment].each { |handler| handler.call(page) }
103
105
  end
104
106
 
105
107
  #
@@ -107,7 +109,7 @@ module Celerity
107
109
  #
108
110
 
109
111
  def handlePrompt(page, message)
110
- @procs[:prompt].each { |h| h.call(page, message) }
112
+ @procs[:prompt].each { |handler| handler.call(page, message) }
111
113
  end
112
114
 
113
115
  #
@@ -115,7 +117,7 @@ module Celerity
115
117
  #
116
118
 
117
119
  def webWindowClosed(web_window_event)
118
- @procs[:web_window_event].each { |h| h.call(web_window_event) }
120
+ @procs[:web_window_event].each { |handler| handler.call(web_window_event) }
119
121
  end
120
122
  alias_method :webWindowOpened, :webWindowClosed
121
123
  alias_method :webWindowContentChanged, :webWindowClosed
@@ -125,7 +127,7 @@ module Celerity
125
127
  #
126
128
 
127
129
  def error(message, url, line, column, key)
128
- @procs[:html_parser].each { |h| h.call(message, url, line, column, key) }
130
+ @procs[:html_parser].each { |handler| handler.call(message, url, line, column, key) }
129
131
  end
130
132
  alias_method :warning, :error
131
133
 
@@ -134,7 +136,7 @@ module Celerity
134
136
  #
135
137
 
136
138
  def notify(message, origin)
137
- @procs[:incorrectness].each { |h| h.call(message, origin) }
139
+ @procs[:incorrectness].each { |handler| handler.call(message, origin) }
138
140
  end
139
141
 
140
142
  end # Listener
data/lib/celerity/util.rb CHANGED
@@ -87,5 +87,40 @@ module Celerity
87
87
  java.util.logging.Logger.getLogger(package_string)
88
88
  end
89
89
 
90
+ # number of spaces that separate the property from the value in the create_string method
91
+ TO_S_SIZE = 14
92
+
93
+ def create_string(element)
94
+ ret = []
95
+
96
+ unless (tag = element.getTagName).empty?
97
+ ret << "tag:".ljust(TO_S_SIZE) + tag
98
+ end
99
+
100
+ element.getAttributes.each do |attribute|
101
+ ret << " #{attribute.getName}:".ljust(TO_S_SIZE + 2) + attribute.getValue.to_s
102
+ end
103
+
104
+ unless (text = element.asText).empty?
105
+ ret << " text:".ljust(TO_S_SIZE + 2) + element.asText
106
+ end
107
+
108
+ ret.join("\n")
109
+ end
110
+
111
+ #
112
+ # Used internally.
113
+ #
114
+ # @param [String] string The string to match against.
115
+ # @param [Regexp, String, #to_s] what The match we're looking for.
116
+ # @return [Fixnum, true, false, nil]
117
+ #
118
+ # @api private
119
+ #
120
+
121
+ def matches?(string, what)
122
+ Regexp === what ? string.strip =~ what : string == what.to_s
123
+ end
124
+
90
125
  end
91
126
  end
@@ -1,3 +1,3 @@
1
1
  module Celerity
2
- VERSION = "0.7.4"
2
+ VERSION = "0.7.5"
3
3
  end
@@ -7,15 +7,7 @@ module Celerity
7
7
  # Added for Watir compatibility - not in use by Celerity
8
8
  alias_method :start_window, :start
9
9
  # Added for Watir compatibility - not in use by Celerity
10
- def reset_attach_timeout; @attach_timeout = 2.0; end
11
- # Added for Watir compatibility - not in use by Celerity
12
10
  def each; end
13
- # Added for Watir compatibility - not in use by Celerity
14
- def quit; end
15
- # Added for Watir compatibility - not in use by Celerity
16
- def set_fast_speed; @speed = :fast; end
17
- # Added for Watir compatibility - not in use by Celerity
18
- def set_slow_speed; @speed = :slow; end
19
11
  end
20
12
 
21
13
  # Added for Watir compatibility - not in use by Celerity
@@ -47,7 +39,6 @@ module Celerity
47
39
 
48
40
  class Image
49
41
  alias_method :hasLoaded?, :loaded?
50
- alias_method :has_loaded?, :loaded?
51
42
  alias_method :fileSize, :file_size
52
43
  alias_method :fileCreatedDate, :file_created_date
53
44
  end
@@ -57,8 +48,6 @@ module Celerity
57
48
  end
58
49
 
59
50
  class RadioCheckCommon
60
- alias_method :is_set?, :set?
61
- alias_method :get_state, :set?
62
51
  alias_method :isSet?, :set?
63
52
  alias_method :getState, :set?
64
53
  end
@@ -67,14 +56,12 @@ module Celerity
67
56
  alias_method :getSelectedItems, :selected_options
68
57
  alias_method :getAllContents, :options
69
58
  alias_method :clearSelection, :clear
70
- alias_method :clear_selection, :clear
71
59
  alias_method :includes?, :include?
72
60
  end
73
61
 
74
62
  class TextField
75
63
  alias_method :dragContentsTo, :drag_contents_to
76
64
  alias_method :getContents, :value
77
- alias_method :get_contents, :value
78
65
 
79
66
  def requires_typing; end
80
67
  end
data/tasks/check.rake ADDED
@@ -0,0 +1,24 @@
1
+ namespace :check do
2
+
3
+ desc 'Check syntax of all .rb files'
4
+ task :syntax do
5
+ failed = []
6
+
7
+ Dir['**/*.rb'].each do |f|
8
+ begin
9
+ eval("lambda do\n return true\n #{File.read f} \nend").call
10
+ print "."
11
+ rescue SyntaxError => e
12
+ print "!"
13
+ failed << [f, e.message]
14
+ end
15
+ end
16
+
17
+ if failed.empty?
18
+ puts "ok."
19
+ else
20
+ puts "\n\t#{failed.join("\n\t")}"
21
+ end
22
+ end
23
+
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celerity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2009-10-09 00:00:00 +02:00
14
+ date: 2009-10-27 00:00:00 +01:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -117,6 +117,7 @@ files:
117
117
  - lib/celerity/watir_compatibility.rb
118
118
  - lib/celerity/xpath_support.rb
119
119
  - tasks/benchmark.rake
120
+ - tasks/check.rake
120
121
  - tasks/clean.rake
121
122
  - tasks/fix.rake
122
123
  - tasks/jar.rake