grope 0.1.3 → 0.1.4

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/Rakefile CHANGED
@@ -11,7 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/youpy/grope"
12
12
  gem.authors = ["youpy"]
13
13
  gem.add_development_dependency "rspec", ">= 1.2.9"
14
- gem.add_dependency "mechanize", ">= 1.0.0"
14
+ gem.add_dependency "mechanize", ">= 2.0.1"
15
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
16
  end
17
17
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
data/lib/grope/env.rb CHANGED
@@ -121,6 +121,26 @@ JS
121
121
  run(sec) do; end
122
122
  end
123
123
 
124
+ def wait_until(options = {})
125
+ options = {
126
+ :timeout => 10
127
+ }.merge(options)
128
+
129
+ start = Time.now.to_i
130
+
131
+ begin
132
+ result = yield self
133
+
134
+ if result
135
+ return result
136
+ end
137
+
138
+ wait(1)
139
+ end until Time.now.to_i >= start + options[:timeout]
140
+
141
+ raise TimeoutError
142
+ end
143
+
124
144
  def document
125
145
  eval('return document;')
126
146
  end
@@ -60,7 +60,7 @@ class NSHTTPCookieWrapper
60
60
  end
61
61
 
62
62
  def domain
63
- cookie.domain && cookie.domain.to_s.sub(/^\./, '')
63
+ cookie.domain && cookie.domain.to_s
64
64
  end
65
65
 
66
66
  def path
data/spec/env_spec.rb CHANGED
@@ -73,6 +73,26 @@ describe Grope::Env do
73
73
  (Time.now.to_i - now).should be_close(3, 1)
74
74
  end
75
75
 
76
+ it "should wait until given block returns true" do
77
+ now = Time.now.to_i
78
+
79
+ lambda {
80
+ @env.wait_until(:timeout => 1) do |env|
81
+ env.document.title == 'xxx'
82
+ end
83
+ }.should raise_error(Timeout::Error)
84
+
85
+ (Time.now.to_i - now).should be_close(1, 1)
86
+
87
+ @env.document.querySelector('title').innerHTML = 'xxx'
88
+
89
+ result = @env.wait_until do |env|
90
+ env.document.title == 'xxx'
91
+ end
92
+
93
+ result.should be_true
94
+ end
95
+
76
96
  it "should use shared cookie storage if 'use_shared_cookie' option is true" do
77
97
  env = Grope::Env.new(:use_shared_cookie => true)
78
98
  env.instance_eval { @resource_load_delegate }.should be_nil
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - youpy
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-09-21 00:00:00 +09:00
17
+ date: 2011-10-03 00:00:00 +09:00
18
18
  default_executable: grope
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -39,10 +39,10 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  segments:
42
- - 1
43
- - 0
42
+ - 2
44
43
  - 0
45
- version: 1.0.0
44
+ - 1
45
+ version: 2.0.1
46
46
  type: :runtime
47
47
  version_requirements: *id002
48
48
  description: A non-GUI library to represent browser environment using WebKit Framework