Sha256: 63f3b328953cef9fcd4ef10b5f698cfc3e62c56d275507c6bfcbf83333e60f06

Contents?: true

Size: 1.34 KB

Versions: 7

Compression:

Stored size: 1.34 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

  def create_step_node(keyword, text, line)
    step_metadata = {
      type: :Step,
      location: { line: line, column: 1 },
      keyword: keyword,
      text: text,
      argument: nil
    }

    Turnip::Node::Step.new(step_metadata)
  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: [create_step_node('Step', 'Step 1', 1)],
          tags: []
        }
      }
    end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
turnip_formatter-0.6.0.pre.beta.7 spec/support/example_helper.rb
turnip_formatter-0.6.0.pre.beta.6 spec/support/example_helper.rb
turnip_formatter-0.6.0.pre.beta.5 spec/support/example_helper.rb
turnip_formatter-0.6.0.pre.beta.4 spec/support/example_helper.rb
turnip_formatter-0.6.0.pre.beta.3 spec/support/example_helper.rb
turnip_formatter-0.6.0.pre.beta.2 spec/support/example_helper.rb
turnip_formatter-0.6.0.pre.beta.1 spec/support/example_helper.rb