masque 0.3.0 → 0.3.1
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.
- checksums.yaml +4 -4
- data/lib/masque.rb +28 -1
- data/lib/masque/version.rb +1 -1
- data/spec/masque_spec.rb +34 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78ca3efe302a644a8728c77802763f2fb24fa90b
|
4
|
+
data.tar.gz: 662934731060be4956413195243147d778abb658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70079bd19309f0e4fa5ec95d83ccde5c713b86f56b919072bdf84c58e88c20197210d7aa4b83bbb7cf748bd5cb977cdfcc0fba672e8a7509128e189bffda8341
|
7
|
+
data.tar.gz: 0594fd76d97cb9a1f8b392eaf1dde8b25daf4e3cef4961b55a5b5dd4ba11fb2e3aa335c37e4055aed788772b2d51b43fd37cea6091e645ecddeedd582000990b
|
data/lib/masque.rb
CHANGED
@@ -7,7 +7,7 @@ require "masque/version"
|
|
7
7
|
require "masque/dsl"
|
8
8
|
|
9
9
|
class Masque
|
10
|
-
attr_reader :options, :agent
|
10
|
+
attr_reader :options, :agent, :compat_mode
|
11
11
|
|
12
12
|
def self.run(options = {}, &block)
|
13
13
|
new(options).run(&block)
|
@@ -16,6 +16,18 @@ class Masque
|
|
16
16
|
def initialize(options = {})
|
17
17
|
@options = options
|
18
18
|
@driver = options[:driver] || :webkit
|
19
|
+
|
20
|
+
case options[:capybara_compat]
|
21
|
+
when "2.1"
|
22
|
+
compat_capybara_21!
|
23
|
+
when "2.0"
|
24
|
+
compat_capybara_20!
|
25
|
+
when "1.x"
|
26
|
+
compat_capybara_1x!
|
27
|
+
else # default compat mode is 1.x (currently. IMO this is most useful for crawler, but any use case can be changed this decision)
|
28
|
+
compat_capybara_1x!
|
29
|
+
end
|
30
|
+
|
19
31
|
@agent = Class.new do
|
20
32
|
include Masque::DSL
|
21
33
|
|
@@ -53,7 +65,20 @@ class Masque
|
|
53
65
|
@agent.instance_eval(&block)
|
54
66
|
end
|
55
67
|
|
68
|
+
def compat_capybara_21!
|
69
|
+
# https://github.com/jnicklas/capybara/blob/2.1.0/lib/capybara.rb#L323
|
70
|
+
@compat_mode = "2.1"
|
71
|
+
Capybara.configure do |config|
|
72
|
+
config.ignore_hidden_elements = true
|
73
|
+
config.match = :smart
|
74
|
+
config.exact = false
|
75
|
+
config.visible_text_only = false
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
56
79
|
def compat_capybara_20!
|
80
|
+
# http://www.elabs.se/blog/60-introducing-capybara-2-1
|
81
|
+
@compat_mode = "2.0"
|
57
82
|
Capybara.configure do |config|
|
58
83
|
config.match = :one
|
59
84
|
config.exact_options = true
|
@@ -63,6 +88,8 @@ class Masque
|
|
63
88
|
end
|
64
89
|
|
65
90
|
def compat_capybara_1x!
|
91
|
+
# http://www.elabs.se/blog/60-introducing-capybara-2-1
|
92
|
+
@compat_mode = "1.x"
|
66
93
|
Capybara.configure do |config|
|
67
94
|
config.match = :prefer_exact
|
68
95
|
config.ignore_hidden_elements = false
|
data/lib/masque/version.rb
CHANGED
data/spec/masque_spec.rb
CHANGED
@@ -3,11 +3,40 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
describe Masque do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
describe ".new" do
|
7
|
+
it do
|
8
|
+
opts = {:display => 50, :driver => :webkit}
|
9
|
+
masque = Masque.new(opts)
|
10
|
+
masque.options.should == opts
|
11
|
+
masque.respond_to?(:run).should be_true
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "compat_mode" do
|
15
|
+
subject { Masque.new(:capybara_compat => ver).compat_mode }
|
16
|
+
|
17
|
+
context "2.1" do
|
18
|
+
let(:method) { :compat_capybara_21! }
|
19
|
+
let(:ver) { "2.1" }
|
20
|
+
it { should == ver }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "2.0" do
|
24
|
+
let(:method) { :compat_capybara_20! }
|
25
|
+
let(:ver) { "2.0" }
|
26
|
+
it { should == ver }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "1.x" do
|
30
|
+
let(:method) { :compat_capybara_1x! }
|
31
|
+
let(:ver) { "1.x" }
|
32
|
+
it { should == ver }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it "default compat mode is 1.x" do
|
37
|
+
Masque.any_instance.should_receive(:compat_capybara_1x!)
|
38
|
+
Masque.new
|
39
|
+
end
|
11
40
|
end
|
12
41
|
end
|
13
42
|
|