Module: Daddy::Cucumber::Capture

Defined in:
lib/daddy/cucumber/capture.rb

Constant Summary collapse

REPORT_DIR =
'features/reports'
IMAGE_DIR =
'images'
@@_screen_count =
0

Instance Method Summary collapse

Instance Method Details

#captureObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/daddy/cucumber/capture.rb', line 12

def capture
  pause

  url = Rack::Utils.unescape(current_url)
    
  @@_screen_count += 1

  image = "#{IMAGE_DIR}/#{@@_screen_count}.png"
  page.driver.save_screenshot("#{REPORT_DIR}/#{image}")

  puts %{
    <div>#{url}</div>
    <img class="screenshot" src="#{image}"/>
  }
end

#resize_window(width, height) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/daddy/cucumber/capture.rb', line 28

def resize_window(width, height)
  case Capybara.current_driver
  when :poltergeist
    Capybara.current_session.driver.resize(width, height)
  when :selenium
    Capybara.current_session.driver.browser.manage.window.resize_to(width, height)
  when :webkit
    # TODO
  end
end