Sha256: 08996d57966461a9667fd6a876734918023375eb36509c6910a25b5147492ba2

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

require "singleton"

module Cornucopia
  module Util
    class TestHelper
      include Singleton

      attr_accessor :spinach_reported_error, :spinach_running_scenario

      def cucumber_name(scenario)
        report_name = "Unknown"
        if scenario.respond_to?(:feature)
          report_name = "#{scenario.feature.title}:#{scenario.title}"
        elsif scenario.respond_to?(:line)
          report_name = "Line - #{scenario.line}"
        end

        report_name
      end

      def spinach_name(scenario_data)
        "#{scenario_data.feature.name} : #{scenario_data.name}"
      end

      def rspec_name(example)
        example.full_description
      end

      def record_test_start(test_name)
        record_test("Start", test_name)
      end

      def record_test_end(test_name)
        record_test("End", test_name)
      end

      def test_message(start_end, test_name)
        Cornucopia::Util::Configuration.record_test_start_and_end_format % {
            start_end: start_end,
            test_name: test_name
        }
      end

      def record_test(start_end, test_name)
        if Cornucopia::Util::Configuration.record_test_start_and_end_in_log
          Rails.logger.error(test_message(start_end, test_name))
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cornucopia-0.1.30 lib/cornucopia/util/test_helper.rb