masque 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ce74176f64dc03dce4b0789c2dad179fd2b4674
4
- data.tar.gz: 6f591a6e12e9895f433f59f3d2e823af94d21a51
3
+ metadata.gz: d94d73faef46aff07f7a2da237b065c72293322f
4
+ data.tar.gz: 825bdbe2e9a5f26f18f7c83c79563b9c1a3f088f
5
5
  SHA512:
6
- metadata.gz: 6fa6ac963be6a889b0fd3dd852b7fc42fc78698518227294b1fb5b1f99d18fac0678e2f66811b558afa98dd10d9067a4222ff5ca4e961ebf12fcda1091f34788
7
- data.tar.gz: f5db900a1fef41084923f4cd7d10cab59f49ad21a20d921ec01597e682410d7b33c303bc6227191d59dfdb202d0fd85297dafd3d3889658e7da21eaf98208d57
6
+ metadata.gz: 0c79c8ea8cebe79ddf79b4034ac69f98bb6a1e59094bc6717eeebbe04281e86173ad06e027af1c1733b6c2013a3f413816164c795562f0231e8ae0924736b829
7
+ data.tar.gz: 06feb166ae7e01f3594de4ee25f987b9fe830d879fb5888dea4e0573823b23b56705667eb99bf7ecf464c6703a5ebc4602e076bc0d86e601974b3396ea5493ab
@@ -52,4 +52,20 @@ class Masque
52
52
  def run(&block)
53
53
  @agent.instance_eval(&block)
54
54
  end
55
+
56
+ def compat_capybara_20!
57
+ Capybara.configure do |config|
58
+ config.match = :one
59
+ config.exact_options = true
60
+ config.ignore_hidden_elements = true
61
+ config.visible_text_only = true
62
+ end
63
+ end
64
+
65
+ def compat_capybara_1x!
66
+ Capybara.configure do |config|
67
+ config.match = :prefer_exact
68
+ config.ignore_hidden_elements = false
69
+ end
70
+ end
55
71
  end
@@ -1,3 +1,3 @@
1
1
  class Masque
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -17,9 +17,9 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
  gem.add_dependency "headless"
20
- gem.add_dependency "capybara"
21
- gem.add_dependency "capybara-webkit", "~> 0.14.0"
22
- gem.add_dependency "poltergeist", "~> 1.1.0"
20
+ gem.add_dependency "capybara" # maybe 2.1.0
21
+ gem.add_dependency "capybara-webkit", "~> 1.0.0"
22
+ gem.add_dependency "poltergeist", "~> 1.3.0"
23
23
  gem.add_development_dependency "rspec", "~> 2.11"
24
24
  gem.add_development_dependency "sinatra"
25
25
  gem.add_development_dependency "simplecov"
@@ -21,8 +21,13 @@ class Dummy < Sinatra::Base
21
21
  <h1 id="visits">#{session[:visit]}</h1>
22
22
  <div id="ua">#{env["HTTP_USER_AGENT"]}</div>
23
23
  <p>Hello, World!</p>
24
+ <div id="hide-text"><p style="display: none">hide text</p></div>
24
25
  <div id="js"></div>
25
26
  <div id="params">#{MultiJson.dump(params)}</div>
27
+ <select id="numbers">
28
+ <option value="10">10</option>
29
+ <option value="11">11</option>
30
+ </select>
26
31
  <script>
27
32
  document.getElementById("js").innerHTML = JSON.stringify({
28
33
  h: window.innerHeight,
@@ -87,6 +87,87 @@ shared_examples_for "driver" do
87
87
  end.to raise_error(TimeoutError)
88
88
  end
89
89
  end
90
+
91
+ describe "compat" do
92
+ context "2.0.x with compat_capybara_20!" do
93
+ before do
94
+ masque.compat_capybara_20!
95
+ end
96
+
97
+ context "config.match = :one" do
98
+ it "raise error multiple elements found" do
99
+ expect do
100
+ masque.run do
101
+ visit "/"
102
+ find "div"
103
+ end
104
+ end.to raise_error(Capybara::Ambiguous)
105
+ end
106
+ end
107
+
108
+ context "config.exact_options = true" do
109
+ it "don't find ambiguous text matching" do
110
+ expect do
111
+ masque.run do
112
+ visit "/"
113
+ page.select "1", :from => "numbers"
114
+ end
115
+ end.to raise_error(Capybara::ElementNotFound)
116
+ end
117
+ end
118
+
119
+ context "config.ignore_hidden_elements = true" do
120
+ it "don't find hidden element" do
121
+ expect do
122
+ masque.run do
123
+ visit "/dummy"
124
+ find "title", :text => "hi dummy"
125
+ end
126
+ end.to raise_error(Capybara::ElementNotFound)
127
+ end
128
+ end
129
+
130
+ context "config.visible_text_only = true" do
131
+ it do
132
+ pending "capybara-webkit 1.0.0 can't handle correctly" if driver == :webkit
133
+
134
+ masque.run do
135
+ visit "/"
136
+ find("#hide-text").text.should == ""
137
+ end
138
+ end
139
+ end
140
+ end
141
+
142
+ context "1.x with compat_capybara_1x!" do
143
+ before do
144
+ masque.compat_capybara_1x!
145
+ end
146
+
147
+ context "config.match = :prefer_exact" do
148
+ it "don't raise error multiple elements found" do
149
+ expect do
150
+ masque.run do
151
+ visit "/"
152
+ find "div"
153
+ end
154
+ end.to_not raise_error
155
+ end
156
+ end
157
+
158
+ context "config.ignore_hidden_elements = false" do
159
+ it "can find hidden element" do
160
+ expect do
161
+ masque.run do
162
+ visit "/dummy"
163
+ find "title", :text => "hi dummy"
164
+ end
165
+ end.to_not raise_error
166
+ end
167
+ end
168
+
169
+ end
170
+ end
90
171
  end
91
172
 
92
173
  it "#reset_session!" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: masque
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - uu59
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-30 00:00:00.000000000 Z
11
+ date: 2013-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: headless
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 0.14.0
47
+ version: 1.0.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 0.14.0
54
+ version: 1.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: poltergeist
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 1.1.0
61
+ version: 1.3.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 1.1.0
68
+ version: 1.3.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project:
169
- rubygems_version: 2.0.0
169
+ rubygems_version: 2.0.3
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: JavaScript enabled web crawler kit