Skip to content

Commit

Permalink
Merge fc947b1 into be22634
Browse files Browse the repository at this point in the history
  • Loading branch information
gongo committed Dec 15, 2015
2 parents be22634 + fc947b1 commit dc44942
Show file tree
Hide file tree
Showing 16 changed files with 61 additions and 158 deletions.
20 changes: 15 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@ language: ruby
sudo: false
cache: bundler

branches:
only:
- master
- 0.4.0-dev

matrix:
allow_failures:
- gemfile: gemfiles/Gemfile-rspec-3.2.x
- rvm: ruby-head

rvm:
- 2.0.0
- 2.1
- 2.2
- jruby-1.7.10
- ruby-head
- jruby-9.0.0.0

script: bundle exec rspec

gemfile:
- gemfiles/Gemfile-rspec-2.14.x
- gemfiles/Gemfile-rspec-2.99.x
- gemfiles/Gemfile-rspec-3.0.x
- gemfiles/Gemfile-rspec-3.1.x
- gemfiles/Gemfile-rspec-3.2.x
- gemfiles/Gemfile-rspec-3.3.x
4 changes: 0 additions & 4 deletions gemfiles/Gemfile-rspec-2.14.x

This file was deleted.

4 changes: 0 additions & 4 deletions gemfiles/Gemfile-rspec-2.99.x

This file was deleted.

4 changes: 0 additions & 4 deletions gemfiles/Gemfile-rspec-3.1.x

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source 'http://rubygems.org'

gemspec :path => '..'
gem 'rspec', '~> 3.0.0'
gem 'rspec', '~> 3.3.0'
38 changes: 30 additions & 8 deletions lib/rspec/core/formatters/turnip_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,50 @@
require 'turnip_formatter/scenario/pending'
require 'turnip_formatter/printer/index'
require 'turnip_formatter/printer/scenario'
require_relative './turnip_formatter/for_rspec2'
require_relative './turnip_formatter/for_rspec3'

module RSpec
module Core
module Formatters
class TurnipFormatter < BaseFormatter
attr_accessor :scenarios

if Formatters.respond_to?(:register)
include TurnipFormatter::ForRSpec3
extend TurnipFormatter::ForRSpec3::Helper
else
include TurnipFormatter::ForRSpec2
extend TurnipFormatter::ForRSpec2::Helper
Formatters.register self, :example_passed, :example_pending, :example_failed, :dump_summary

def self.formatted_backtrace(example)
formatter = RSpec.configuration.backtrace_formatter
formatter.format_backtrace(example.exception.backtrace, example.metadata)
end

def initialize(output)
super(output)
@scenarios = []
end

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

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

def example_pending(notification)
scenario = ::TurnipFormatter::Scenario::Pending.new(notification.example)
scenarios << scenario
end

def example_failed(notification)
scenario = ::TurnipFormatter::Scenario::Failure.new(notification.example)
scenarios << scenario
end

private

def output_html(params)
Expand Down
42 changes: 0 additions & 42 deletions lib/rspec/core/formatters/turnip_formatter/for_rspec2.rb

This file was deleted.

47 changes: 0 additions & 47 deletions lib/rspec/core/formatters/turnip_formatter/for_rspec3.rb

This file was deleted.

1 change: 0 additions & 1 deletion lib/turnip_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def configuration
end

require 'rspec/core/formatters/turnip_formatter'
require 'turnip_formatter/helper'
require 'turnip_formatter/template'
require 'turnip_formatter/step_template/exception'
require 'turnip_formatter/step_template/source'
Expand Down
22 changes: 0 additions & 22 deletions lib/turnip_formatter/helper.rb

This file was deleted.

10 changes: 2 additions & 8 deletions lib/turnip_formatter/scenario/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,14 @@ def raw_steps
# @return [Hash] parent example group
#
def parent_example_group
if example.example_group.metadata.key?(:parent_example_group)
# RSpec 3
example.example_group.metadata[:parent_example_group]
else
# RSpec 2
example.example_group.metadata[:example_group][:example_group]
end
example.example_group.metadata[:parent_example_group]
end

#
# @return [OpenStruct or ::RSpec::Core::Example::ExecutionResult]
#
def execution_result
@execution_result ||= Helper.example_execution_result(example)
@execution_result ||= example.execution_result
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/turnip_formatter/scenario/pending.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def pending_line_number
end

def pending_message
result = TurnipFormatter::Helper.example_execution_result(example)
result.pending_message
example.execution_result.pending_message
end
end
end
Expand Down
3 changes: 1 addition & 2 deletions lib/turnip_formatter/step_template/exception.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def build_failed(example)
# @param [RSpec::Core::Example] example
#
def build_pending(example)
result = TurnipFormatter::Helper.example_execution_result(example)
build(result.pending_message, [example.location])
build(example.execution_result.pending_message, [example.location])
end

private
Expand Down
16 changes: 9 additions & 7 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
require 'simplecov'
require 'coveralls'
if !defined?(JRUBY_VERSION)
require 'simplecov'
require 'coveralls'

SimpleCov.formatter = Coveralls::SimpleCov::Formatter
SimpleCov.start do
add_filter 'spec/'
add_filter 'vendor/'
add_filter 'lib/turnip_formatter/ext'
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
SimpleCov.start do
add_filter 'spec/'
add_filter 'vendor/'
add_filter 'lib/turnip_formatter/ext'
end
end

require 'turnip_formatter'
Expand Down
1 change: 1 addition & 0 deletions spec/turnip_formatter/template_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'spec_helper'
require 'tempfile'

describe TurnipFormatter::Template do
let(:template) { described_class }
Expand Down
2 changes: 1 addition & 1 deletion turnip_formatter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |spec|

spec.add_dependency 'turnip', '~> 1.3.0'
spec.add_dependency 'slim'
spec.add_dependency 'rspec', ['>=2.14.0', '<4.0']
spec.add_dependency 'rspec', [">=3.0", "<3.4"]
spec.add_development_dependency 'bundler', '~> 1.3'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'coveralls'
Expand Down

0 comments on commit dc44942

Please sign in to comment.