Class: Poltergeist::ScreenshotOverview::Screenshot
- Inherits:
-
Object
- Object
- Poltergeist::ScreenshotOverview::Screenshot
- 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
- #full_test_path ⇒ Object
-
#initialize(opts = {}) ⇒ Screenshot
constructor
A new instance of Screenshot.
- #line_number ⇒ Object
- #render ⇒ Object
- #snippet ⇒ Object
- #test_file ⇒ Object
- #to_hash ⇒ Object
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_path ⇒ Object
36 37 38 |
# File 'lib/poltergeist/screenshot_overview/manager.rb', line 36 def full_test_path file_with_line.split(":")[0] end |
#line_number ⇒ Object
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 |
#render ⇒ Object
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 |
#snippet ⇒ Object
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_file ⇒ Object
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_hash ⇒ Object
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 |