turnip_formatter 0.2.11 → 0.3.0

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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/README.md +18 -22
  4. data/example/README.md +6 -8
  5. data/example/images/background.png +0 -0
  6. data/example/images/basic_step.png +0 -0
  7. data/example/images/failed_step.png +0 -0
  8. data/example/images/multiline.png +0 -0
  9. data/example/images/outline.png +0 -0
  10. data/example/images/pending_step.png +0 -0
  11. data/example/spec/bar.js +1 -0
  12. data/example/spec/foo.css +3 -0
  13. data/example/spec/spec_helper.rb +7 -2
  14. data/lib/rspec/core/formatters/turnip_formatter.rb +32 -19
  15. data/lib/turnip_formatter/printer/index.rb +6 -9
  16. data/lib/turnip_formatter/printer/scenario.rb +4 -2
  17. data/lib/turnip_formatter/printer/step.rb +16 -14
  18. data/lib/turnip_formatter/printer/step_extra_args.rb +2 -0
  19. data/lib/turnip_formatter/printer/tab_speed_statistics.rb +2 -1
  20. data/lib/turnip_formatter/printer/tab_tag_statistics.rb +5 -6
  21. data/lib/turnip_formatter/printer.rb +6 -11
  22. data/lib/turnip_formatter/scenario/base.rb +98 -0
  23. data/lib/turnip_formatter/scenario/failure.rb +19 -21
  24. data/lib/turnip_formatter/scenario/pass.rb +2 -13
  25. data/lib/turnip_formatter/scenario/pending.rb +19 -25
  26. data/lib/turnip_formatter/step.rb +8 -38
  27. data/lib/turnip_formatter/step_template/base.rb +34 -0
  28. data/lib/turnip_formatter/step_template/exception.rb +59 -50
  29. data/lib/turnip_formatter/step_template/source.rb +36 -34
  30. data/lib/turnip_formatter/template/exception.haml +8 -0
  31. data/lib/turnip_formatter/template/index.haml +88 -0
  32. data/lib/turnip_formatter/template/runtime_exception.haml +13 -0
  33. data/lib/turnip_formatter/template/scenario.haml +14 -0
  34. data/lib/turnip_formatter/template/step.haml +6 -0
  35. data/lib/turnip_formatter/template/step_multiline.haml +1 -0
  36. data/lib/turnip_formatter/template/step_outline.haml +6 -0
  37. data/lib/turnip_formatter/template/tab_feature_statistics.haml +18 -0
  38. data/lib/turnip_formatter/template/tab_speed_statistics.haml +16 -0
  39. data/lib/turnip_formatter/template/tab_tag_statistics.haml +18 -0
  40. data/lib/turnip_formatter/template/turnip_formatter.js +8 -25
  41. data/lib/turnip_formatter/template/turnip_formatter.scss +102 -174
  42. data/lib/turnip_formatter/template.rb +65 -39
  43. data/lib/turnip_formatter/version.rb +1 -1
  44. data/lib/turnip_formatter.rb +45 -7
  45. data/spec/spec_helper.rb +6 -1
  46. data/spec/support/example_helper.rb +36 -0
  47. data/spec/support/step_helper.rb +27 -0
  48. data/spec/turnip_formatter/printer/index_spec.rb +10 -10
  49. data/spec/turnip_formatter/printer/scenario_spec.rb +29 -23
  50. data/spec/turnip_formatter/printer/step_extra_args_spec.rb +6 -6
  51. data/spec/turnip_formatter/printer/step_spec.rb +36 -69
  52. data/spec/turnip_formatter/printer/tab_feature_statistics_spec.rb +1 -4
  53. data/spec/turnip_formatter/printer/tab_speed_statistics_spec.rb +1 -4
  54. data/spec/turnip_formatter/printer/tab_tag_statistics_spec.rb +1 -4
  55. data/spec/turnip_formatter/scenario/base_spec.rb +67 -0
  56. data/spec/turnip_formatter/scenario/failure_spec.rb +16 -38
  57. data/spec/turnip_formatter/scenario/pending_spec.rb +16 -39
  58. data/spec/turnip_formatter/step_template/base_spec.rb +82 -0
  59. data/spec/turnip_formatter/step_template/exception_spec.rb +25 -17
  60. data/spec/turnip_formatter/step_template/source_spec.rb +10 -13
  61. data/turnip_formatter.gemspec +15 -11
  62. metadata +83 -41
  63. data/example/images/tag_step.png +0 -0
  64. data/images/tab_feature_statistics.png +0 -0
  65. data/images/tab_speed_statistics.png +0 -0
  66. data/images/tab_steps.png +0 -0
  67. data/images/tab_steps_expanding.png +0 -0
  68. data/images/tab_tag_statistics.png +0 -0
  69. data/lib/turnip_formatter/ext/turnip/builder.rb +0 -47
  70. data/lib/turnip_formatter/scenario.rb +0 -89
  71. data/lib/turnip_formatter/step/dsl.rb +0 -33
  72. data/lib/turnip_formatter/step/failure.rb +0 -19
  73. data/lib/turnip_formatter/step/pending.rb +0 -19
  74. data/lib/turnip_formatter/step_template.rb +0 -8
  75. data/lib/turnip_formatter/template/exception.erb +0 -10
  76. data/lib/turnip_formatter/template/exception_backtrace.erb +0 -7
  77. data/lib/turnip_formatter/template/index.erb +0 -70
  78. data/lib/turnip_formatter/template/runtime_exception.erb +0 -16
  79. data/lib/turnip_formatter/template/scenario.erb +0 -25
  80. data/lib/turnip_formatter/template/section_report.erb +0 -15
  81. data/lib/turnip_formatter/template/step.erb +0 -4
  82. data/lib/turnip_formatter/template/step_multiline.erb +0 -1
  83. data/lib/turnip_formatter/template/step_outline.erb +0 -9
  84. data/lib/turnip_formatter/template/tab_feature_statistics.erb +0 -24
  85. data/lib/turnip_formatter/template/tab_speed_statistics.erb +0 -18
  86. data/lib/turnip_formatter/template/tab_tag_statistics.erb +0 -24
  87. data/spec/rspec/core/formatters/turnip_formatter_spec.rb +0 -78
  88. data/spec/support/shared_context_examples.rb +0 -39
  89. data/spec/turnip_formatter/scenario/pass_spec.rb +0 -54
  90. data/spec/turnip_formatter/step/failure_spec.rb +0 -64
  91. data/spec/turnip_formatter/step/pending_spec.rb +0 -63
  92. data/spec/turnip_formatter/step_spec.rb +0 -86
@@ -1,36 +1,42 @@
1
1
  require 'spec_helper'
2
2
  require 'turnip_formatter/printer/scenario'
3
3
 
4
- module TurnipFormatter::Printer
5
- describe Scenario do
6
- include_context 'turnip_formatter scenario setup'
7
- include_context 'turnip_formatter standard scenario metadata'
4
+ describe TurnipFormatter::Printer::Scenario do
5
+ let(:example) do
6
+ passed_example
7
+ end
8
8
 
9
- let(:scenario) do
10
- TurnipFormatter::Scenario::Pass.new(example)
11
- end
9
+ let(:scenario) do
10
+ TurnipFormatter::Scenario::Pass.new(example)
11
+ end
12
12
 
13
- context 'turnip example' do
14
- describe '.print_out' do
15
- subject { Scenario.print_out(scenario) }
13
+ describe '.print_out' do
14
+ context 'with turnip example' do
15
+ subject { described_class.print_out(scenario) }
16
16
 
17
- it { should have_tag 'a', with: { href: '#' + scenario.id } }
18
- it { should have_tag 'span.scenario_name', text: /Scenario: Scenario/ }
19
- it { should have_tag 'span.feature_name' }
20
- it { should have_tag 'ul.tags' }
21
- it { should have_tag 'ul.steps' }
22
- end
17
+ it { should have_tag 'a', with: { href: '#' + scenario.id } }
18
+ it { should have_tag 'div.scenario-title', text: /Scenario: Scenario/ }
19
+ it { should have_tag 'ul.tags' }
20
+ it { should have_tag 'div.steps' }
23
21
  end
24
22
 
25
- context 'not turnip example' do
26
- describe '.print_out' do
27
- before do
28
- allow(scenario).to receive(:validation) { raise NoFeatureFileError }
29
- expect(RuntimeError).to receive(:print_out)
30
- end
23
+ context 'with no turnip example' do
24
+ let(:example) do
25
+ passed_example.tap { |e| e.metadata.delete(:turnip_formatter) }
26
+ end
31
27
 
32
- it { Scenario.print_out(scenario) }
28
+ subject { described_class.print_out(scenario) }
29
+
30
+ it { should be nil }
31
+ end
32
+
33
+ context 'runtime error' do
34
+ before do
35
+ allow(scenario).to receive(:valid?) { raise StandardError }
36
+ expect(TurnipFormatter::Printer::RuntimeError).to receive(:print_out)
33
37
  end
38
+
39
+ it { described_class.print_out(scenario) }
34
40
  end
35
41
  end
36
42
  end
@@ -17,14 +17,14 @@ module TurnipFormatter::Printer
17
17
 
18
18
  it {
19
19
  expect(subject).to have_tag 'table.step_outline' do
20
- with_tag 'tr:nth-child(1) td:nth-child(1)', text: 'State'
21
- with_tag 'tr:nth-child(1) td:nth-child(2)', text: 'Money'
20
+ with_tag 'tr:nth-child(1) td:nth-child(1)', text: /State/
21
+ with_tag 'tr:nth-child(1) td:nth-child(2)', text: /Money/
22
22
 
23
- with_tag 'tr:nth-child(2) td:nth-child(1)', text: '<Tokushima>'
24
- with_tag 'tr:nth-child(2) td:nth-child(2)', text: '555'
23
+ with_tag 'tr:nth-child(2) td:nth-child(1)', text: /<Tokushima>/
24
+ with_tag 'tr:nth-child(2) td:nth-child(2)', text: /555/
25
25
 
26
- with_tag 'tr:nth-child(3) td:nth-child(1)', text: '<Okinawa>'
27
- with_tag 'tr:nth-child(3) td:nth-child(2)', text: '368'
26
+ with_tag 'tr:nth-child(3) td:nth-child(1)', text: /<Okinawa>/
27
+ with_tag 'tr:nth-child(3) td:nth-child(2)', text: /368/
28
28
  end
29
29
  }
30
30
  end
@@ -1,89 +1,56 @@
1
1
  require 'spec_helper'
2
2
  require 'turnip_formatter/printer/step'
3
3
 
4
- module TurnipFormatter::Printer
5
- describe Step do
6
- let(:exception_style) { ::TurnipFormatter::StepTemplate::Exception }
7
- let(:source_style) { ::TurnipFormatter::StepTemplate::Source }
8
-
9
- subject { Step.print_out(step) }
10
-
11
- context 'Step has arguments' do
12
- let(:table) { Turnip::Table.new [] }
13
-
14
- context 'original template' do
15
- describe '#step_args' do
16
- let(:step) do
17
- docs = {}
18
- docs[:extra_args] = { klass: nil, value: ['a', table] }
19
- docs[source_style] = { klass: source_style, value: 'b' }
20
- docs[exception_style] = { klass: exception_style, value: 'c' }
21
-
22
- double(status: '', name: 'step', docs: docs)
23
- end
24
-
25
- before do
26
- expect(StepExtraArgs).to receive(:print_out).with(['a', table]).and_return('extra_args')
27
- expect(source_style).to receive(:build).with('b').and_return('source')
28
- expect(exception_style).to receive(:build).with('c').and_return('exception')
29
- end
4
+ describe TurnipFormatter::Printer::Step do
5
+ describe '.print_out' do
6
+ subject { described_class.print_out(step) }
7
+
8
+ context 'not has extra argument' do
9
+ let(:step) do
10
+ step = passed_step
11
+ expect(step).to receive(:extra_args).and_return([])
12
+ step
13
+ end
30
14
 
31
- it { should have_tag 'div.args', text: "extra_args\nsource\nexception" }
15
+ it do
16
+ should have_tag 'div.step' do
17
+ with_tag 'div.step-title'
32
18
  end
33
19
  end
20
+ end
34
21
 
35
- context 'custom template' do
36
- describe '#step_args' do
37
- let(:custom_template_1) do
38
- Module.new do
39
- def self.build(value)
40
- "<em>#{value}</em>"
41
- end
42
- end
43
- end
44
-
45
- let(:custom_template_2) do
46
- Module.new do
47
- def self.build(value)
48
- "<strong>#{value}</strong>"
49
- end
50
- end
51
- end
52
-
53
- let(:step) do
54
- docs = {
55
- source: { klass: custom_template_1, value: 'aiueo' },
56
- exception: { klass: custom_template_2, value: '12345' }
57
- }
22
+ context 'has table argument' do
23
+ let(:table) { Turnip::Table.new [] }
58
24
 
59
- double(status: '', name: 'step', docs: docs)
60
- end
25
+ let(:step) do
26
+ step = passed_step
27
+ allow(step).to receive(:extra_args).and_return([table])
28
+ step
29
+ end
61
30
 
62
- it 'should call corresponding method in step' do
63
- expect(subject).to have_tag 'div.args' do
64
- with_tag 'em', text: 'aiueo'
65
- with_tag 'strong', text: '12345'
66
- end
31
+ it do
32
+ should have_tag 'div.step' do
33
+ with_tag 'div.step-title'
34
+ with_tag 'div.step-body' do
35
+ with_tag 'table.step_outline'
67
36
  end
68
37
  end
69
38
  end
70
39
  end
71
40
 
72
- context 'Step has no argument' do
73
- describe '#step_args' do
74
- let(:step) do
75
- double(status: '', name: 'step', docs: [])
76
- end
41
+ context 'has outline argument' do
42
+ let(:step) do
43
+ passed_step
44
+ end
77
45
 
78
- before do
79
- expect(StepExtraArgs).not_to receive(:print_out)
80
- expect(source_style).not_to receive(:build)
81
- expect(exception_style).not_to receive(:build)
46
+ it do
47
+ should have_tag 'div.step' do
48
+ with_tag 'div.step-title'
49
+ with_tag 'div.step-body' do
50
+ with_tag 'table.multiline'
51
+ end
82
52
  end
83
-
84
- it { should have_tag 'div.args', text: '' }
85
53
  end
86
54
  end
87
55
  end
88
56
  end
89
-
@@ -3,11 +3,8 @@ require 'turnip_formatter/printer/tab_feature_statistics'
3
3
 
4
4
  module TurnipFormatter::Printer
5
5
  describe TabFeatureStatistics do
6
- include_context 'turnip_formatter scenario setup'
7
- include_context 'turnip_formatter standard scenario metadata'
8
-
9
6
  let :base_scenario do
10
- TurnipFormatter::Scenario::Pass.new(example)
7
+ TurnipFormatter::Scenario::Pass.new(passed_example)
11
8
  end
12
9
 
13
10
  let :statistics do
@@ -3,15 +3,12 @@ require 'turnip_formatter/printer/tab_speed_statistics'
3
3
 
4
4
  module TurnipFormatter::Printer
5
5
  describe TabSpeedStatistics do
6
- include_context 'turnip_formatter scenario setup'
7
- include_context 'turnip_formatter standard scenario metadata'
8
-
9
6
  let :statistics do
10
7
  TurnipFormatter::Printer::TabSpeedStatistics
11
8
  end
12
9
 
13
10
  let :passed_scenarios do
14
- ([example] * 3).map do |ex|
11
+ ([passed_example] * 3).map do |ex|
15
12
  TurnipFormatter::Scenario::Pass.new(ex)
16
13
  end.each { |s| allow(s).to receive(:run_time).and_return(rand) }
17
14
  end
@@ -3,11 +3,8 @@ require 'turnip_formatter/printer/tab_tag_statistics'
3
3
 
4
4
  module TurnipFormatter::Printer
5
5
  describe TabTagStatistics do
6
- include_context 'turnip_formatter scenario setup'
7
- include_context 'turnip_formatter standard scenario metadata'
8
-
9
6
  let :base_scenario do
10
- TurnipFormatter::Scenario::Pass.new(example)
7
+ TurnipFormatter::Scenario::Pass.new(passed_example)
11
8
  end
12
9
 
13
10
  let :scenarios do
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe TurnipFormatter::Scenario::Base do
4
+ let(:example) { passed_example }
5
+ let(:scenario) { described_class.new(example) }
6
+
7
+ describe '#valid?' do
8
+ subject { scenario.valid? }
9
+
10
+ context 'called by turnip example' do
11
+ it { should be true }
12
+ end
13
+
14
+ context 'called by not turnip example' do
15
+ let(:example) do
16
+ passed_example.tap { |e| e.metadata.delete(:turnip_formatter) }
17
+ end
18
+
19
+ it { should be false }
20
+ end
21
+ end
22
+
23
+ describe '#id' do
24
+ it 'returns unique string' do
25
+ expect(scenario.id).to start_with 'scenario_'
26
+ end
27
+ end
28
+
29
+ describe '#steps' do
30
+ subject { scenario.steps }
31
+
32
+ it 'returns step array' do
33
+ expect(subject).to be_a Array
34
+ expect(subject[0]).to be_a TurnipFormatter::Step
35
+ end
36
+ end
37
+
38
+ describe '#name' do
39
+ it 'returns scenario name' do
40
+ expect(scenario.name).to eq 'Scenario'
41
+ end
42
+ end
43
+
44
+ describe '#status' do
45
+ it 'returns scenario status' do
46
+ expect(scenario.status).to eq 'passed'
47
+ end
48
+ end
49
+
50
+ describe '#run_time' do
51
+ it 'returns run time(second) of scenario' do
52
+ expect(scenario.run_time).to be_a Float
53
+ end
54
+ end
55
+
56
+ describe '#feature_info' do
57
+ it 'returns feature name and filepath' do
58
+ expect(scenario.feature_info).to eq '"Feature" in /path/to/hoge.feature'
59
+ end
60
+ end
61
+
62
+ describe '#tags' do
63
+ it 'returns tags' do
64
+ expect(scenario.tags).to be_a Array
65
+ end
66
+ end
67
+ end
@@ -1,50 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
- module TurnipFormatter::Scenario
4
- describe Failure do
5
- let(:scenario) { ::TurnipFormatter::Scenario::Failure.new(failure_example) }
6
- include_context 'turnip_formatter standard scenario metadata'
7
- include_context 'turnip_formatter failure scenario setup'
3
+ describe TurnipFormatter::Scenario::Failure do
4
+ let(:example) { failed_example }
5
+ let(:scenario) { described_class.new(example) }
8
6
 
9
- context 'Turnip example' do
10
- let(:failure_example) do
11
- example.exception.backtrace.push ":in step:0 `"
12
- example
13
- end
7
+ describe '#valid?' do
8
+ subject { scenario.valid? }
14
9
 
15
- describe '#validation' do
16
- it 'should not raise exception' do
17
- expect { scenario.validation }.not_to raise_error
18
- end
19
- end
10
+ context 'called by turnip example' do
11
+ it { should be true }
20
12
  end
21
13
 
22
- context 'Not Turnip example' do
23
- let(:failure_example) do
24
- example
14
+ context 'called by not turnip example' do
15
+ let(:example) do
16
+ failed_example.tap { |e| e.exception.backtrace.pop }
25
17
  end
26
18
 
27
- context 'Not failed example' do
28
- include_context 'turnip_formatter scenario setup'
29
-
30
- describe '#validation' do
31
- it 'should raise exception' do
32
- expect {
33
- scenario.validation
34
- }.to raise_error NotFailedScenarioError
35
- end
36
- end
37
- end
19
+ it { should be false }
20
+ end
21
+ end
38
22
 
39
- context 'Not exist failed step information' do
40
- describe '#validation' do
41
- it 'should raise exception' do
42
- expect {
43
- scenario.validation
44
- }.to raise_error NoExistFailedStepInformationError
45
- end
46
- end
47
- end
23
+ describe '#status' do
24
+ it 'return scenario status' do
25
+ expect(scenario.status).to eq 'failed'
48
26
  end
49
27
  end
50
28
  end
@@ -1,51 +1,28 @@
1
1
  require 'spec_helper'
2
2
 
3
- module TurnipFormatter::Scenario
4
- describe Failure do
5
- include_context 'turnip_formatter standard scenario metadata'
6
- include_context 'turnip_formatter pending scenario setup'
3
+ describe TurnipFormatter::Scenario::Pending do
4
+ let(:example) { pending_example }
5
+ let(:scenario) { described_class.new(example) }
7
6
 
8
- let(:scenario) { ::TurnipFormatter::Scenario::Pending.new(pending_example) }
7
+ describe '#valid?' do
8
+ subject { scenario.valid? }
9
9
 
10
- context 'Turnip example' do
11
- let(:pending_example) do
12
- example.execution_result[:pending_message] = 'No such step(0): '
13
- example
14
- end
15
-
16
- describe '#validation' do
17
- it 'should not raise exception' do
18
- expect { scenario.validation }.not_to raise_error
19
- end
20
- end
10
+ context 'called by turnip example' do
11
+ it { should be true }
21
12
  end
22
13
 
23
- context 'Not Turnip example' do
24
- let(:pending_example) do
25
- example
14
+ context 'called by not turnip example' do
15
+ let(:example) do
16
+ pending_example.tap { |e| e.execution_result[:pending_message] = '' }
26
17
  end
27
18
 
28
- context 'Not pending example' do
29
- include_context 'turnip_formatter scenario setup'
30
-
31
- describe '#validation' do
32
- it 'should raise exception' do
33
- expect {
34
- scenario.validation
35
- }.to raise_error NotPendingScenarioError
36
- end
37
- end
38
- end
19
+ it { should be false }
20
+ end
21
+ end
39
22
 
40
- context 'Not exist pending step information' do
41
- describe '#validation' do
42
- it 'should raise exception' do
43
- expect {
44
- scenario.validation
45
- }.to raise_error NoExistPendingStepInformationError
46
- end
47
- end
48
- end
23
+ describe '#status' do
24
+ it 'return scenario status' do
25
+ expect(scenario.status).to eq 'pending'
49
26
  end
50
27
  end
51
28
  end
@@ -0,0 +1,82 @@
1
+ require 'spec_helper'
2
+ require 'turnip_formatter/step_template/exception'
3
+
4
+ describe TurnipFormatter::StepTemplate::Base do
5
+ before do
6
+ @backup_templates = TurnipFormatter.step_templates
7
+ TurnipFormatter.step_templates.clear
8
+ end
9
+
10
+ after do
11
+ @backup_templates.each do |t|
12
+ TurnipFormatter.step_templates << t
13
+ end
14
+ end
15
+
16
+ context 'register step template' do
17
+ before do
18
+ Class.new(described_class) do
19
+ on_passed :build_passed
20
+ on_failed :build_failed1
21
+ on_failed :build_failed2
22
+ on_pending :build_pending
23
+
24
+ def build_passed(_)
25
+ 'build_passed'
26
+ end
27
+
28
+ def build_failed1(_)
29
+ 'build_failed'
30
+ end
31
+
32
+ def build_failed2(_)
33
+ 'hello_world'
34
+ end
35
+
36
+ def build_pending(_)
37
+ 'build_pending'
38
+ end
39
+ end
40
+ end
41
+
42
+ after do
43
+ TurnipFormatter.step_templates.pop
44
+ end
45
+
46
+ describe '.on_passed' do
47
+ subject do
48
+ TurnipFormatter.step_templates_for(:passed).map do |template, method|
49
+ template.send(method, passed_example)
50
+ end.join
51
+ end
52
+
53
+ it 'returns step document for passed' do
54
+ should eq 'build_passed'
55
+ end
56
+ end
57
+
58
+ describe '.on_failed' do
59
+ subject do
60
+ TurnipFormatter.step_templates_for(:failed).map do |template, method|
61
+ template.send(method, failed_example)
62
+ end.join
63
+ end
64
+
65
+ it 'returns step document for failed' do
66
+ should eq 'build_failedhello_world'
67
+ end
68
+ end
69
+
70
+ describe '.on_pending' do
71
+ subject do
72
+ TurnipFormatter.step_templates_for(:pending).map do |template, method|
73
+ template.send(method, pending_example)
74
+ end.join
75
+ end
76
+
77
+ it 'returns step document for failed' do
78
+ should eq 'build_pending'
79
+ end
80
+ end
81
+ end
82
+ end
@@ -1,25 +1,33 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  require 'spec_helper'
4
2
  require 'turnip_formatter/step_template/exception'
5
3
 
6
- module TurnipFormatter
7
- module StepTemplate
8
- describe Exception do
9
- let(:template) { ::TurnipFormatter::StepTemplate::Exception }
10
- let(:exception) do
11
- StandardError.new('StepExceptionError').tap do |e|
12
- e.set_backtrace('/path/to/error.rb: 10')
13
- end
4
+ describe TurnipFormatter::StepTemplate::Exception do
5
+ after do
6
+ TurnipFormatter.step_templates.pop
7
+ end
8
+
9
+ let!(:template) do
10
+ described_class.new
11
+ end
12
+
13
+ describe '#build_failed' do
14
+ subject { template.build_failed(failed_example) }
15
+
16
+ it do
17
+ expect(subject).to have_tag 'div.step_exception' do
18
+ with_tag 'pre'
19
+ with_tag 'ol > li', text: ':in step:0 `'
14
20
  end
21
+ end
22
+ end
23
+
24
+ describe '#build_pending' do
25
+ subject { template.build_pending(pending_example) }
15
26
 
16
- describe '.build' do
17
- subject { template.build(exception) }
18
- it do
19
- should match %r{div class="step_exception"}
20
- should match %r{<pre>.*#{exception.message}.*</pre>}
21
- should match %r{<li>/path/to/error.rb: 10</li>}
22
- end
27
+ it do
28
+ expect(subject).to have_tag 'div.step_exception' do
29
+ with_tag 'pre', text: 'No such step(0):'
30
+ with_tag 'ol > li'
23
31
  end
24
32
  end
25
33
  end
@@ -1,20 +1,17 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  require 'spec_helper'
4
2
  require 'turnip_formatter/step_template/source'
5
3
 
6
- module TurnipFormatter
7
- module StepTemplate
8
- describe Source do
9
- let(:template) { ::TurnipFormatter::StepTemplate::Source }
10
- let(:source) { __FILE__ + ':3' }
4
+ describe TurnipFormatter::StepTemplate::Source do
5
+ let(:template) do
6
+ described_class.new
7
+ end
8
+
9
+ describe '#build' do
10
+ subject { template.build(failed_example) }
11
11
 
12
- describe '.build' do
13
- subject { template.build(source) }
14
- it do
15
- should match '<pre class="source"><code class="ruby">'
16
- should match "require 'turnip_formatter/step_template/source'"
17
- end
12
+ it do
13
+ expect(subject).to have_tag 'pre.source > code.ruby' do
14
+ with_tag 'span.linenum'
18
15
  end
19
16
  end
20
17
  end
@@ -4,24 +4,28 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'turnip_formatter/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "turnip_formatter"
7
+ spec.name = 'turnip_formatter'
8
8
  spec.version = TurnipFormatter::VERSION
9
- spec.authors = ["Wataru MIYAGUNI"]
10
- spec.email = ["gonngo@gmail.com"]
11
- spec.description = %q{RSpec custom formatter for Turnip}
12
- spec.summary = %q{RSpec custom formatter for Turnip}
13
- spec.homepage = "https://github.com/gongo/turnip_formatter"
14
- spec.license = "MIT"
9
+ spec.authors = ['Wataru MIYAGUNI']
10
+ spec.email = ['gonngo@gmail.com']
11
+ spec.description = %q(RSpec custom formatter for Turnip)
12
+ spec.summary = %q(RSpec custom formatter for Turnip)
13
+ spec.homepage = 'https://github.com/gongo/turnip_formatter'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^spec/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'turnip', '~> 1.2.0'
21
+ spec.add_dependency 'turnip', '~> 1.2.2'
22
+ spec.add_dependency 'tilt'
23
+ spec.add_dependency 'haml'
22
24
  spec.add_dependency 'sass'
23
- spec.add_development_dependency "bundler", "~> 1.3"
24
- spec.add_development_dependency "rake"
25
+ spec.add_dependency 'bootstrap-sass'
26
+ spec.add_dependency 'rspec', '~> 2.14.0'
27
+ spec.add_development_dependency 'bundler', '~> 1.3'
28
+ spec.add_development_dependency 'rake'
25
29
  spec.add_development_dependency 'rspec-html-matchers'
26
30
  spec.add_development_dependency 'coveralls'
27
31
  spec.add_development_dependency 'guard-rspec'