capybara-js_finders 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,29 +13,34 @@ module Capybara
13
13
  BR = "br".freeze # Bottom range
14
14
  XpathTrue = "(1=1)"
15
15
 
16
- # TODO: This script is only prototype compatibile. Let it discover jquery or prototype and use proper methods.
16
+ # TODO: This script is only prototype compatible. Let it discover jquery or prototype and use proper methods.
17
+ #
18
+ # If element left offset is 5 and element width is 10 then it cannot occupy pixels from 5 to 15 because that would give us 11px width.
19
+ # Element must occupy pixels from 6 to 15 or from 5 to 14 (including).
20
+ #
21
+ # I assume that the former answer is correct.
22
+ # Element starts on 6th pixel and that's why offset is equal to 5. TODO: Make sure there is test for that!
23
+ #
17
24
  SCRIPT = <<-JS
18
- xpathResult = document.evaluate( "#{descendant(:th, :td)}", document, null, XPathResult.ANY_TYPE, null);
19
- var ary = [];
20
- var td;
21
- while( td = xpathResult.iterateNext() ){
22
- ary.push(td);
23
- }
24
- ary.each(function(ele){
25
- try{
26
- var offset = ele.cumulativeOffset();
27
- var lr = offset.left;
28
- var rr = lr + ele.getWidth();
29
- var tr = offset.top;
30
- var br = tr + ele.getHeight();
31
- ele.setAttribute('#{LR}', lr);
32
- ele.setAttribute('#{RR}', rr);
33
- ele.setAttribute('#{TR}', tr);
34
- ele.setAttribute('#{BR}', br);
35
- } catch(err){
36
- /* ele.getWidth() and ele.getHeight() sometimes raises an exception, just skip ele in such case, there is nothing we can do about it! */
25
+ xpathResult = document.evaluate( "#{descendant(:th, :td)}", document, null, XPathResult.ANY_TYPE, null);
26
+ var ary = [];
27
+ var td;
28
+ while( td = xpathResult.iterateNext() ){
29
+ ary.push(td);
37
30
  }
38
- });
31
+ ary.each(function(ele){
32
+ try{
33
+ var dimensions = ele.getDimensions();
34
+ var offset = ele.cumulativeOffset();
35
+
36
+ ele.setAttribute('#{LR}', offset.left + 1);
37
+ ele.setAttribute('#{RR}', offset.left + dimensions.width);
38
+ ele.setAttribute('#{TR}', offset.top + 1);
39
+ ele.setAttribute('#{BR}', offset.top + dimensions.height);
40
+ } catch(err){
41
+ /* ele.getDimensions() sometimes raises an exception, just skip ele in such case, there is nothing we can do about it! */
42
+ }
43
+ });
39
44
  JS
40
45
  SCRIPT.freeze
41
46
 
@@ -124,7 +129,7 @@ module Capybara
124
129
  execute_script(SCRIPT)
125
130
  xpath = JsFinders.cell_condition(columns, rows)
126
131
  xpath = ".//td[ #{xpath} ]"
127
- #puts xpath
132
+ # puts xpath
128
133
  find(:xpath, xpath, options)
129
134
  end
130
135
  end
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module JsFinders
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-js_finders
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-18 00:00:00.000000000Z
12
+ date: 2011-07-25 00:00:00.000000000 +02:00
13
+ default_executable:
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: capybara
16
- requirement: &87884780 !ruby/object:Gem::Requirement
17
+ requirement: &78592980 !ruby/object:Gem::Requirement
17
18
  none: false
18
19
  requirements:
19
20
  - - ~>
@@ -21,10 +22,10 @@ dependencies:
21
22
  version: 1.0.0
22
23
  type: :runtime
23
24
  prerelease: false
24
- version_requirements: *87884780
25
+ version_requirements: *78592980
25
26
  - !ruby/object:Gem::Dependency
26
27
  name: rake
27
- requirement: &87875910 !ruby/object:Gem::Requirement
28
+ requirement: &78592730 !ruby/object:Gem::Requirement
28
29
  none: false
29
30
  requirements:
30
31
  - - ~>
@@ -32,10 +33,10 @@ dependencies:
32
33
  version: 0.9.0
33
34
  type: :development
34
35
  prerelease: false
35
- version_requirements: *87875910
36
+ version_requirements: *78592730
36
37
  - !ruby/object:Gem::Dependency
37
38
  name: rdoc
38
- requirement: &87875680 !ruby/object:Gem::Requirement
39
+ requirement: &78592500 !ruby/object:Gem::Requirement
39
40
  none: false
40
41
  requirements:
41
42
  - - ! '>='
@@ -43,10 +44,10 @@ dependencies:
43
44
  version: 2.4.2
44
45
  type: :development
45
46
  prerelease: false
46
- version_requirements: *87875680
47
+ version_requirements: *78592500
47
48
  - !ruby/object:Gem::Dependency
48
49
  name: sinatra
49
- requirement: &87875450 !ruby/object:Gem::Requirement
50
+ requirement: &78592270 !ruby/object:Gem::Requirement
50
51
  none: false
51
52
  requirements:
52
53
  - - ~>
@@ -54,10 +55,10 @@ dependencies:
54
55
  version: 1.2.6
55
56
  type: :development
56
57
  prerelease: false
57
- version_requirements: *87875450
58
+ version_requirements: *78592270
58
59
  - !ruby/object:Gem::Dependency
59
60
  name: erubis
60
- requirement: &87875220 !ruby/object:Gem::Requirement
61
+ requirement: &78592040 !ruby/object:Gem::Requirement
61
62
  none: false
62
63
  requirements:
63
64
  - - ~>
@@ -65,10 +66,10 @@ dependencies:
65
66
  version: 2.6.6
66
67
  type: :development
67
68
  prerelease: false
68
- version_requirements: *87875220
69
+ version_requirements: *78592040
69
70
  - !ruby/object:Gem::Dependency
70
71
  name: bbq
71
- requirement: &87874990 !ruby/object:Gem::Requirement
72
+ requirement: &78591810 !ruby/object:Gem::Requirement
72
73
  none: false
73
74
  requirements:
74
75
  - - ~>
@@ -76,10 +77,10 @@ dependencies:
76
77
  version: 0.0.3
77
78
  type: :development
78
79
  prerelease: false
79
- version_requirements: *87874990
80
+ version_requirements: *78591810
80
81
  - !ruby/object:Gem::Dependency
81
82
  name: redcarpet
82
- requirement: &87874760 !ruby/object:Gem::Requirement
83
+ requirement: &78591580 !ruby/object:Gem::Requirement
83
84
  none: false
84
85
  requirements:
85
86
  - - ~>
@@ -87,10 +88,10 @@ dependencies:
87
88
  version: '1.17'
88
89
  type: :development
89
90
  prerelease: false
90
- version_requirements: *87874760
91
+ version_requirements: *78591580
91
92
  - !ruby/object:Gem::Dependency
92
93
  name: ruby-debug19
93
- requirement: &87874570 !ruby/object:Gem::Requirement
94
+ requirement: &78591390 !ruby/object:Gem::Requirement
94
95
  none: false
95
96
  requirements:
96
97
  - - ! '>='
@@ -98,7 +99,7 @@ dependencies:
98
99
  version: '0'
99
100
  type: :development
100
101
  prerelease: false
101
- version_requirements: *87874570
102
+ version_requirements: *78591390
102
103
  description: ! " Additional finders for capybara that for some reason\n cannot
103
104
  use only xpath for finding nodes but needs to\n execute js for some calculations.\n\n
104
105
  \ Ex: I you want to find a table cell\n that is under or next to other cell
@@ -128,6 +129,7 @@ files:
128
129
  - test/unit/find_cell_tests/app/public/js/prototype.js
129
130
  - test/unit/find_cell_tests/app/views/table.erubis
130
131
  - test/unit/find_cell_tests/basic_test.rb
132
+ has_rdoc: true
131
133
  homepage: https://github.com/paneq/capybara-js_finders
132
134
  licenses: []
133
135
  post_install_message:
@@ -142,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
142
144
  version: '0'
143
145
  segments:
144
146
  - 0
145
- hash: -398005553
147
+ hash: 767245201
146
148
  required_rubygems_version: !ruby/object:Gem::Requirement
147
149
  none: false
148
150
  requirements:
@@ -151,10 +153,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
153
  version: '0'
152
154
  segments:
153
155
  - 0
154
- hash: -398005553
156
+ hash: 767245201
155
157
  requirements: []
156
158
  rubyforge_project: capybara-js_finders
157
- rubygems_version: 1.8.5
159
+ rubygems_version: 1.6.2
158
160
  signing_key:
159
161
  specification_version: 3
160
162
  summary: Additional finders for capybara that for some reason cannot use only xpath