Skip to content

Instantly share code, notes, and snippets.

@jerilevine
Last active April 24, 2017 20:16
Show Gist options
  • Select an option

  • Save jerilevine/478fdeb43754d4e9b7ce6b4f74fa2e06 to your computer and use it in GitHub Desktop.

Select an option

Save jerilevine/478fdeb43754d4e9b7ce6b4f74fa2e06 to your computer and use it in GitHub Desktop.

Revisions

  1. jerilevine revised this gist Apr 24, 2017. No changes.
  2. jerilevine created this gist Feb 15, 2017.
    14 changes: 14 additions & 0 deletions acceptance_helper.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    LOG_DIR = Rails.root.join('log')
    LOG = Logger.new(File.join(LOG_DIR, "turnip_#{Time.now.strftime("%Y%m%d%H%M")}.log"))
    LOG.level = Logger::DEBUG

    RSpec.configure do |config|
    config.before(:each) do | scenario |
    LOG.info("========================================")
    LOG.info("Starting test #{scenario.example_group.description}")
    end

    config.after(:each) do | scenario |
    LOG.info("Test #{scenario.example_group.description} completed.")
    end
    end
    23 changes: 23 additions & 0 deletions step_logger.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    # Monkeypatch for https://github.com/jnicklas/turnip
    # Output Turnip stepwise results to log file

    module Turnip
    module RSpec
    module Execute
    alias_method :old_run_step, :run_step

    def run_step(feature_file, step)
    begin
    old_run_step(feature_file, step)
    LOG.info("#{step.description}: As expected. PASS")
    rescue Turnip::Pending, ::RSpec::Core::Pending::SkipDeclaredInExample => e
    LOG.warn("#{step.description}: No such step. PENDING")
    raise
    rescue StandardError, ::RSpec::Expectations::ExpectationNotMetError => e
    LOG.error("#{step.description}: FAILED")
    raise e
    end
    end
    end
    end
    end