Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gongo committed Sep 20, 2014
1 parent 9d45ebc commit 75c97bc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
1 change: 0 additions & 1 deletion lib/turnip_formatter/scenario/failure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def failed_line_number
return unless example.exception

filepath = File.basename(feature_file_path)

line = example.exception.backtrace.find do |backtrace|
backtrace.match(/#{filepath}:(\d+)/)
end
Expand Down
16 changes: 6 additions & 10 deletions spec/support/example_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,24 @@ def pending_example
end
end

def invalid_pending_example
if ::RSpec::Version::STRING >= '2.99.0'
base_example { skip('Pending') }
else
base_example { pending('Pending') }
end
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'
group.run(NoopObject.new)

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

example
end

def example_metadata
{
turnip_formatter: {
steps: [ { name: 'Step 1', extra_args: [], keyword: 'When' } ],
steps: [Turnip::Builder::Step.new('Step 1', [], 1, 'When')],
tags: []
}
}
Expand Down
2 changes: 1 addition & 1 deletion spec/support/step_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ def base_step(example)
end

def step_description
{ name: 'StepName', keyword: 'Keyword', extra_args: ['Docstring'] }
Turnip::Builder::Step.new('StepName', ['Docstring'], 1, 'Keyword')
end
end
6 changes: 5 additions & 1 deletion spec/turnip_formatter/scenario/failure_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

context 'called by not turnip example' do
let(:example) do
failed_example.tap { |e| e.exception.backtrace.pop }
backtrace = failed_example.exception.backtrace.reject do |b|
b.include? failed_example.metadata[:file_path]
end

failed_example.tap { |e| e.exception.set_backtrace(backtrace) }
end

it { should be false }
Expand Down
2 changes: 1 addition & 1 deletion spec/turnip_formatter/scenario/pending_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

context 'called by not turnip example' do
let(:example) do
invalid_pending_example
pending_example.tap { |e| e.metadata[:line_number] = nil }
end

it { should be false }
Expand Down
2 changes: 1 addition & 1 deletion turnip_formatter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^spec/})
spec.require_paths = ['lib']

spec.add_dependency 'turnip', '~> 1.2.2'
spec.add_dependency 'turnip', '~> 1.2.4'
spec.add_dependency 'haml'
spec.add_dependency 'sass'
spec.add_dependency 'bootstrap-sass'
Expand Down

0 comments on commit 75c97bc

Please sign in to comment.