Class: Capybara::Experience

Inherits:
Object
  • Object
show all
Includes:
DSL
Defined in:
lib/capybara/experience.rb,
lib/capybara/experience/pool.rb,
lib/capybara/experience/rspec.rb,
lib/capybara/experience/version.rb

Defined Under Namespace

Modules: BehaviorDSL, UnifySessionPool Classes: Error, Pool

Constant Summary collapse

VERSION =
"0.3.4"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(driver_name: nil) ⇒ Experience

Returns a new instance of Experience.



15
16
17
# File 'lib/capybara/experience.rb', line 15

def initialize(driver_name: nil)
  @driver_name = driver_name
end

Class Method Details

.wait_for_pending_requestsObject



39
40
41
42
43
# File 'lib/capybara/experience.rb', line 39

def self.wait_for_pending_requests
  Experience::Pool.taken.each do |session|
    session.server.try(:wait_for_pending_requests)
  end
end

Instance Method Details

#driverObject



27
28
29
# File 'lib/capybara/experience.rb', line 27

def driver
  page.driver
end

#driver_nameObject



23
24
25
# File 'lib/capybara/experience.rb', line 23

def driver_name
  @driver_name ||= Capybara.current_driver
end

#pageObject



31
32
33
34
35
36
37
# File 'lib/capybara/experience.rb', line 31

def page
  @page ||= Experience::Pool.instance.take(driver: driver_name)

  Capybara::Screenshot.final_session_name = @page.object_id if defined?(Capybara::Screenshot)

  @page
end

#reload_pageObject



19
20
21
# File 'lib/capybara/experience.rb', line 19

def reload_page
  visit current_url
end

#t(*arg) ⇒ Object



10
11
12
# File 'lib/capybara/experience.rb', line 10

def t(*arg)
  I18n.t(*args)
end