Skip to content

Commit

Permalink
Merge pull request #91 from gongo/0.6.0
Browse files Browse the repository at this point in the history
Release 0.6.0
  • Loading branch information
gongo authored Apr 3, 2017
2 parents 648d27f + 0b84ed2 commit 489b77e
Show file tree
Hide file tree
Showing 115 changed files with 2,512 additions and 1,853 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
vendor/bundle
report.html
.sass-cache
1 change: 0 additions & 1 deletion .rspec

This file was deleted.

8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ cache: bundler
branches:
only:
- master
- 0.6.0

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

rvm:
- 2.1
- 2.2
- 2.3.0
- ruby-head
- jruby-9.0.0.0
- jruby-9.0.5.0

script: bundle exec rspec
script:
- bundle exec rake test

gemfile:
- gemfiles/Gemfile-rspec-3.2.x
- gemfiles/Gemfile-rspec-3.3.x
- gemfiles/Gemfile-rspec-3.4.x
9 changes: 0 additions & 9 deletions Guardfile

This file was deleted.

13 changes: 11 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
require 'bundler/gem_tasks'
require 'sass'
require 'bootstrap-sass'
require 'rake/testtask'

desc 'Compile report CSS file'
task :compile do
input = open('lib/turnip_formatter/template/turnip_formatter.scss').read
dir = 'lib/turnip_formatter/renderer/html/assets'
input = open("#{dir}/turnip_formatter.scss").read
engine = Sass::Engine.new(input, syntax: :scss, style: :compressed)

File.open('lib/turnip_formatter/template/turnip_formatter.css', 'w') do |f|
File.open("#{dir}/turnip_formatter.css", 'w') do |f|
f.write engine.render
end
end

Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/**/test*.rb']
t.verbose = true
t.warning = false
end
15 changes: 15 additions & 0 deletions example/spec/features/argument.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Feature: A feature with argument
Scenario: This is a feature with DocString
When the monster sings the following song
"""
Oh here be monsters
This is cool
"""
Then the song should have 2 lines

Scenario: This is a feature with DocTable
When there are monsters:
| gargoyle |
| Cockatrice |
Then there should be 2 monsters

Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ Feature: Battle a monster with weapon
And Fanfare

Scenario: strong monster

His attacks can defeat strong monster if has weapon.

Given there is a strong monster
When I attack it
Then it should die
And Fanfare

Scenario: boss monster

This scenario will error
So, fanfare is not...oh...
Scenario: [ERROR] boss monster

This scenario will not success.
Because his attacks can't defeat boss monster even if has weapon.

Given there is a boss monster
When I attack it
Expand Down
51 changes: 51 additions & 0 deletions example/spec/features/basic.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Feature: Battle a monster

Scenario: normal monster
Given there is a monster
When I attack it
Then it should die
And Fanfare

Scenario: [ERROR] strong monster

This scenario will not success because his attacks can't defeat strong monster

Given there is a strong monster
When I attack it
Then it should die
And Fanfare

@aggregate_failures
Scenario: [ERROR] boss monster (aggregate_failures)

Even if error occurs during steps, test will run to the end

Given there is a boss monster
When I attack it
Then it should die
When I attack it
Then it should die
When I attack it
Then it should die
And Fanfare

Scenario: [PENDING] spell magic

This scenario will not success because he can't cast spell

Given there is a strong monster
When I cast a spell 'fireball'
And I attack it
Then it should die
And Fanfare

@magician
Scenario: spell magic

`magician` can cast spell.

Given there is a strong monster
When I cast a spell 'fireball'
And I attack it
Then it should die
And Fanfare
36 changes: 0 additions & 36 deletions example/spec/features/battle.feature

This file was deleted.

File renamed without changes.
22 changes: 22 additions & 0 deletions example/spec/features/rspec_hooks.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Feature: Battle a monster with hooks

@before_hook_error
Scenario: [ERROR] Error in before hook
Given there is a monster
When I attack it
Then it should die
And Fanfare

@after_hook_error
Scenario: [ERROR] Error in after hook
Given there is a monster
When I attack it
Then it should die
And Fanfare

@after_hook_error
Scenario: [ERROR] Error in steps and after hook
Given there is a strong monster
When I attack it
Then it should die
And Fanfare
19 changes: 0 additions & 19 deletions example/spec/features/songs.feature

This file was deleted.

20 changes: 20 additions & 0 deletions example/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@

Dir.glob(File.dirname(__FILE__) + '/steps/**/*steps.rb') { |f| load f, true }

RSpec.configure do |config|
config.before(:example, before_hook_error: true) do
#
# Workaround for JRuby <= 9.1.7.0
#
# https://github.com/jruby/jruby/issues/4467
# https://github.com/rspec/rspec-core/pull/2381
#
begin
undefined_method # NameError
rescue => e
raise e
end
end

config.after(:example, after_hook_error: true) do
expect(true).to be false # RSpec Matcher Error
end
end

# TurnipFormatter.configure do |config|
# config.title = 'My Report'
# config.add_stylesheet File.dirname(__FILE__) + '/foo.css'
Expand Down
4 changes: 4 additions & 0 deletions example/spec/steps/steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
@monsters = monsters.map { |row| row[0] }
end

step "there should be :count monsters" do |count|
@monsters.length.should eq(count.to_i)
end

step "the monster sings the following song" do |song|
@song = song
end
Expand Down
4 changes: 0 additions & 4 deletions gemfiles/Gemfile-rspec-3.2.x

This file was deleted.

23 changes: 12 additions & 11 deletions lib/rspec/core/formatters/turnip_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-

require 'rspec'
require 'rspec/core/formatters/base_formatter'
require 'turnip_formatter/scenario/pass'
require 'turnip_formatter/scenario/failure'
require 'turnip_formatter/scenario/pending'
require 'turnip_formatter/printer/index'
require 'turnip_formatter/printer/scenario'
require 'turnip_formatter/renderer/html/index'
require 'turnip_formatter/resource/scenario/pass'
require 'turnip_formatter/resource/scenario/failure'
require 'turnip_formatter/resource/scenario/pending'

module RSpec
module Core
Expand All @@ -15,9 +15,10 @@ class TurnipFormatter < BaseFormatter

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

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

def initialize(output)
Expand All @@ -36,24 +37,24 @@ def dump_summary(summary)
end

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

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

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

private

def output_html(params)
output.puts ::TurnipFormatter::Printer::Index.print_out(params)
output.puts ::TurnipFormatter::Renderer::Html::Index.new(params).render
end
end
end
Expand Down
13 changes: 8 additions & 5 deletions lib/turnip_formatter.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'turnip_formatter/version'
require 'turnip'
require 'turnip_formatter/renderer/html'

module TurnipFormatter
class << self
Expand All @@ -21,15 +22,15 @@ def add_stylesheet(stylesheets)
stylesheets = [stylesheets] if stylesheets.is_a? String

stylesheets.each do |s|
TurnipFormatter::Template.add_stylesheet(s)
TurnipFormatter::Renderer::Html.add_stylesheet(s)
end
end

def add_javascript(scripts)
scripts = [scripts] if scripts.is_a? String

scripts.each do |s|
TurnipFormatter::Template.add_javascript(s)
TurnipFormatter::Renderer::Html.add_javascript(s)
end
end

Expand All @@ -43,15 +44,17 @@ def configuration
end

require 'rspec/core/formatters/turnip_formatter'
require 'turnip_formatter/template'
require 'turnip_formatter/step_template/exception'
require 'turnip_formatter/step_template/source'
require 'turnip_formatter/ext/turnip/rspec'
require 'turnip_formatter/printer/index'
end

RSpecTurnipFormatter = RSpec::Core::Formatters::TurnipFormatter

TurnipFormatter.configure do |config|
config.title = 'Turnip'
end

(File.dirname(__FILE__) + '/turnip_formatter/renderer/html/assets').tap do |dirname|
TurnipFormatter::Renderer::Html.add_stylesheet(dirname + '/turnip_formatter.css')
TurnipFormatter::Renderer::Html.add_javascript(dirname + '/turnip_formatter.js')
end
Loading

0 comments on commit 489b77e

Please sign in to comment.