Class: Poltergeist::ScreenshotOverview::Screenshot

Inherits:
Object
  • Object
show all
Defined in:
lib/poltergeist/screenshot_overview/manager.rb

Constant Summary collapse

ATTR =
:url, :argument, :local_image, :full_path, :group_description, :example_description, :file_with_line

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Screenshot

Returns a new instance of Screenshot.



20
21
22
23
24
# File 'lib/poltergeist/screenshot_overview/manager.rb', line 20

def initialize(opts={})
  opts.each do |k,v|
    self.send("#{k}=", v)
  end
end

Instance Method Details

#full_test_pathObject



36
37
38
# File 'lib/poltergeist/screenshot_overview/manager.rb', line 36

def full_test_path
  file_with_line.split(":")[0]
end

#line_numberObject



32
33
34
# File 'lib/poltergeist/screenshot_overview/manager.rb', line 32

def line_number
  file_with_line.split(":")[1].to_i rescue 0
end

#renderObject



48
49
50
51
# File 'lib/poltergeist/screenshot_overview/manager.rb', line 48

def render
  template = ERB.new File.read(Poltergeist::ScreenshotOverview.template), nil, "%"
  template.result(binding)
end

#snippetObject



40
41
42
# File 'lib/poltergeist/screenshot_overview/manager.rb', line 40

def snippet
  File.read(full_test_path).lines[ line_number - 3, 5].join
end

#test_fileObject



44
45
46
# File 'lib/poltergeist/screenshot_overview/manager.rb', line 44

def test_file
  full_test_path.gsub(Dir.pwd, "").gsub("spec/features/","")
end

#to_hashObject



26
27
28
29
30
# File 'lib/poltergeist/screenshot_overview/manager.rb', line 26

def to_hash
  Hash[
    ATTR.map{|k|[k, self.send(k)]}
  ]
end