Skip to content

Commit

Permalink
Merge pull request #103 from marcoadkins/master
Browse files Browse the repository at this point in the history
Support turnip version 4 and limit counts to features
  • Loading branch information
gongo authored Sep 6, 2023
2 parents 090e4a0 + 80bf322 commit e3f3543
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
16 changes: 13 additions & 3 deletions lib/rspec/core/formatters/turnip_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module RSpec
module Core
module Formatters
class TurnipFormatter < BaseFormatter
attr_accessor :scenarios
attr_accessor :scenarios, :failure_count, :pending_count

Formatters.register self, :example_passed, :example_pending, :example_failed, :dump_summary

Expand All @@ -24,29 +24,39 @@ def self.formatted_backtrace(example, exception = nil)
def initialize(output)
super(output)
@scenarios = []
@failure_count = 0
@pending_count = 0
end

def dump_summary(summary)
print_params = {
scenarios: scenarios,
failed_count: summary.failure_count,
pending_count: summary.pending_count,
failed_count: failure_count,
pending_count: pending_count,
total_time: summary.duration
}
output_html(print_params)
end

def example_passed(notification)
return unless notification.example.metadata[:type] == :feature

scenario = ::TurnipFormatter::Resource::Scenario::Pass.new(notification.example)
scenarios << scenario
end

def example_pending(notification)
return unless notification.example.metadata[:type] == :feature

@pending_count +=1
scenario = ::TurnipFormatter::Resource::Scenario::Pending.new(notification.example)
scenarios << scenario
end

def example_failed(notification)
return unless notification.example.metadata[:type] == :feature

@failure_count +=1
scenario = ::TurnipFormatter::Resource::Scenario::Failure.new(notification.example)
scenarios << scenario
end
Expand Down
2 changes: 1 addition & 1 deletion test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def run_feature(feature, filename)
expect(true).to be false # RSpec Matcher Error
end

Turnip::RSpec.__send__(:run_feature, rspec_context, feature, filename)
Turnip::RSpec.__send__(:run_scenario_group, rspec_context, feature, filename)
rspec_context.run(NoopObject.new)
Turnip::RSpec.update_metadata(feature, rspec_context)

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{^test/})
spec.require_paths = ['lib']

spec.add_dependency 'turnip', '~> 3.1.0'
spec.add_dependency 'turnip', '~> 4.1'
spec.add_dependency 'rspec', [">=3.3", "<4.0"]

# For ruby >= 2.1
Expand Down

0 comments on commit e3f3543

Please sign in to comment.