Sha256: 05f6d7dc4206a5b947b394bb4ed512a1dd93f4e93ae4a0062d9eb120da0d41a2

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

module ExampleHelper
  def passed_example
    base_example { expect(true).to be true }
  end

  def failed_example
    base_example { expect(true).to be false }
  end

  def pending_example
    example = if ::RSpec::Version::STRING >= '2.99.0'
                base_example { skip('No such step(0): ') }
              else
                base_example { pending('No such step(0): ') }
              end

    # Turnip::Rspec::Execute#run_step
    example.metadata[:line_number] = 10
    example.metadata[:location] = "#{example.metadata[:file_path]}:10"
    example
  end

  private

    def base_example(&assertion)
      group = ::RSpec::Core::ExampleGroup.describe('Feature').describe('Scenario')
      example = group.example('example', example_metadata, &assertion)
      example.metadata[:file_path] = '/path/to/hoge.feature'

      instance_eval <<-EOS, example.metadata[:file_path], 10
        group.run(NoopObject.new)
      EOS

      example
    end

    def example_metadata
      {
        turnip_formatter: {
          steps: [Turnip::Builder::Step.new('Step 1', [], 1, 'When')],
          tags: []
        }
      }
    end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
turnip_formatter-0.5.0 spec/support/example_helper.rb
turnip_formatter-0.4.0 spec/support/example_helper.rb
turnip_formatter-0.3.4 spec/support/example_helper.rb
turnip_formatter-0.3.3 spec/support/example_helper.rb
turnip_formatter-0.3.2 spec/support/example_helper.rb