Skip to content

Commit 489b77e

Browse files
authored
Merge pull request #91 from gongo/0.6.0
Release 0.6.0
2 parents 648d27f + 0b84ed2 commit 489b77e

File tree

115 files changed

+2512
-1853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2512
-1853
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ doc/
1111
lib/bundler/man
1212
pkg
1313
rdoc
14-
spec/reports
1514
test/tmp
1615
test/version_tmp
1716
tmp
1817
vendor/bundle
1918
report.html
19+
.sass-cache

.rspec

-1
This file was deleted.

.travis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@ cache: bundler
66
branches:
77
only:
88
- master
9+
- 0.6.0
910

1011
matrix:
1112
allow_failures:
12-
- gemfile: gemfiles/Gemfile-rspec-3.2.x
1313
- rvm: ruby-head
1414

1515
rvm:
1616
- 2.1
1717
- 2.2
1818
- 2.3.0
1919
- ruby-head
20-
- jruby-9.0.0.0
20+
- jruby-9.0.5.0
2121

22-
script: bundle exec rspec
22+
script:
23+
- bundle exec rake test
2324

2425
gemfile:
25-
- gemfiles/Gemfile-rspec-3.2.x
2626
- gemfiles/Gemfile-rspec-3.3.x
2727
- gemfiles/Gemfile-rspec-3.4.x

Guardfile

-9
This file was deleted.

Rakefile

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
require 'bundler/gem_tasks'
22
require 'sass'
33
require 'bootstrap-sass'
4+
require 'rake/testtask'
45

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

10-
File.open('lib/turnip_formatter/template/turnip_formatter.css', 'w') do |f|
12+
File.open("#{dir}/turnip_formatter.css", 'w') do |f|
1113
f.write engine.render
1214
end
1315
end
16+
17+
Rake::TestTask.new do |t|
18+
t.libs << "test"
19+
t.test_files = FileList['test/**/test*.rb']
20+
t.verbose = true
21+
t.warning = false
22+
end
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Feature: A feature with argument
2+
Scenario: This is a feature with DocString
3+
When the monster sings the following song
4+
"""
5+
Oh here be monsters
6+
This is cool
7+
"""
8+
Then the song should have 2 lines
9+
10+
Scenario: This is a feature with DocTable
11+
When there are monsters:
12+
| gargoyle |
13+
| Cockatrice |
14+
Then there should be 2 monsters
15+

example/spec/features/battle2.feature example/spec/features/background.feature

+7-4
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ Feature: Battle a monster with weapon
1010
And Fanfare
1111

1212
Scenario: strong monster
13+
14+
His attacks can defeat strong monster if has weapon.
15+
1316
Given there is a strong monster
1417
When I attack it
1518
Then it should die
1619
And Fanfare
17-
18-
Scenario: boss monster
1920

20-
This scenario will error
21-
So, fanfare is not...oh...
21+
Scenario: [ERROR] boss monster
22+
23+
This scenario will not success.
24+
Because his attacks can't defeat boss monster even if has weapon.
2225

2326
Given there is a boss monster
2427
When I attack it

example/spec/features/basic.feature

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Feature: Battle a monster
2+
3+
Scenario: normal monster
4+
Given there is a monster
5+
When I attack it
6+
Then it should die
7+
And Fanfare
8+
9+
Scenario: [ERROR] strong monster
10+
11+
This scenario will not success because his attacks can't defeat strong monster
12+
13+
Given there is a strong monster
14+
When I attack it
15+
Then it should die
16+
And Fanfare
17+
18+
@aggregate_failures
19+
Scenario: [ERROR] boss monster (aggregate_failures)
20+
21+
Even if error occurs during steps, test will run to the end
22+
23+
Given there is a boss monster
24+
When I attack it
25+
Then it should die
26+
When I attack it
27+
Then it should die
28+
When I attack it
29+
Then it should die
30+
And Fanfare
31+
32+
Scenario: [PENDING] spell magic
33+
34+
This scenario will not success because he can't cast spell
35+
36+
Given there is a strong monster
37+
When I cast a spell 'fireball'
38+
And I attack it
39+
Then it should die
40+
And Fanfare
41+
42+
@magician
43+
Scenario: spell magic
44+
45+
`magician` can cast spell.
46+
47+
Given there is a strong monster
48+
When I cast a spell 'fireball'
49+
And I attack it
50+
Then it should die
51+
And Fanfare

example/spec/features/battle.feature

-36
This file was deleted.
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Feature: Battle a monster with hooks
2+
3+
@before_hook_error
4+
Scenario: [ERROR] Error in before hook
5+
Given there is a monster
6+
When I attack it
7+
Then it should die
8+
And Fanfare
9+
10+
@after_hook_error
11+
Scenario: [ERROR] Error in after hook
12+
Given there is a monster
13+
When I attack it
14+
Then it should die
15+
And Fanfare
16+
17+
@after_hook_error
18+
Scenario: [ERROR] Error in steps and after hook
19+
Given there is a strong monster
20+
When I attack it
21+
Then it should die
22+
And Fanfare

example/spec/features/songs.feature

-19
This file was deleted.

example/spec/spec_helper.rb

+20
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@
66

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

9+
RSpec.configure do |config|
10+
config.before(:example, before_hook_error: true) do
11+
#
12+
# Workaround for JRuby <= 9.1.7.0
13+
#
14+
# https://github.com/jruby/jruby/issues/4467
15+
# https://github.com/rspec/rspec-core/pull/2381
16+
#
17+
begin
18+
undefined_method # NameError
19+
rescue => e
20+
raise e
21+
end
22+
end
23+
24+
config.after(:example, after_hook_error: true) do
25+
expect(true).to be false # RSpec Matcher Error
26+
end
27+
end
28+
929
# TurnipFormatter.configure do |config|
1030
# config.title = 'My Report'
1131
# config.add_stylesheet File.dirname(__FILE__) + '/foo.css'

example/spec/steps/steps.rb

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
@monsters = monsters.map { |row| row[0] }
3333
end
3434

35+
step "there should be :count monsters" do |count|
36+
@monsters.length.should eq(count.to_i)
37+
end
38+
3539
step "the monster sings the following song" do |song|
3640
@song = song
3741
end

gemfiles/Gemfile-rspec-3.2.x

-4
This file was deleted.

lib/rspec/core/formatters/turnip_formatter.rb

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# -*- coding: utf-8 -*-
22

3+
require 'rspec'
34
require 'rspec/core/formatters/base_formatter'
4-
require 'turnip_formatter/scenario/pass'
5-
require 'turnip_formatter/scenario/failure'
6-
require 'turnip_formatter/scenario/pending'
7-
require 'turnip_formatter/printer/index'
8-
require 'turnip_formatter/printer/scenario'
5+
require 'turnip_formatter/renderer/html/index'
6+
require 'turnip_formatter/resource/scenario/pass'
7+
require 'turnip_formatter/resource/scenario/failure'
8+
require 'turnip_formatter/resource/scenario/pending'
99

1010
module RSpec
1111
module Core
@@ -15,9 +15,10 @@ class TurnipFormatter < BaseFormatter
1515

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

18-
def self.formatted_backtrace(example)
18+
def self.formatted_backtrace(example, exception = nil)
19+
exception = example.exception if exception.nil?
1920
formatter = RSpec.configuration.backtrace_formatter
20-
formatter.format_backtrace(example.exception.backtrace, example.metadata)
21+
formatter.format_backtrace(exception.backtrace, example.metadata)
2122
end
2223

2324
def initialize(output)
@@ -36,24 +37,24 @@ def dump_summary(summary)
3637
end
3738

3839
def example_passed(notification)
39-
scenario = ::TurnipFormatter::Scenario::Pass.new(notification.example)
40+
scenario = ::TurnipFormatter::Resource::Scenario::Pass.new(notification.example)
4041
scenarios << scenario
4142
end
4243

4344
def example_pending(notification)
44-
scenario = ::TurnipFormatter::Scenario::Pending.new(notification.example)
45+
scenario = ::TurnipFormatter::Resource::Scenario::Pending.new(notification.example)
4546
scenarios << scenario
4647
end
4748

4849
def example_failed(notification)
49-
scenario = ::TurnipFormatter::Scenario::Failure.new(notification.example)
50+
scenario = ::TurnipFormatter::Resource::Scenario::Failure.new(notification.example)
5051
scenarios << scenario
5152
end
5253

5354
private
5455

5556
def output_html(params)
56-
output.puts ::TurnipFormatter::Printer::Index.print_out(params)
57+
output.puts ::TurnipFormatter::Renderer::Html::Index.new(params).render
5758
end
5859
end
5960
end

lib/turnip_formatter.rb

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'turnip_formatter/version'
22
require 'turnip'
3+
require 'turnip_formatter/renderer/html'
34

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

2324
stylesheets.each do |s|
24-
TurnipFormatter::Template.add_stylesheet(s)
25+
TurnipFormatter::Renderer::Html.add_stylesheet(s)
2526
end
2627
end
2728

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

3132
scripts.each do |s|
32-
TurnipFormatter::Template.add_javascript(s)
33+
TurnipFormatter::Renderer::Html.add_javascript(s)
3334
end
3435
end
3536

@@ -43,15 +44,17 @@ def configuration
4344
end
4445

4546
require 'rspec/core/formatters/turnip_formatter'
46-
require 'turnip_formatter/template'
4747
require 'turnip_formatter/step_template/exception'
48-
require 'turnip_formatter/step_template/source'
4948
require 'turnip_formatter/ext/turnip/rspec'
50-
require 'turnip_formatter/printer/index'
5149
end
5250

5351
RSpecTurnipFormatter = RSpec::Core::Formatters::TurnipFormatter
5452

5553
TurnipFormatter.configure do |config|
5654
config.title = 'Turnip'
5755
end
56+
57+
(File.dirname(__FILE__) + '/turnip_formatter/renderer/html/assets').tap do |dirname|
58+
TurnipFormatter::Renderer::Html.add_stylesheet(dirname + '/turnip_formatter.css')
59+
TurnipFormatter::Renderer::Html.add_javascript(dirname + '/turnip_formatter.js')
60+
end

0 commit comments

Comments
 (0)