Skip to content

Commit

Permalink
Add a (failing) test for better source output for scenario outline steps
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwynne committed May 15, 2017
1 parent 15f9e57 commit dc41d81
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'cucumber/configuration'
require 'cucumber/core/test/case'
require 'cucumber/hooks'
require 'cucumber/core/gherkin/document'

describe Cucumber::Formatter::EventStream::Plugin do
describe "when the test run starts" do
Expand Down Expand Up @@ -81,6 +82,45 @@
expect(message['steps'][0]['actionLocation']).to eq({ 'uri' => 'features/step_definitions/steps.rb', 'line' => 1 })
expect(message['steps'][0]['sourceLocation']).to eq({ 'uri' => 'features/test.feature', 'line' => 4 })
end

it "emits a source location with two lines for a Gherkin Scenario Outline step" do
test_cases = compile('features/test.feature', %{Feature:
Scenario Outline:
Given this step is <status>
Examples:
| status |
| passing |
})

passing_test_case = test_cases[0].
with_steps(test_cases[0].test_steps.map { |test_step| test_step.with_action { } })
output = run_test_cases([ passing_test_case ])
message = output.find { |message| message['type'] == 'test-case-prepared' }
expect(message['steps'][0]['sourceLocation']).to eq({ 'uri' => 'features/test.feature', 'lines' => [ 7, 3 ]})
end

def compile(file, gherkin)
core = Object.new.extend(Cucumber::Core)
receiver = Receiver.new
core.compile([Cucumber::Core::Gherkin::Document.new(file, gherkin)], receiver)
receiver.test_cases
end

class Receiver
attr_reader :test_cases

def initialize
@test_cases = []
end

def test_case(test_case)
@test_cases << test_case
end

def done
end
end
end

def location(file_colon_line)
Expand Down

0 comments on commit dc41d81

Please sign in to comment.