Class: ScreenshotMaker

Inherits:
Object
  • Object
show all
Defined in:
lib/acceptance_test/screenshot_maker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(basedir) ⇒ ScreenshotMaker

Returns a new instance of ScreenshotMaker.



4
5
6
# File 'lib/acceptance_test/screenshot_maker.rb', line 4

def initialize basedir
  @basedir = basedir
end

Instance Attribute Details

#basedirObject

Returns the value of attribute basedir.



2
3
4
# File 'lib/acceptance_test/screenshot_maker.rb', line 2

def basedir
  @basedir
end

Instance Method Details

#make(page, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/acceptance_test/screenshot_maker.rb', line 8

def make page, options
  FileUtils.mkdir_p basedir unless File.exist? basedir

  file_path = options[:file_path]

  name = screenshot_name(build_name(file_path), options[:line_number])
  path = File.expand_path("#{basedir}/#{name}")

  page.save_screenshot(path)
end

#screenshot_url(options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/acceptance_test/screenshot_maker.rb', line 19

def screenshot_url options
  file_path = options[:file_path]

  if options[:screenshot_url_base]
    name = screenshot_name(build_name(file_path), options[:line_number])

    "#{options[:screenshot_url_base]}/#{name}"
  else
    name = screenshot_name(build_name(file_path), options[:line_number])

    path = File.expand_path("#{basedir}/#{name}")

    "file:///#{path}"
  end
end