turnip_formatter 0.6.0.pre.beta.1 → 0.6.0.pre.beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +4 -1
- data/Rakefile +8 -0
- data/lib/rspec/core/formatters/turnip_formatter.rb +1 -0
- data/lib/turnip_formatter/ext/turnip/rspec.rb +6 -6
- data/lib/turnip_formatter/printer/runtime_error.rb +0 -1
- data/lib/turnip_formatter/printer/scenario.rb +1 -1
- data/lib/turnip_formatter/renderer/html/base.rb +47 -0
- data/lib/turnip_formatter/renderer/html/data_table.rb +16 -0
- data/lib/turnip_formatter/renderer/html/doc_string.rb +16 -0
- data/lib/turnip_formatter/renderer/html/step.rb +47 -0
- data/lib/turnip_formatter/renderer/html/views/data_table.html.erb +9 -0
- data/lib/turnip_formatter/renderer/html/views/doc_string.html.erb +1 -0
- data/lib/turnip_formatter/renderer/html/views/step.html.erb +10 -0
- data/lib/turnip_formatter/resource/step.rb +23 -0
- data/lib/turnip_formatter/scenario/base.rb +2 -2
- data/lib/turnip_formatter/template/scenario.slim +1 -1
- data/lib/turnip_formatter/template/turnip_formatter.css +5 -1
- data/lib/turnip_formatter/template/turnip_formatter.scss +2 -2
- data/lib/turnip_formatter/version.rb +1 -1
- data/spec/support/step_helper.rb +1 -1
- data/spec/turnip_formatter/scenario/base_spec.rb +1 -1
- data/test/helper.rb +31 -0
- data/test/sample.feature +16 -0
- data/test/turnip_formatter/renderer/html/test_data_table.rb +30 -0
- data/test/turnip_formatter/renderer/html/test_doc_string.rb +17 -0
- data/test/turnip_formatter/renderer/html/test_step.rb +38 -0
- data/turnip_formatter.gemspec +8 -1
- metadata +73 -13
- data/lib/turnip_formatter/printer/step.rb +0 -35
- data/lib/turnip_formatter/printer/step_extra_args.rb +0 -24
- data/lib/turnip_formatter/template/step.slim +0 -6
- data/lib/turnip_formatter/template/step_multiline.slim +0 -1
- data/lib/turnip_formatter/template/step_outline.slim +0 -6
- data/spec/turnip_formatter/printer/step_extra_args_spec.rb +0 -32
- data/spec/turnip_formatter/printer/step_spec.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 048fca2032893aaaa891ca94b828d4902e76f240
|
4
|
+
data.tar.gz: 246f710e24aa823ee0c8072099e69c8a93e2fbcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da405c93158af4c53894a66d86edf97fc4bb6e78842d38724153b858e1dba9362af4982d2876daa8ddec290abe5ae2fe3c708500dcf593102838824e87c5dcb0
|
7
|
+
data.tar.gz: c1a0a785ee94f842f6eb5029ec88c3884e03c2a347c741c304564619ab3a8c521cf3c396c7340af555c90e6732e17c424ca4eeba5c705b1abcfd6399b79425cb
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -6,6 +6,7 @@ cache: bundler
|
|
6
6
|
branches:
|
7
7
|
only:
|
8
8
|
- master
|
9
|
+
- 0.6.0
|
9
10
|
|
10
11
|
matrix:
|
11
12
|
allow_failures:
|
@@ -19,7 +20,9 @@ rvm:
|
|
19
20
|
- ruby-head
|
20
21
|
- jruby-9.0.0.0
|
21
22
|
|
22
|
-
script:
|
23
|
+
script:
|
24
|
+
- bundle exec rspec
|
25
|
+
- bundle exec rake test
|
23
26
|
|
24
27
|
gemfile:
|
25
28
|
- gemfiles/Gemfile-rspec-3.2.x
|
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'sass'
|
3
3
|
require 'bootstrap-sass'
|
4
|
+
require 'rake/testtask'
|
4
5
|
|
5
6
|
desc 'Compile report CSS file'
|
6
7
|
task :compile do
|
@@ -11,3 +12,10 @@ task :compile do
|
|
11
12
|
f.write engine.render
|
12
13
|
end
|
13
14
|
end
|
15
|
+
|
16
|
+
Rake::TestTask.new do |t|
|
17
|
+
t.libs << "test"
|
18
|
+
t.test_files = FileList['test/**/test*.rb']
|
19
|
+
t.verbose = true
|
20
|
+
t.warning = false
|
21
|
+
end
|
@@ -8,16 +8,16 @@ module Turnip
|
|
8
8
|
alias_method :original_run, :run
|
9
9
|
|
10
10
|
def run(feature_file)
|
11
|
-
|
12
|
-
example_groups = ::RSpec.world.example_groups[-features.length..-1]
|
11
|
+
original_run(feature_file)
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
feature = Turnip::Builder.build(feature_file)
|
14
|
+
example_group = ::RSpec.world.example_groups.last
|
15
|
+
|
16
|
+
update_metadata(feature, example_group)
|
17
17
|
end
|
18
18
|
|
19
19
|
#
|
20
|
-
# @param [Turnip::
|
20
|
+
# @param [Turnip::Node::Feature] feature
|
21
21
|
# @param [RSpec::Core::ExampleGroup] example_group
|
22
22
|
#
|
23
23
|
def update_metadata(feature, example_group)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'active_support/core_ext/string/inflections' # String#{demodulize,underscore}
|
2
|
+
require 'tilt/erb'
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
module TurnipFormatter
|
6
|
+
module Renderer
|
7
|
+
module Html
|
8
|
+
class Base
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
TEMPLATE_DIRECTORY = File.dirname(__FILE__) + '/views'
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def view
|
15
|
+
@view ||= ::Tilt::ERBTemplate.new(
|
16
|
+
"#{TEMPLATE_DIRECTORY}/#{resource_name}.html.erb"
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def resource_name
|
21
|
+
@resource_name ||= self.to_s.demodulize.underscore
|
22
|
+
end
|
23
|
+
|
24
|
+
def delegate(*props)
|
25
|
+
def_delegators :@resource, *props
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def initialize(resource)
|
30
|
+
@resource = resource
|
31
|
+
end
|
32
|
+
|
33
|
+
def id
|
34
|
+
@id ||= self.class.resource_name + '_' + @resource.object_id.to_s
|
35
|
+
end
|
36
|
+
|
37
|
+
def view
|
38
|
+
self.class.view
|
39
|
+
end
|
40
|
+
|
41
|
+
def render
|
42
|
+
view.render(self)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'turnip_formatter'
|
2
|
+
require 'turnip_formatter/renderer/html/base'
|
3
|
+
require 'turnip_formatter/renderer/html/doc_string'
|
4
|
+
require 'turnip_formatter/renderer/html/data_table'
|
5
|
+
require 'turnip/table'
|
6
|
+
|
7
|
+
module TurnipFormatter
|
8
|
+
module Renderer
|
9
|
+
module Html
|
10
|
+
#
|
11
|
+
# @resource [TurnipFormatter::Resource::Step]
|
12
|
+
#
|
13
|
+
class Step < Base
|
14
|
+
delegate :text, :status
|
15
|
+
|
16
|
+
def keyword
|
17
|
+
@resource.keyword.strip
|
18
|
+
end
|
19
|
+
|
20
|
+
def argument
|
21
|
+
@argument ||= case @resource.argument
|
22
|
+
when ::Turnip::Table
|
23
|
+
DataTable.new(@resource.argument).render
|
24
|
+
when String
|
25
|
+
DocString.new(@resource.argument).render
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def extra_information
|
30
|
+
extra_information_templates.map do |template, method|
|
31
|
+
template.send(method, @resource.example)
|
32
|
+
end.join("\n")
|
33
|
+
end
|
34
|
+
|
35
|
+
def has_appendix?
|
36
|
+
!!argument or !extra_information_templates.empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def extra_information_templates
|
42
|
+
@extra_information_templates ||= TurnipFormatter.step_templates_for(status)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<pre class="step_doc_string"><%= ERB::Util.h(content) %></pre>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module TurnipFormatter
|
4
|
+
module Resource
|
5
|
+
class Step
|
6
|
+
extend Forwardable
|
7
|
+
def_delegators :@raw, :keyword, :text, :line, :argument
|
8
|
+
|
9
|
+
attr_reader :example
|
10
|
+
attr_accessor :status
|
11
|
+
|
12
|
+
#
|
13
|
+
# @param [RSpec::Core::Example] example
|
14
|
+
# @param [Turnip::Node::Step] raw
|
15
|
+
#
|
16
|
+
def initialize(example, raw)
|
17
|
+
@example = example
|
18
|
+
@raw = raw
|
19
|
+
@status = :passed
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'turnip_formatter/step'
|
1
|
+
require 'turnip_formatter/resource/step'
|
2
2
|
|
3
3
|
module TurnipFormatter
|
4
4
|
module Scenario
|
@@ -21,7 +21,7 @@ module TurnipFormatter
|
|
21
21
|
|
22
22
|
def steps
|
23
23
|
@steps ||= raw_steps.map do |step|
|
24
|
-
TurnipFormatter::Step.new(example, step)
|
24
|
+
TurnipFormatter::Resource::Step.new(example, step)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|