Sha256: dc5dbd97d64b50d818d8372d920fb8037a75fd78f22bdc6549bbb1e0e2e08cf3

Contents?: true

Size: 1.49 KB

Versions: 17

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

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)
          if scenario.feature.respond_to?(:name)
            report_name = "#{scenario.feature.name}:#{scenario.name}"
          else
            report_name = "#{scenario.feature.title}:#{scenario.title}"
          end
        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
          if Object.const_defined?("Rails")
            Rails.logger.error(test_message(start_end, test_name))
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
cornucopia-0.2.0 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.56 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.55 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.54 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.53 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.52 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.51 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.50 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.49 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.48 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.47 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.46 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.45 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.44 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.43 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.42 lib/cornucopia/util/test_helper.rb
cornucopia-0.1.41 lib/cornucopia/util/test_helper.rb