turnip_formatter 0.6.0.pre.beta.1 → 0.6.0.pre.beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +4 -1
  4. data/Rakefile +8 -0
  5. data/lib/rspec/core/formatters/turnip_formatter.rb +1 -0
  6. data/lib/turnip_formatter/ext/turnip/rspec.rb +6 -6
  7. data/lib/turnip_formatter/printer/runtime_error.rb +0 -1
  8. data/lib/turnip_formatter/printer/scenario.rb +1 -1
  9. data/lib/turnip_formatter/renderer/html/base.rb +47 -0
  10. data/lib/turnip_formatter/renderer/html/data_table.rb +16 -0
  11. data/lib/turnip_formatter/renderer/html/doc_string.rb +16 -0
  12. data/lib/turnip_formatter/renderer/html/step.rb +47 -0
  13. data/lib/turnip_formatter/renderer/html/views/data_table.html.erb +9 -0
  14. data/lib/turnip_formatter/renderer/html/views/doc_string.html.erb +1 -0
  15. data/lib/turnip_formatter/renderer/html/views/step.html.erb +10 -0
  16. data/lib/turnip_formatter/resource/step.rb +23 -0
  17. data/lib/turnip_formatter/scenario/base.rb +2 -2
  18. data/lib/turnip_formatter/template/scenario.slim +1 -1
  19. data/lib/turnip_formatter/template/turnip_formatter.css +5 -1
  20. data/lib/turnip_formatter/template/turnip_formatter.scss +2 -2
  21. data/lib/turnip_formatter/version.rb +1 -1
  22. data/spec/support/step_helper.rb +1 -1
  23. data/spec/turnip_formatter/scenario/base_spec.rb +1 -1
  24. data/test/helper.rb +31 -0
  25. data/test/sample.feature +16 -0
  26. data/test/turnip_formatter/renderer/html/test_data_table.rb +30 -0
  27. data/test/turnip_formatter/renderer/html/test_doc_string.rb +17 -0
  28. data/test/turnip_formatter/renderer/html/test_step.rb +38 -0
  29. data/turnip_formatter.gemspec +8 -1
  30. metadata +73 -13
  31. data/lib/turnip_formatter/printer/step.rb +0 -35
  32. data/lib/turnip_formatter/printer/step_extra_args.rb +0 -24
  33. data/lib/turnip_formatter/template/step.slim +0 -6
  34. data/lib/turnip_formatter/template/step_multiline.slim +0 -1
  35. data/lib/turnip_formatter/template/step_outline.slim +0 -6
  36. data/spec/turnip_formatter/printer/step_extra_args_spec.rb +0 -32
  37. 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: 195374f593f8a0a948c425c5b30846125ce713c2
4
- data.tar.gz: 5062b23635c5b9bcbda2a3c58997b3cee708836e
3
+ metadata.gz: 048fca2032893aaaa891ca94b828d4902e76f240
4
+ data.tar.gz: 246f710e24aa823ee0c8072099e69c8a93e2fbcd
5
5
  SHA512:
6
- metadata.gz: 497aa307340cf60835a20d682fb8fb9d165b4de27292ea7620422397e56d0be6ebe55e8bef2a7b5a88340802a272994b8c62961d820b47c1bfb35fc48bfeae62
7
- data.tar.gz: dcf3718d91084ab6d4115208426c8036ed357c78c6bae0f73606ee7bfa719069f4f9d3aaddbe9fbb3b3cfbfd515aeacb425cb2ef752f0e338fb758a31064975e
6
+ metadata.gz: da405c93158af4c53894a66d86edf97fc4bb6e78842d38724153b858e1dba9362af4982d2876daa8ddec290abe5ae2fe3c708500dcf593102838824e87c5dcb0
7
+ data.tar.gz: c1a0a785ee94f842f6eb5029ec88c3884e03c2a347c741c304564619ab3a8c521cf3c396c7340af555c90e6732e17c424ca4eeba5c705b1abcfd6399b79425cb
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ test/version_tmp
17
17
  tmp
18
18
  vendor/bundle
19
19
  report.html
20
+ .sass-cache
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: bundle exec rspec
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
@@ -1,5 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ require 'rspec'
3
4
  require 'rspec/core/formatters/base_formatter'
4
5
  require 'turnip_formatter/scenario/pass'
5
6
  require 'turnip_formatter/scenario/failure'
@@ -8,16 +8,16 @@ module Turnip
8
8
  alias_method :original_run, :run
9
9
 
10
10
  def run(feature_file)
11
- features = original_run(feature_file)
12
- example_groups = ::RSpec.world.example_groups[-features.length..-1]
11
+ original_run(feature_file)
13
12
 
14
- features.zip(example_groups).each do |feature, example_group|
15
- update_metadata(feature, example_group)
16
- end
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::Builder::Feature] feature
20
+ # @param [Turnip::Node::Feature] feature
21
21
  # @param [RSpec::Core::ExampleGroup] example_group
22
22
  #
23
23
  def update_metadata(feature, example_group)
@@ -1,5 +1,4 @@
1
1
  require 'turnip_formatter/printer'
2
- require 'turnip_formatter/printer/step_extra_args'
3
2
 
4
3
  module TurnipFormatter
5
4
  module Printer
@@ -1,6 +1,6 @@
1
1
  require 'turnip_formatter/printer'
2
- require 'turnip_formatter/printer/step'
3
2
  require 'turnip_formatter/printer/runtime_error'
3
+ require 'turnip_formatter/renderer/html/step'
4
4
 
5
5
  module TurnipFormatter
6
6
  module Printer
@@ -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,16 @@
1
+ require 'turnip_formatter/renderer/html/base'
2
+
3
+ module TurnipFormatter
4
+ module Renderer
5
+ module Html
6
+ #
7
+ # @resource [Turnip::Table]
8
+ #
9
+ class DataTable < Base
10
+ def table
11
+ @resource
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'turnip_formatter/renderer/html/base'
2
+
3
+ module TurnipFormatter
4
+ module Renderer
5
+ module Html
6
+ #
7
+ # @resource [String]
8
+ #
9
+ class DocString < Base
10
+ def content
11
+ @resource
12
+ end
13
+ end
14
+ end
15
+ end
16
+ 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,9 @@
1
+ <table id="<%= id %>" class="step_data_table">
2
+ <% table.each do |row| %>
3
+ <tr>
4
+ <% row.each do |td| %>
5
+ <td><%= ERB::Util.h(td) %></td>
6
+ <% end %>
7
+ </tr>
8
+ <% end %>
9
+ </table>
@@ -0,0 +1 @@
1
+ <pre class="step_doc_string"><%= ERB::Util.h(content) %></pre>
@@ -0,0 +1,10 @@
1
+ <div id="<%= id %>" class="step <%= status %>">
2
+ <div class="step-title"><%= keyword %> <%= text %></div>
3
+
4
+ <% if has_appendix? %>
5
+ <div class="step-body">
6
+ <%= argument %>
7
+ <%= extra_information %>
8
+ </div>
9
+ <% end %>
10
+ </div>
@@ -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
 
@@ -12,4 +12,4 @@ section class="scenario #{scenario.status}" id=scenario.id
12
12
  li = "@#{tag}"
13
13
  div.steps
14
14
  - scenario.steps.each do |step|
15
- == TurnipFormatter::Printer::Step.print_out(step)
15
+ == TurnipFormatter::Renderer::Html::Step.new(step).render