Class: Masque
- Inherits:
-
Object
- Object
- Masque
- Defined in:
- lib/masque.rb,
lib/masque/dsl.rb,
lib/masque/version.rb
Defined Under Namespace
Modules: DSL
Constant Summary collapse
- VERSION =
"0.3.0"
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #compat_capybara_1x! ⇒ Object
- #compat_capybara_20! ⇒ Object
-
#initialize(options = {}) ⇒ Masque
constructor
A new instance of Masque.
- #reset_session! ⇒ Object
- #run(&block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Masque
Returns a new instance of Masque.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/masque.rb', line 16 def initialize( = {}) @options = @driver = [:driver] || :webkit @agent = Class.new do include Masque::DSL attr_accessor :session def initialize(session) @session = session end def method_missing(*args, &block) if block_given? session.__send__(*args, &block) else session.__send__(*args) end end end.new(Capybara::Session.new(@driver)) if @driver == :webkit h = Headless.new(.merge(:destroy_at_exit => false, :reuse => true)) h.start ObjectSpace.define_finalizer(@agent.driver.browser.instance_variable_get(:@connection)) do h.destroy end end end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
10 11 12 |
# File 'lib/masque.rb', line 10 def agent @agent end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/masque.rb', line 10 def @options end |
Class Method Details
.run(options = {}, &block) ⇒ Object
12 13 14 |
# File 'lib/masque.rb', line 12 def self.run( = {}, &block) new().run(&block) end |
Instance Method Details
#compat_capybara_1x! ⇒ Object
65 66 67 68 69 70 |
# File 'lib/masque.rb', line 65 def Capybara.configure do |config| config.match = :prefer_exact config.ignore_hidden_elements = false end end |
#compat_capybara_20! ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/masque.rb', line 56 def Capybara.configure do |config| config.match = :one config. = true config.ignore_hidden_elements = true config.visible_text_only = true end end |
#reset_session! ⇒ Object
46 47 48 49 50 |
# File 'lib/masque.rb', line 46 def reset_session! run do driver.reset! end end |
#run(&block) ⇒ Object
52 53 54 |
# File 'lib/masque.rb', line 52 def run(&block) @agent.instance_eval(&block) end |