Class: Lazyman::LazymanFormatter
- Inherits:
-
RSpec::Core::Formatters::HtmlFormatter
- Object
- RSpec::Core::Formatters::HtmlFormatter
- Lazyman::LazymanFormatter
- Defined in:
- lib/magicspec/generators/magicspec/app/spec/support/formatters/magicspec_formatter.rb
Instance Method Summary collapse
- #example_failed(example) ⇒ Object
- #example_passed(example) ⇒ Object
- #extra_failure_content(failure) ⇒ Object
-
#initialize(output) ⇒ LazymanFormatter
constructor
A new instance of LazymanFormatter.
Constructor Details
#initialize(output) ⇒ LazymanFormatter
Returns a new instance of LazymanFormatter.
7 8 9 10 11 12 13 |
# File 'lib/magicspec/generators/magicspec/app/spec/support/formatters/magicspec_formatter.rb', line 7 def initialize(output) output = File.new(File.(File.join('.', 'app', 'reports', "#{Time.now.strftime("%Y%m%d_%H%M%S")}.html")), 'w') super(output) @printer.class.send(:define_method, 'puts') do |what| @output.puts what end #define_method end |
Instance Method Details
#example_failed(example) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/magicspec/generators/magicspec/app/spec/support/formatters/magicspec_formatter.rb', line 15 def example_failed(example) super(example) if $navi failed_url = $navi.url rescue $navi.current_url @printer.puts "<a target=\"_blank\" href=\"#{failed_url}\">failed url is [#{failed_url}]</a>" @printer.puts '<br />' @printer.puts '<p>Extra problem text</p>' @printer.flush end #if end |
#example_passed(example) ⇒ Object
26 27 28 29 |
# File 'lib/magicspec/generators/magicspec/app/spec/support/formatters/magicspec_formatter.rb', line 26 def example_passed(example) super(example) @printer.flush end |
#extra_failure_content(failure) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/magicspec/generators/magicspec/app/spec/support/formatters/magicspec_formatter.rb', line 31 def extra_failure_content(failure) browser = example_group.before_all_ivars[:@browser] || @browser # If we'ere dealing with a browser get a screenshot on failure if browser browser.screenshot.save File.(File.join('.', 'app', 'reports','screenshots', "#{Time.now.strftime("%Y%m%d_%H%M%S")}.png")) # Need to figure out how to remotely upload content = [] content << "<span>" content << "<a target='_blank' href='http://127.0.0.1:8020/o365/app/reports/screenshots/20131031_103612.png'>screenshot</a>" content << "</span>" super + content.join($/) end end |