turnip_formatter 0.3.4 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf2cb89186ac950d7e5016cdf19bd3971bd99ea7
4
- data.tar.gz: 806569c9a32ee90d4dd74cd436eb40873b59637c
3
+ metadata.gz: 5c2de1ecef64d4a95753fdf6bd9a9eeb6916bf95
4
+ data.tar.gz: 431ffff5eb2458aecf9d49612bcdf90942767296
5
5
  SHA512:
6
- metadata.gz: 960fb26961d339b500bfd59d54d31849a28ff9fad2103cf9bc36cbaf36b8b16da8dd539b243bfeea2352a180135e57a302c8f7cd182929ab70e8f926293e9717
7
- data.tar.gz: f93667549138a32b54ef8fe0ee814668e0b5bdd750b1cd82f904a1e1f0edb0e03280137bc77d20d25f1769c13b1328ea15c7d473efea57408525538d542095ff
6
+ metadata.gz: f0a0b433a65848792bb93990070b7e3d280a733511bb9e29a4b7e3b7971fadd0f5374b9fca5ebb0f157a79409190c1241dd719ce09322bbeb59ca7b26d0c4b57
7
+ data.tar.gz: a09fe98fd660bbe2f47ff24e6a11bbc7dd8cd6e46c0740899c5d05d462f53bb3a7b7af0725d265e08abf3db8f2e4afc0972c5803c75d2c7b113703846fcc7e04
data/.travis.yml CHANGED
@@ -1,13 +1,27 @@
1
1
  language: ruby
2
+
3
+ sudo: false
4
+ cache: bundler
5
+
6
+ branches:
7
+ only:
8
+ - master
9
+ - 0.4.0-dev
10
+
11
+ matrix:
12
+ allow_failures:
13
+ - gemfile: gemfiles/Gemfile-rspec-3.2.x
14
+ - rvm: ruby-head
15
+
2
16
  rvm:
3
17
  - 2.0.0
4
18
  - 2.1
5
19
  - 2.2
6
- - jruby-1.7.10
20
+ - ruby-head
21
+ - jruby-9.0.0.0
22
+
7
23
  script: bundle exec rspec
24
+
8
25
  gemfile:
9
- - spec/gemfiles/Gemfile-rspec-2.14.x
10
- - spec/gemfiles/Gemfile-rspec-2.99.x
11
- - spec/gemfiles/Gemfile-rspec-3.0.x
12
- - spec/gemfiles/Gemfile-rspec-3.1.x
13
- - spec/gemfiles/Gemfile-rspec-3.2.x
26
+ - gemfiles/Gemfile-rspec-3.2.x
27
+ - gemfiles/Gemfile-rspec-3.3.x
@@ -1,4 +1,4 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gemspec :path => '../..'
3
+ gemspec :path => '..'
4
4
  gem 'rspec', '~> 3.2.0'
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec :path => '..'
4
+ gem 'rspec', '~> 3.3.0'
@@ -6,8 +6,6 @@ require 'turnip_formatter/scenario/failure'
6
6
  require 'turnip_formatter/scenario/pending'
7
7
  require 'turnip_formatter/printer/index'
8
8
  require 'turnip_formatter/printer/scenario'
9
- require_relative './turnip_formatter/for_rspec2'
10
- require_relative './turnip_formatter/for_rspec3'
11
9
 
12
10
  module RSpec
13
11
  module Core
@@ -15,12 +13,11 @@ module RSpec
15
13
  class TurnipFormatter < BaseFormatter
16
14
  attr_accessor :scenarios
17
15
 
18
- if Formatters.respond_to?(:register)
19
- include TurnipFormatter::ForRSpec3
20
- extend TurnipFormatter::ForRSpec3::Helper
21
- else
22
- include TurnipFormatter::ForRSpec2
23
- extend TurnipFormatter::ForRSpec2::Helper
16
+ Formatters.register self, :example_passed, :example_pending, :example_failed, :dump_summary
17
+
18
+ def self.formatted_backtrace(example)
19
+ formatter = RSpec.configuration.backtrace_formatter
20
+ formatter.format_backtrace(example.exception.backtrace, example.metadata)
24
21
  end
25
22
 
26
23
  def initialize(output)
@@ -28,6 +25,31 @@ module RSpec
28
25
  @scenarios = []
29
26
  end
30
27
 
28
+ def dump_summary(summary)
29
+ print_params = {
30
+ scenarios: scenarios,
31
+ failed_count: summary.failure_count,
32
+ pending_count: summary.pending_count,
33
+ total_time: summary.duration
34
+ }
35
+ output_html(print_params)
36
+ end
37
+
38
+ def example_passed(notification)
39
+ scenario = ::TurnipFormatter::Scenario::Pass.new(notification.example)
40
+ scenarios << scenario
41
+ end
42
+
43
+ def example_pending(notification)
44
+ scenario = ::TurnipFormatter::Scenario::Pending.new(notification.example)
45
+ scenarios << scenario
46
+ end
47
+
48
+ def example_failed(notification)
49
+ scenario = ::TurnipFormatter::Scenario::Failure.new(notification.example)
50
+ scenarios << scenario
51
+ end
52
+
31
53
  private
32
54
 
33
55
  def output_html(params)
@@ -85,20 +85,14 @@ module TurnipFormatter
85
85
  # @return [Hash] parent example group
86
86
  #
87
87
  def parent_example_group
88
- if example.example_group.metadata.key?(:parent_example_group)
89
- # RSpec 3
90
- example.example_group.metadata[:parent_example_group]
91
- else
92
- # RSpec 2
93
- example.example_group.metadata[:example_group][:example_group]
94
- end
88
+ example.example_group.metadata[:parent_example_group]
95
89
  end
96
90
 
97
91
  #
98
92
  # @return [OpenStruct or ::RSpec::Core::Example::ExecutionResult]
99
93
  #
100
94
  def execution_result
101
- @execution_result ||= Helper.example_execution_result(example)
95
+ @execution_result ||= example.execution_result
102
96
  end
103
97
  end
104
98
  end
@@ -33,8 +33,7 @@ module TurnipFormatter
33
33
  end
34
34
 
35
35
  def pending_message
36
- result = TurnipFormatter::Helper.example_execution_result(example)
37
- result.pending_message
36
+ example.execution_result.pending_message
38
37
  end
39
38
  end
40
39
  end
@@ -35,8 +35,7 @@ module TurnipFormatter
35
35
  # @param [RSpec::Core::Example] example
36
36
  #
37
37
  def build_pending(example)
38
- result = TurnipFormatter::Helper.example_execution_result(example)
39
- build(result.pending_message, [example.location])
38
+ build(example.execution_result.pending_message, [example.location])
40
39
  end
41
40
 
42
41
  private
@@ -1,5 +1,4 @@
1
1
  require 'turnip_formatter/step_template/base'
2
- require 'rspec/core/formatters/snippet_extractor'
3
2
 
4
3
  module TurnipFormatter
5
4
  module StepTemplate
@@ -38,13 +37,21 @@ module TurnipFormatter
38
37
 
39
38
  private
40
39
 
41
- def location(example)
42
- formatted_backtrace(example).first
43
- end
40
+ def location(example)
41
+ formatted_backtrace(example).first
42
+ end
44
43
 
45
- def extractor
46
- @extractor ||= ::RSpec::Core::Formatters::SnippetExtractor.new
47
- end
44
+ def extractor
45
+ @extractor ||= begin
46
+ # RSpec 3.4
47
+ require 'rspec/core/formatters/html_snippet_extractor'
48
+ ::RSpec::Core::Formatters::HtmlSnippetExtractor.new
49
+ rescue LoadError
50
+ # RSpec 3.3 or earlier
51
+ require 'rspec/core/formatters/snippet_extractor'
52
+ ::RSpec::Core::Formatters::SnippetExtractor.new
53
+ end
54
+ end
48
55
  end
49
56
  end
50
57
  end
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module TurnipFormatter
4
- VERSION = '0.3.4'
4
+ VERSION = '0.4.0'
5
5
  end
@@ -43,7 +43,6 @@ module TurnipFormatter
43
43
  end
44
44
 
45
45
  require 'rspec/core/formatters/turnip_formatter'
46
- require 'turnip_formatter/helper'
47
46
  require 'turnip_formatter/template'
48
47
  require 'turnip_formatter/step_template/exception'
49
48
  require 'turnip_formatter/step_template/source'
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,13 @@
1
- require 'simplecov'
2
- require 'coveralls'
1
+ if !defined?(JRUBY_VERSION)
2
+ require 'simplecov'
3
+ require 'coveralls'
3
4
 
4
- SimpleCov.formatter = Coveralls::SimpleCov::Formatter
5
- SimpleCov.start do
6
- add_filter 'spec/'
7
- add_filter 'vendor/'
8
- add_filter 'lib/turnip_formatter/ext'
5
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
6
+ SimpleCov.start do
7
+ add_filter 'spec/'
8
+ add_filter 'vendor/'
9
+ add_filter 'lib/turnip_formatter/ext'
10
+ end
9
11
  end
10
12
 
11
13
  require 'turnip_formatter'
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'tempfile'
2
3
 
3
4
  describe TurnipFormatter::Template do
4
5
  let(:template) { described_class }
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^spec/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'turnip', '~> 1.3.0'
21
+ spec.add_dependency 'turnip', '~> 2.0.0'
22
22
  spec.add_dependency 'slim'
23
- spec.add_dependency 'rspec', ['>=2.14.0', '<4.0']
23
+ spec.add_dependency 'rspec', [">=3.0", "<4.0"]
24
24
  spec.add_development_dependency 'bundler', '~> 1.3'
25
25
  spec.add_development_dependency 'rake'
26
26
  spec.add_development_dependency 'coveralls'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turnip_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wataru MIYAGUNI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-22 00:00:00.000000000 Z
11
+ date: 2016-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: turnip
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.0
19
+ version: 2.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.0
26
+ version: 2.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: slim
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,7 +44,7 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.14.0
47
+ version: '3.0'
48
48
  - - "<"
49
49
  - !ruby/object:Gem::Version
50
50
  version: '4.0'
@@ -54,7 +54,7 @@ dependencies:
54
54
  requirements:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
- version: 2.14.0
57
+ version: '3.0'
58
58
  - - "<"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '4.0'
@@ -175,12 +175,11 @@ files:
175
175
  - example/spec/steps/escape_steps.rb
176
176
  - example/spec/steps/spell_steps.rb
177
177
  - example/spec/steps/steps.rb
178
+ - gemfiles/Gemfile-rspec-3.2.x
179
+ - gemfiles/Gemfile-rspec-3.3.x
178
180
  - lib/rspec/core/formatters/turnip_formatter.rb
179
- - lib/rspec/core/formatters/turnip_formatter/for_rspec2.rb
180
- - lib/rspec/core/formatters/turnip_formatter/for_rspec3.rb
181
181
  - lib/turnip_formatter.rb
182
182
  - lib/turnip_formatter/ext/turnip/rspec.rb
183
- - lib/turnip_formatter/helper.rb
184
183
  - lib/turnip_formatter/printer.rb
185
184
  - lib/turnip_formatter/printer/index.rb
186
185
  - lib/turnip_formatter/printer/runtime_error.rb
@@ -214,11 +213,6 @@ files:
214
213
  - lib/turnip_formatter/template/turnip_formatter.js
215
214
  - lib/turnip_formatter/template/turnip_formatter.scss
216
215
  - lib/turnip_formatter/version.rb
217
- - spec/gemfiles/Gemfile-rspec-2.14.x
218
- - spec/gemfiles/Gemfile-rspec-2.99.x
219
- - spec/gemfiles/Gemfile-rspec-3.0.x
220
- - spec/gemfiles/Gemfile-rspec-3.1.x
221
- - spec/gemfiles/Gemfile-rspec-3.2.x
222
216
  - spec/spec_helper.rb
223
217
  - spec/support/example_helper.rb
224
218
  - spec/support/passed.feature
@@ -258,16 +252,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
252
  version: '0'
259
253
  requirements: []
260
254
  rubyforge_project:
261
- rubygems_version: 2.2.2
255
+ rubygems_version: 2.4.5
262
256
  signing_key:
263
257
  specification_version: 4
264
258
  summary: RSpec custom formatter for Turnip
265
259
  test_files:
266
- - spec/gemfiles/Gemfile-rspec-2.14.x
267
- - spec/gemfiles/Gemfile-rspec-2.99.x
268
- - spec/gemfiles/Gemfile-rspec-3.0.x
269
- - spec/gemfiles/Gemfile-rspec-3.1.x
270
- - spec/gemfiles/Gemfile-rspec-3.2.x
271
260
  - spec/spec_helper.rb
272
261
  - spec/support/example_helper.rb
273
262
  - spec/support/passed.feature
@@ -1,42 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- module RSpec
4
- module Core
5
- module Formatters
6
- class TurnipFormatter < BaseFormatter
7
- module ForRSpec2
8
- def dump_summary(duration, _, failure_count, pending_count)
9
- print_params = {
10
- scenarios: scenarios,
11
- failed_count: failure_count,
12
- pending_count: pending_count,
13
- total_time: duration
14
- }
15
- output_html(print_params)
16
- end
17
-
18
- def example_passed(example)
19
- scenario = ::TurnipFormatter::Scenario::Pass.new(example)
20
- scenarios << scenario
21
- end
22
-
23
- def example_pending(example)
24
- scenario = ::TurnipFormatter::Scenario::Pending.new(example)
25
- scenarios << scenario
26
- end
27
-
28
- def example_failed(example)
29
- scenario = ::TurnipFormatter::Scenario::Failure.new(example)
30
- scenarios << scenario
31
- end
32
-
33
- module Helper
34
- def formatted_backtrace(example)
35
- RSpec::Core::BacktraceFormatter.format_backtrace(example.exception.backtrace, example.metadata)
36
- end
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,47 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- module RSpec
4
- module Core
5
- module Formatters
6
- class TurnipFormatter < BaseFormatter
7
- module ForRSpec3
8
- def self.included(klass)
9
- RSpec::Core::Formatters.register klass, :example_passed, :example_pending, :example_failed, :dump_summary
10
- end
11
-
12
- def dump_summary(summary)
13
- print_params = {
14
- scenarios: scenarios,
15
- failed_count: summary.failure_count,
16
- pending_count: summary.pending_count,
17
- total_time: summary.duration
18
- }
19
- output_html(print_params)
20
- end
21
-
22
- def example_passed(notification)
23
- scenario = ::TurnipFormatter::Scenario::Pass.new(notification.example)
24
- scenarios << scenario
25
- end
26
-
27
- def example_pending(notification)
28
- scenario = ::TurnipFormatter::Scenario::Pending.new(notification.example)
29
- scenarios << scenario
30
- end
31
-
32
- def example_failed(notification)
33
- scenario = ::TurnipFormatter::Scenario::Failure.new(notification.example)
34
- scenarios << scenario
35
- end
36
-
37
- module Helper
38
- def formatted_backtrace(example)
39
- formatter = RSpec.configuration.backtrace_formatter
40
- formatter.format_backtrace(example.exception.backtrace, example.metadata)
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,22 +0,0 @@
1
- module TurnipFormatter
2
- module Helper
3
- module HelperMethods
4
- #
5
- # @param [RSpec::Core::Example] example
6
- # @param [OpenStruct or ::RSpec::Core::Example::ExecutionResult]
7
- #
8
- def example_execution_result(example)
9
- case example.execution_result
10
- when Hash
11
- # RSpec 2
12
- OpenStruct.new(example.execution_result)
13
- when ::RSpec::Core::Example::ExecutionResult
14
- # RSpec 3
15
- example.execution_result
16
- end
17
- end
18
- end
19
-
20
- extend HelperMethods
21
- end
22
- end
@@ -1,4 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gemspec :path => '../..'
4
- gem 'rspec', '~> 2.14.0'
@@ -1,4 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gemspec :path => '../..'
4
- gem 'rspec', '~> 2.99.0'
@@ -1,4 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gemspec :path => '../..'
4
- gem 'rspec', '~> 3.0.0'
@@ -1,4 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gemspec :path => '../..'
4
- gem 'rspec', '~> 3.1.0'