Sha256: 6727de1dee5df3ec79d80703eec9364bf83ff7d41140bbafdb8876bf3dde8806

Contents?: true

Size: 961 Bytes

Versions: 5

Compression:

Stored size: 961 Bytes

Contents

# coding: UTF-8

module Daddy
  module Cucumber
    module Capture
      REPORT_DIR = 'features/reports'
      IMAGE_DIR = 'images'
      FileUtils.mkdir_p("#{REPORT_DIR}/#{IMAGE_DIR}")
    
      @@_screen_count = 0
    
      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

      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

    end
  end
end

World(Daddy::Cucumber::Capture)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
daddy-0.1.20 lib/daddy/cucumber/capture.rb
daddy-0.1.18 lib/daddy/cucumber/capture.rb
daddy-0.1.17 lib/daddy/cucumber/capture.rb
daddy-0.1.15 lib/daddy/cucumber/capture.rb
daddy-0.1.14 lib/daddy/cucumber/capture.rb