turnip_formatter 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/.gitignore +1 -1
  2. data/{spec/examples → example}/README.md +8 -8
  3. data/{spec/examples → example}/features/battle.feature +0 -0
  4. data/{spec/examples → example}/features/battle2.feature +0 -0
  5. data/{spec/examples → example}/features/battle3.feature +0 -0
  6. data/{spec/examples → example}/features/songs.feature +0 -0
  7. data/{spec/examples → example}/images/background.png +0 -0
  8. data/{spec/examples → example}/images/basic_step.png +0 -0
  9. data/{spec/examples → example}/images/failed_step.png +0 -0
  10. data/{spec/examples → example}/images/multiline.png +0 -0
  11. data/{spec/examples → example}/images/outline.png +0 -0
  12. data/{spec/examples → example}/images/pending_step.png +0 -0
  13. data/{spec/examples → example}/images/tag_step.png +0 -0
  14. data/{spec/examples → example}/spec_helper.rb +0 -0
  15. data/{spec/examples → example}/steps/spell_steps.rb +0 -0
  16. data/{spec/examples → example}/steps/steps.rb +0 -0
  17. data/lib/turnip_formatter/formatter.css +0 -21
  18. data/lib/turnip_formatter/formatter.scss +0 -32
  19. data/lib/turnip_formatter/scenario.rb +5 -0
  20. data/lib/turnip_formatter/step/dsl.rb +5 -5
  21. data/lib/turnip_formatter/step/failure.rb +0 -8
  22. data/lib/turnip_formatter/step/pending.rb +0 -7
  23. data/lib/turnip_formatter/step.rb +4 -4
  24. data/lib/turnip_formatter/step_template/exception.rb +61 -0
  25. data/lib/turnip_formatter/step_template/source.rb +46 -0
  26. data/lib/turnip_formatter/step_template.rb +8 -0
  27. data/lib/turnip_formatter/template/exception.erb +26 -0
  28. data/lib/turnip_formatter/template/exception_backtrace.erb +7 -0
  29. data/lib/turnip_formatter/template/scenario.erb +24 -0
  30. data/lib/turnip_formatter/template/scenario_tags.erb +5 -0
  31. data/lib/turnip_formatter/template/section_report.erb +15 -0
  32. data/lib/turnip_formatter/template/step_multiline.erb +1 -0
  33. data/lib/turnip_formatter/template/step_outline.erb +9 -0
  34. data/lib/turnip_formatter/template.rb +88 -125
  35. data/lib/turnip_formatter/version.rb +1 -1
  36. data/lib/turnip_formatter.rb +1 -0
  37. data/spec/turnip_formatter/step/failure_spec.rb +19 -4
  38. data/spec/turnip_formatter/step/pending_spec.rb +18 -4
  39. data/spec/turnip_formatter/step_spec.rb +37 -24
  40. data/spec/turnip_formatter/{template/step_exception_spec.rb → step_template/exception_spec.rb} +4 -4
  41. data/spec/turnip_formatter/{template/step_source_spec.rb → step_template/source_spec.rb} +5 -5
  42. data/spec/turnip_formatter/template_spec.rb +60 -40
  43. data/turnip_formatter.gemspec +2 -1
  44. metadata +47 -44
  45. data/lib/turnip_formatter/template/step_exception.rb +0 -30
  46. data/lib/turnip_formatter/template/step_multiline.rb +0 -13
  47. data/lib/turnip_formatter/template/step_outline.rb +0 -29
  48. data/lib/turnip_formatter/template/step_source.rb +0 -15
  49. data/spec/turnip_formatter/template/step_multiline_spec.rb +0 -18
  50. data/spec/turnip_formatter/template/step_outline_spec.rb +0 -31
@@ -3,34 +3,33 @@ require 'spec_helper'
3
3
  module TurnipFormatter
4
4
  describe Template do
5
5
  let(:template) { ::TurnipFormatter::Template.new }
6
+ let(:exception_style) { ::TurnipFormatter::StepTemplate::Exception }
7
+ let(:source_style) { ::TurnipFormatter::StepTemplate::Source }
6
8
 
7
- context 'Step has no tag' do
8
- describe '#scenario_tags' do
9
+ describe '#print_scenario_tags' do
10
+ subject { template.print_scenario_tags(scenario) }
11
+
12
+ context 'Step has no tag' do
9
13
  let(:scenario) do
10
14
  scenario = double('scenario')
11
15
  scenario.stub(:tags).and_return([])
12
16
  scenario
13
17
  end
14
-
15
- it 'should get null string' do
16
- expect(template.send(:scenario_tags, scenario)).to be_empty
17
- end
18
+
19
+ it { should eq '' }
18
20
  end
19
- end
20
21
 
21
- context 'Step has tags' do
22
- describe '#scenario_tags' do
22
+ context 'Step has tags' do
23
23
  let(:scenario) do
24
24
  scenario = double('scenario')
25
- scenario.stub(:tags).and_return(['hoge', 'fuga'])
25
+ scenario.stub(:tags).and_return(['hoge', '<b>fuga</b>'])
26
26
  scenario
27
27
  end
28
-
29
- it 'should get null string' do
30
- html = template.send(:scenario_tags, scenario)
31
- expect(html).to match %r{ul class="tags"}
32
- expect(html).to match %r{<li>@hoge</li>[[:space:]]+<li>@fuga</li>}
33
- end
28
+
29
+ it {
30
+ should match %r{ul class="tags"}
31
+ should match %r{<li>@hoge</li>[[:space:]]+<li>@&lt;b&gt;fuga&lt;/b&gt;</li>}
32
+ }
34
33
  end
35
34
  end
36
35
 
@@ -54,28 +53,28 @@ module TurnipFormatter
54
53
  expect(template.send(:step_attr, failed_step)).to eq('class="step failed"')
55
54
  end
56
55
  end
57
-
56
+
58
57
  context 'Step has arguments' do
59
58
  let(:table) { Turnip::Table.new [] }
60
59
 
61
60
  context 'original template' do
62
61
  describe '#step_args' do
63
62
  let(:step) do
63
+ docs = {}
64
+ docs[:extra_args] = { klass: nil, value: ['a', table] }
65
+ docs[source_style] = { klass: source_style, value: 'b' }
66
+ docs[exception_style] = { klass: exception_style, value: 'c' }
67
+
64
68
  step = double
65
- step.stub(:docs).and_return(
66
- extra_args: { klass: nil, value: ['a', table] },
67
- source: { klass: nil, value: 'b' },
68
- exception: { klass: nil, value: 'c' }
69
- )
69
+ step.stub(:docs).and_return(docs)
70
70
  step
71
71
  end
72
-
73
- it 'should call corresponding method in step' do
74
- Template::StepMultiline.should_receive(:build).with('a').and_return('extra_args1')
75
- Template::StepOutline.should_receive(:build).with(table).and_return('extra_args2')
76
- Template::StepSource.should_receive(:build).with('b').and_return('source')
77
- Template::StepException.should_receive(:build).with('c').and_return('exception')
78
72
 
73
+ it 'should call corresponding method in step' do
74
+ template.should_receive(:print_step_multiline).with('a').and_return('extra_args1')
75
+ template.should_receive(:print_step_outline).with(table).and_return('extra_args2')
76
+ source_style.should_receive(:build).with('b').and_return('source')
77
+ exception_style.should_receive(:build).with('c').and_return('exception')
79
78
  expect(template.send(:step_args, step)).to eq("extra_args1\nextra_args2\nsource\nexception")
80
79
  end
81
80
  end
@@ -107,7 +106,7 @@ module TurnipFormatter
107
106
  )
108
107
  step
109
108
  end
110
-
109
+
111
110
  it 'should call corresponding method in step' do
112
111
  expect(template.send(:step_args, step)).to eq("<html>aiueo</html>\n<strong>12345</strong>")
113
112
  end
@@ -124,21 +123,20 @@ module TurnipFormatter
124
123
  end
125
124
 
126
125
  it 'should get null string' do
127
- Template::StepOutline.should_not_receive(:build)
128
- Template::StepMultiline.should_not_receive(:build)
129
- Template::StepSource.should_not_receive(:build)
130
- Template::StepException.should_not_receive(:build)
131
-
126
+ template.should_not_receive(:print_step_multiline)
127
+ template.should_not_receive(:print_step_outline)
128
+ source_style.should_not_receive(:build)
129
+ exception_style.should_not_receive(:build)
132
130
  expect(template.send(:step_args, step)).to be_empty
133
131
  end
134
132
  end
135
133
  end
136
134
 
137
- describe '#step_extra_args' do
135
+ describe '#print_step_extra_args' do
138
136
  let(:template_stub) do
139
137
  template.tap do |t|
140
- template.stub(:step_outline).and_return('outline')
141
- template.stub(:step_multiline).and_return('multiline')
138
+ template.stub(:print_step_outline).and_return('outline')
139
+ template.stub(:print_step_multiline).and_return('multiline')
142
140
  end
143
141
  end
144
142
 
@@ -147,13 +145,35 @@ module TurnipFormatter
147
145
  end
148
146
 
149
147
  before do
150
- Template::StepOutline.should_receive(:build).and_return('outline')
151
- Template::StepMultiline.should_receive(:build).and_return('multiline')
148
+ template.should_receive(:print_step_outline).and_return('outline')
149
+ template.should_receive(:print_step_multiline).and_return('multiline')
152
150
  end
153
151
 
154
152
  it 'should get string converted from extra_args' do
155
- expect(template_stub.send(:step_extra_args, extra_args)).to eq("outline\nmultiline")
153
+ expect(template_stub.send(:print_step_extra_args, extra_args)).to eq("outline\nmultiline")
156
154
  end
157
155
  end
156
+
157
+ describe '#print_step_multiline' do
158
+ let(:string) { 'a<a>a' }
159
+ subject { template.print_step_multiline(string) }
160
+ it { should include '<pre class="multiline">a&lt;a&gt;a</pre>' }
161
+ end
162
+
163
+ describe '#print_step_outline' do
164
+ let(:string) do
165
+ ::Turnip::Table.new([
166
+ ["State", "Money"],
167
+ ["<Tokushima>", "555"],
168
+ ["<Okinawa>", "368"]
169
+ ])
170
+ end
171
+
172
+ subject { template.print_step_outline(string) }
173
+
174
+ it { should match %r{<td>State</td>[[:space:]]+<td>Money</td>} }
175
+ it { should match %r{<td>&lt;Tokushima&gt;</td>[[:space:]]+<td>555</td>} }
176
+ it { should match %r{<td>&lt;Okinawa&gt;</td>[[:space:]]+<td>368</td>} }
177
+ end
158
178
  end
159
179
  end
@@ -15,10 +15,11 @@ Gem::Specification.new do |spec|
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.test_files = spec.files.grep(%r{^spec/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency 'turnip'
22
+ spec.add_dependency 'sass'
22
23
  spec.add_development_dependency "bundler", "~> 1.3"
23
24
  spec.add_development_dependency "rake"
24
25
  spec.add_development_dependency 'coveralls'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turnip_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-23 00:00:00.000000000 Z
12
+ date: 2013-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: turnip
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: sass
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: bundler
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -106,6 +122,21 @@ files:
106
122
  - LICENSE.txt
107
123
  - README.md
108
124
  - Rakefile
125
+ - example/README.md
126
+ - example/features/battle.feature
127
+ - example/features/battle2.feature
128
+ - example/features/battle3.feature
129
+ - example/features/songs.feature
130
+ - example/images/background.png
131
+ - example/images/basic_step.png
132
+ - example/images/failed_step.png
133
+ - example/images/multiline.png
134
+ - example/images/outline.png
135
+ - example/images/pending_step.png
136
+ - example/images/tag_step.png
137
+ - example/spec_helper.rb
138
+ - example/steps/spell_steps.rb
139
+ - example/steps/steps.rb
109
140
  - images/tab_feature_statistics.png
110
141
  - images/tab_speed_statistics.png
111
142
  - images/tab_steps.png
@@ -125,30 +156,21 @@ files:
125
156
  - lib/turnip_formatter/step/dsl.rb
126
157
  - lib/turnip_formatter/step/failure.rb
127
158
  - lib/turnip_formatter/step/pending.rb
159
+ - lib/turnip_formatter/step_template.rb
160
+ - lib/turnip_formatter/step_template/exception.rb
161
+ - lib/turnip_formatter/step_template/source.rb
128
162
  - lib/turnip_formatter/template.rb
129
- - lib/turnip_formatter/template/step_exception.rb
130
- - lib/turnip_formatter/template/step_multiline.rb
131
- - lib/turnip_formatter/template/step_outline.rb
132
- - lib/turnip_formatter/template/step_source.rb
163
+ - lib/turnip_formatter/template/exception.erb
164
+ - lib/turnip_formatter/template/exception_backtrace.erb
165
+ - lib/turnip_formatter/template/scenario.erb
166
+ - lib/turnip_formatter/template/scenario_tags.erb
167
+ - lib/turnip_formatter/template/section_report.erb
168
+ - lib/turnip_formatter/template/step_multiline.erb
169
+ - lib/turnip_formatter/template/step_outline.erb
133
170
  - lib/turnip_formatter/template/tab/feature_statistics.rb
134
171
  - lib/turnip_formatter/template/tab/speed_statistics.rb
135
172
  - lib/turnip_formatter/template/tab/tag_statistics.rb
136
173
  - lib/turnip_formatter/version.rb
137
- - spec/examples/README.md
138
- - spec/examples/features/battle.feature
139
- - spec/examples/features/battle2.feature
140
- - spec/examples/features/battle3.feature
141
- - spec/examples/features/songs.feature
142
- - spec/examples/images/background.png
143
- - spec/examples/images/basic_step.png
144
- - spec/examples/images/failed_step.png
145
- - spec/examples/images/multiline.png
146
- - spec/examples/images/outline.png
147
- - spec/examples/images/pending_step.png
148
- - spec/examples/images/tag_step.png
149
- - spec/examples/spec_helper.rb
150
- - spec/examples/steps/spell_steps.rb
151
- - spec/examples/steps/steps.rb
152
174
  - spec/rspec/core/formatters/turnip_formatter_spec.rb
153
175
  - spec/spec_helper.rb
154
176
  - spec/support/passed.feature
@@ -159,10 +181,8 @@ files:
159
181
  - spec/turnip_formatter/step/failure_spec.rb
160
182
  - spec/turnip_formatter/step/pending_spec.rb
161
183
  - spec/turnip_formatter/step_spec.rb
162
- - spec/turnip_formatter/template/step_exception_spec.rb
163
- - spec/turnip_formatter/template/step_multiline_spec.rb
164
- - spec/turnip_formatter/template/step_outline_spec.rb
165
- - spec/turnip_formatter/template/step_source_spec.rb
184
+ - spec/turnip_formatter/step_template/exception_spec.rb
185
+ - spec/turnip_formatter/step_template/source_spec.rb
166
186
  - spec/turnip_formatter/template/tab/feature_statistics_spec.rb
167
187
  - spec/turnip_formatter/template/tab/speed_statistics_spec.rb
168
188
  - spec/turnip_formatter/template/tab/tag_statistics_spec.rb
@@ -194,21 +214,6 @@ signing_key:
194
214
  specification_version: 3
195
215
  summary: RSpec custom formatter for Turnip
196
216
  test_files:
197
- - spec/examples/README.md
198
- - spec/examples/features/battle.feature
199
- - spec/examples/features/battle2.feature
200
- - spec/examples/features/battle3.feature
201
- - spec/examples/features/songs.feature
202
- - spec/examples/images/background.png
203
- - spec/examples/images/basic_step.png
204
- - spec/examples/images/failed_step.png
205
- - spec/examples/images/multiline.png
206
- - spec/examples/images/outline.png
207
- - spec/examples/images/pending_step.png
208
- - spec/examples/images/tag_step.png
209
- - spec/examples/spec_helper.rb
210
- - spec/examples/steps/spell_steps.rb
211
- - spec/examples/steps/steps.rb
212
217
  - spec/rspec/core/formatters/turnip_formatter_spec.rb
213
218
  - spec/spec_helper.rb
214
219
  - spec/support/passed.feature
@@ -219,10 +224,8 @@ test_files:
219
224
  - spec/turnip_formatter/step/failure_spec.rb
220
225
  - spec/turnip_formatter/step/pending_spec.rb
221
226
  - spec/turnip_formatter/step_spec.rb
222
- - spec/turnip_formatter/template/step_exception_spec.rb
223
- - spec/turnip_formatter/template/step_multiline_spec.rb
224
- - spec/turnip_formatter/template/step_outline_spec.rb
225
- - spec/turnip_formatter/template/step_source_spec.rb
227
+ - spec/turnip_formatter/step_template/exception_spec.rb
228
+ - spec/turnip_formatter/step_template/source_spec.rb
226
229
  - spec/turnip_formatter/template/tab/feature_statistics_spec.rb
227
230
  - spec/turnip_formatter/template/tab/speed_statistics_spec.rb
228
231
  - spec/turnip_formatter/template/tab/tag_statistics_spec.rb
@@ -1,30 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'erb'
4
-
5
- module TurnipFormatter
6
- class Template
7
- module StepException
8
- def self.build(exception)
9
- template_step_exception.result(binding)
10
- end
11
-
12
- private
13
-
14
- def self.template_step_exception
15
- @template_step_exception ||= ERB.new(<<-EOS)
16
- <div class="step_exception">
17
- <span>Failure:</span>
18
- <pre><%= ERB::Util.h(exception.to_s) %></pre>
19
- <span>Backtrace:</span>
20
- <ol>
21
- <% exception.backtrace.each do |line| %>
22
- <li><%= ERB::Util.h(line) %></li>
23
- <% end %>
24
- </ol>
25
- </div>
26
- EOS
27
- end
28
- end
29
- end
30
- end
@@ -1,13 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'erb'
4
-
5
- module TurnipFormatter
6
- class Template
7
- module StepMultiline
8
- def self.build(lines)
9
- '<pre class="multiline">' + ERB::Util.h(lines) + '</pre>'
10
- end
11
- end
12
- end
13
- end
@@ -1,29 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'erb'
4
-
5
- module TurnipFormatter
6
- class Template
7
- module StepOutline
8
- def self.build(table)
9
- template_step_outline.result(binding)
10
- end
11
-
12
- private
13
-
14
- def self.template_step_outline
15
- @template_step_outline ||= ERB.new(<<-EOS)
16
- <table class="step_outline">
17
- <% table.each do |tr| %>
18
- <tr>
19
- <% tr.each do |td| %>
20
- <td><%= ERB::Util.h(td) %></td>
21
- <% end %>
22
- </tr>
23
- <% end %>
24
- </table>
25
- EOS
26
- end
27
- end
28
- end
29
- end
@@ -1,15 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'erb'
4
- require 'rspec/core/formatters/snippet_extractor'
5
-
6
- module TurnipFormatter
7
- class Template
8
- module StepSource
9
- def self.build(location)
10
- @snippet_extractor ||= ::RSpec::Core::Formatters::SnippetExtractor.new
11
- '<pre class="source"><code class="ruby">' + @snippet_extractor.snippet([location]) + '</code></pre>'
12
- end
13
- end
14
- end
15
- end
@@ -1,18 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'spec_helper'
4
- require 'turnip_formatter/template/step_multiline'
5
-
6
- module TurnipFormatter
7
- class Template
8
- describe StepMultiline do
9
- let(:template) { ::TurnipFormatter::Template::StepMultiline }
10
- let(:string) { 'a<a>a' }
11
-
12
- describe '.build' do
13
- subject { template.build(string) }
14
- it { should eq '<pre class="multiline">a&lt;a&gt;a</pre>' }
15
- end
16
- end
17
- end
18
- end
@@ -1,31 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'spec_helper'
4
- require 'turnip/table'
5
- require 'turnip_formatter/template/step_outline'
6
-
7
- module TurnipFormatter
8
- class Template
9
- describe StepOutline do
10
- let(:template) { ::TurnipFormatter::Template::StepOutline }
11
-
12
- let(:string) do
13
- ::Turnip::Table.new([
14
- ["State", "Money"],
15
- ["<Tokushima>", "555"],
16
- ["<Okinawa>", "368"]
17
- ])
18
- end
19
-
20
- describe '.build' do
21
- subject { template.build(string) }
22
-
23
- it do
24
- should match %r{<td>State</td>[[:space:]]+<td>Money</td>}
25
- should match %r{<td>&lt;Tokushima&gt;</td>[[:space:]]+<td>555</td>}
26
- should match %r{<td>&lt;Okinawa&gt;</td>[[:space:]]+<td>368</td>}
27
- end
28
- end
29
- end
30
- end
31
- end