masque 0.3.0 → 0.3.1

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: d94d73faef46aff07f7a2da237b065c72293322f
4
- data.tar.gz: 825bdbe2e9a5f26f18f7c83c79563b9c1a3f088f
3
+ metadata.gz: 78ca3efe302a644a8728c77802763f2fb24fa90b
4
+ data.tar.gz: 662934731060be4956413195243147d778abb658
5
5
  SHA512:
6
- metadata.gz: 0c79c8ea8cebe79ddf79b4034ac69f98bb6a1e59094bc6717eeebbe04281e86173ad06e027af1c1733b6c2013a3f413816164c795562f0231e8ae0924736b829
7
- data.tar.gz: 06feb166ae7e01f3594de4ee25f987b9fe830d879fb5888dea4e0573823b23b56705667eb99bf7ecf464c6703a5ebc4602e076bc0d86e601974b3396ea5493ab
6
+ metadata.gz: 70079bd19309f0e4fa5ec95d83ccde5c713b86f56b919072bdf84c58e88c20197210d7aa4b83bbb7cf748bd5cb977cdfcc0fba672e8a7509128e189bffda8341
7
+ data.tar.gz: 0594fd76d97cb9a1f8b392eaf1dde8b25daf4e3cef4961b55a5b5dd4ba11fb2e3aa335c37e4055aed788772b2d51b43fd37cea6091e645ecddeedd582000990b
@@ -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
@@ -1,3 +1,3 @@
1
1
  class Masque
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -3,11 +3,40 @@
3
3
  require "spec_helper"
4
4
 
5
5
  describe Masque do
6
- it ".new" do
7
- opts = {:display => 50, :driver => :webkit}
8
- masque = Masque.new(opts)
9
- masque.options.should == opts
10
- masque.respond_to?(:run).should be_true
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: masque
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - uu59