chinchilla 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,14 +19,20 @@ module Chinchilla
19
19
  driver == :poltergeist
20
20
  end
21
21
 
22
+ def timeout
23
+ @timeout ||= @options[:timeout] || 0.5
24
+ end
25
+
22
26
  def run
23
27
  session.visit(url)
24
28
 
25
29
  events_consumed = 0
26
30
  done = false
31
+ raise_after = Time.now.to_f + timeout
27
32
  begin
28
33
  sleep 0.1
29
- events = JSON.parse(session.evaluate_script('window.mocha.getEvents()'))
34
+ json_events = session.evaluate_script(script_content)
35
+ events = json_events ? JSON.parse(json_events) : nil
30
36
  if events
31
37
  events[events_consumed..-1].each do |event|
32
38
  done = true if event['event'] == 'end'
@@ -34,6 +40,9 @@ module Chinchilla
34
40
  end
35
41
 
36
42
  events_consumed = events.length
43
+ raise_after = nil
44
+ elsif raise_after && raise_after < Time.now.to_f
45
+ raise 'Timeout'
37
46
  end
38
47
  end until done
39
48
 
@@ -53,6 +62,10 @@ module Chinchilla
53
62
 
54
63
  private
55
64
 
65
+ def script_content
66
+ 'window.mocha && window.mocha.getEvents && window.mocha.getEvents()'
67
+ end
68
+
56
69
  def application
57
70
  @application ||= @options[:application] || default_application
58
71
  end
@@ -1,3 +1,3 @@
1
1
  module Chinchilla
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,91 +1,91 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chinchilla
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
4
  prerelease:
5
+ version: 0.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - tchak
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-14 00:00:00.000000000 Z
12
+ date: 2013-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: capybara
16
- requirement: !ruby/object:Gem::Requirement
15
+ type: :runtime
16
+ version_requirements: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
- type: :runtime
22
+ name: capybara
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
24
+ requirement: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: poltergeist
32
- requirement: !ruby/object:Gem::Requirement
31
+ type: :runtime
32
+ version_requirements: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
- type: :runtime
38
+ name: poltergeist
39
39
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
40
+ requirement: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
- name: rocha
48
- requirement: !ruby/object:Gem::Requirement
47
+ type: :runtime
48
+ version_requirements: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
51
  - - ~>
52
52
  - !ruby/object:Gem::Version
53
53
  version: 0.2.1
54
- type: :runtime
54
+ name: rocha
55
55
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
56
+ requirement: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.2.1
62
62
  - !ruby/object:Gem::Dependency
63
- name: rake
64
- requirement: !ruby/object:Gem::Requirement
63
+ type: :runtime
64
+ version_requirements: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
67
  - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
- type: :runtime
70
+ name: rake
71
71
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
72
+ requirement: !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  - !ruby/object:Gem::Dependency
79
- name: rspec
80
- requirement: !ruby/object:Gem::Requirement
79
+ type: :development
80
+ version_requirements: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
83
  - - ! '>='
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
- type: :development
86
+ name: rspec
87
87
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
88
+ requirement: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
91
  - - ! '>='
@@ -120,19 +120,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - ! '>='
122
122
  - !ruby/object:Gem::Version
123
- version: '0'
124
123
  segments:
125
124
  - 0
126
- hash: 2362535692980596119
125
+ hash: -3082772088287280522
126
+ version: '0'
127
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ! '>='
131
131
  - !ruby/object:Gem::Version
132
- version: '0'
133
132
  segments:
134
133
  - 0
135
- hash: 2362535692980596119
134
+ hash: -3082772088287280522
135
+ version: '0'
136
136
  requirements: []
137
137
  rubyforge_project:
138
138
  rubygems_version: 1.8.23