casper 0.0.5 → 0.0.6

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.
Files changed (3) hide show
  1. data/lib/casper.rb +4 -2
  2. data/test/casper_test.rb +17 -0
  3. metadata +4 -4
@@ -95,8 +95,8 @@ module Casper
95
95
  #
96
96
  # drag :from => [ 0, 0 ], :distance => [ 20, 20 ], :increments => 8
97
97
  #
98
- # will still occur in 8 iterations, however each 3rd iteration will move
99
- # 3px instead of 2px.
98
+ # will still occur in 8 iterations, however each iteration will alternate
99
+ # between 2px and 3px (interpolated movement).
100
100
  def drag(options={}, &block)
101
101
  raise ArgumentError.new(":to or :distance is required to provide ending location") unless options.has_key?(:to) || options.has_key?(:distance)
102
102
  raise ArgumentError.new(":increments must be > 0") if options.has_key?(:increments) && options[:increments] <= 0
@@ -113,6 +113,7 @@ module Casper
113
113
  move(x, y)
114
114
  end
115
115
  yield if block_given?
116
+ ensure
116
117
  up
117
118
  end
118
119
 
@@ -123,6 +124,7 @@ module Casper
123
124
  xdo = Libxdo.xdo_new(nil)
124
125
  yield(xdo)
125
126
  sleep delay
127
+ ensure
126
128
  Libxdo.xdo_free(xdo)
127
129
  end
128
130
 
@@ -140,4 +140,21 @@ $('<div class="target" id="#{id}"></div>').
140
140
  assert (Time.now.to_f - start.to_f) > 0.5
141
141
  end
142
142
  end
143
+
144
+ describe "when exceptions occur in blocks" do
145
+ should "release the mouse button when dragging" do
146
+ target! "a", 300, 220
147
+ assert !has_class?("#a", "mousedown")
148
+
149
+ Casper::Mouse.move 320, 350
150
+ begin
151
+ Casper::Mouse.drag(:to => [ 330, 360 ]) do
152
+ assert has_class?("#a", "mousedown")
153
+ raise
154
+ end
155
+ rescue RuntimeError;end;
156
+
157
+ assert !has_class?("#a", "mousedown")
158
+ end
159
+ end
143
160
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: casper
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Alavi
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-09-27 00:00:00 -07:00
19
+ date: 2010-09-28 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency