module CucumberCinema::ViewSelectStrategy

Public Class Methods

new_movie(options={}) click to toggle source
# File lib/cucumber_cinema/view_strategy.rb, line 15
def self.new_movie(options={})
  if ENV['CUCUMBER_CINEMA']
    $cucumber_cinema_screenshots = {}
    $cucumber_cinema_emails = {}
    create_screenhot_dir(options)
    $cucumber_cinema_prefix = options[:prefix].present? ? options[:prefix] : "take"
    $cucumber_cinema_action_shots=[]
    $cucumber_cinema_all_screenshots=[]
  end
end
take_screenshot?(request) click to toggle source
# File lib/cucumber_cinema/view_strategy.rb, line 4
def self.take_screenshot?(request)
  return false unless request
  current_shot = "#{request.filtered_parameters["controller"]}-#{request.filtered_parameters["action"]}-#{request.method}"
  if !$cucumber_cinema_screenshots[current_shot]
    $cucumber_cinema_screenshots[current_shot] = 1
    true
  else
    false
  end
end

Protected Class Methods

copy_assets() click to toggle source
# File lib/cucumber_cinema/view_strategy.rb, line 43
def self.copy_assets
  Dir["#{Gem.searcher.find('cucumber-cinema').full_gem_path}/public/*"].each do |asset|
    `cp -r #{asset} #{$cucumber_cinema_location}/#{$cucumber_cinema_dir_name}/`
  end

end
create_screenhot_dir(options) click to toggle source
# File lib/cucumber_cinema/view_strategy.rb, line 28
def self.create_screenhot_dir(options)
  $cucumber_cinema_dir_name = "#{Time.new.strftime("%Y%m%d%H%M%S")}"
  $cucumber_cinema_location=options[:location] || "#{Rails.root}/tmp/screenshots/"
  $cucumber_cinema_link=options[:link_location] || "#{Rails.root}/tmp/latest_screenshots"
  Dir.mkdir("#{$cucumber_cinema_location}") unless Dir.exist?($cucumber_cinema_location)

  create_link
  copy_assets
end