pretty_face 0.1 → 0.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.
- data/.gitignore +2 -0
- data/.travis.yml +2 -0
- data/ChangeLog +7 -0
- data/README.md +8 -2
- data/Rakefile +1 -0
- data/autotrader.png +0 -0
- data/cucumber.yml +1 -1
- data/features/feature_pages.feature +94 -0
- data/features/pretty_face_report.feature +38 -32
- data/features/support/hooks.rb +5 -0
- data/fixtures/advanced.feature +43 -0
- data/fixtures/background.feature +10 -0
- data/fixtures/basic.feature +3 -0
- data/fixtures/failing_background.feature +7 -0
- data/fixtures/more/more.feature +8 -0
- data/fixtures/step_definitions/advanced_steps.rb +24 -2
- data/fixtures/step_definitions/basic_steps.rb +6 -0
- data/lib/pretty_face/formatter/html.rb +123 -38
- data/lib/pretty_face/formatter/report.rb +145 -14
- data/lib/pretty_face/formatter/view_helper.rb +10 -9
- data/lib/pretty_face/templates/_step.erb +41 -0
- data/lib/pretty_face/templates/failed.png +0 -0
- data/lib/pretty_face/templates/feature.erb +147 -0
- data/lib/pretty_face/templates/main.erb +71 -130
- data/lib/pretty_face/templates/passed.png +0 -0
- data/lib/pretty_face/templates/pending.png +0 -0
- data/lib/pretty_face/templates/skipped.png +0 -0
- data/lib/pretty_face/templates/style.css +149 -0
- data/lib/pretty_face/templates/undefined.png +0 -0
- data/lib/pretty_face/version.rb +1 -1
- data/pretty_face.gemspec +3 -1
- data/spec/lib/html_formatter_spec.rb +45 -16
- metadata +35 -4
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/ChangeLog
CHANGED
@@ -1,2 +1,9 @@
|
|
1
|
+
=== Release 0.2
|
2
|
+
* Creating a page for each feature file
|
3
|
+
* Displaying Background
|
4
|
+
* Displaying Errors on feature pages
|
5
|
+
* Displaying multi-line steps
|
6
|
+
* Displaying embedded images
|
7
|
+
|
1
8
|
=== Release 0.1 / 2012-11-17
|
2
9
|
Initial release with single page basic report
|
data/README.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# pretty_face
|
2
2
|
|
3
|
-
HTML report for cucumber and rspec. You can
|
3
|
+
HTML report for cucumber and rspec. You can customize the report by editing an erb file.
|
4
|
+
|
5
|
+
The current release is very basic but you can expect a lot more over the next month or so. If you wish to use this formatter you can simply add the following to your command-line or cucumber.yml profile:
|
6
|
+
|
7
|
+
--format PrettyFace::Formatter::Html --out index.html
|
8
|
+
|
9
|
+
|
4
10
|
|
5
11
|
## Known Issues
|
6
12
|
|
@@ -18,4 +24,4 @@ See [http://github.com/cheezy/pretty_face/issues](http://github.com/cheezy/prett
|
|
18
24
|
|
19
25
|
## Copyright
|
20
26
|
|
21
|
-
Copyright (c) 2012 Jeffrey S. Morgan. See LICENSE for details.
|
27
|
+
Copyright (c) 2012-2013 Jeffrey S. Morgan. See LICENSE for details.
|
data/Rakefile
CHANGED
data/autotrader.png
ADDED
Binary file
|
data/cucumber.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
default: --color --no-source --format pretty
|
2
|
-
fixture: --color --no-source --require fixtures/step_definitions --format PrettyFace::Formatter::Html --out fixture.html
|
2
|
+
fixture: --color --no-source --require fixtures/step_definitions --format PrettyFace::Formatter::Html --out results/fixture.html
|
3
3
|
focus: --color --no-source --format pretty --tags @focus
|
@@ -0,0 +1,94 @@
|
|
1
|
+
Feature: pages that show details for features
|
2
|
+
|
3
|
+
Background:
|
4
|
+
When I run `cucumber fixtures --profile fixture`
|
5
|
+
|
6
|
+
Scenario: Generate the pages
|
7
|
+
Then the following files should exist:
|
8
|
+
| results/basic.html |
|
9
|
+
| results/advanced.html |
|
10
|
+
|
11
|
+
Scenario: Generating the basic html page from the erb
|
12
|
+
Then the file "results/basic.html" should contain "DOCTYPE html PUBLIC"
|
13
|
+
And the file "results/basic.html" should contain "<html xmlns='http://www.w3.org/1999/xhtml'>"
|
14
|
+
And the file "results/basic.html" should contain "<head>"
|
15
|
+
And the file "results/basic.html" should contain "<body"
|
16
|
+
And the file "results/basic.html" should contain "<title>Feature Results</title>"
|
17
|
+
|
18
|
+
Scenario: Including an image / logo
|
19
|
+
Then the file "results/basic.html" should contain "<img src="
|
20
|
+
And the file "results/basic.html" should contain "images/face.jpg"
|
21
|
+
|
22
|
+
Scenario: It should show start time and duration in the header
|
23
|
+
Then the file "results/basic.html" should contain "Feature started:"
|
24
|
+
And the file "results/basic.html" should contain "Duration:"
|
25
|
+
|
26
|
+
Scenario: Generating some basic stats from the erb
|
27
|
+
Then the file "results/basic.html" should contain "<th>Executed<"
|
28
|
+
And the file "results/basic.html" should contain "<th>Average<br/>Duration"
|
29
|
+
And the file "results/basic.html" should contain "Scenarios"
|
30
|
+
And the file "results/basic.html" should contain "Steps"
|
31
|
+
|
32
|
+
Scenario: It should capture scenario and step statuses
|
33
|
+
Then the file "results/basic.html" should contain "Passed"
|
34
|
+
And the file "results/basic.html" should contain "Failed"
|
35
|
+
And the file "results/basic.html" should contain "Pending"
|
36
|
+
And the file "results/basic.html" should contain "Undefined"
|
37
|
+
And the file "results/basic.html" should contain "Skipped"
|
38
|
+
|
39
|
+
Scenario: It should display scenario names
|
40
|
+
Then the file "results/basic.html" should contain "A passing scenario"
|
41
|
+
And the file "results/advanced.html" should contain "A scenario outline"
|
42
|
+
And the file "results/background.html" should contain "Another passing scenario"
|
43
|
+
|
44
|
+
Scenario: It should display scenario steps
|
45
|
+
Then the file "results/basic.html" should contain "it should say hello"
|
46
|
+
And the file "results/background.html" should contain "it should say hello"
|
47
|
+
And the file "results/advanced.html" should contain "I am using a scenario outline"
|
48
|
+
|
49
|
+
Scenario: It should display the step and data for scenario outline steps
|
50
|
+
I use 'aaa'\
|
51
|
+
Then the file "results/advanced.html" should contain "I use 'aaa'"
|
52
|
+
And the file "results/advanced.html" should contain "I use 'bbb'"
|
53
|
+
|
54
|
+
Scenario: It should display descriptions for features
|
55
|
+
Then the file "results/basic.html" should contain "As a stakeholder"
|
56
|
+
Then the file "results/basic.html" should contain "I want to see some details about this feature"
|
57
|
+
Then the file "results/basic.html" should contain "So that I have some idea why this test matters"
|
58
|
+
|
59
|
+
Scenario: It should display a nested table
|
60
|
+
Then the file "results/advanced.html" should contain "<th>key1</th>"
|
61
|
+
And the file "results/advanced.html" should contain "<th>key2</th>"
|
62
|
+
And the file "results/advanced.html" should contain "<th>key3</th>"
|
63
|
+
And the file "results/advanced.html" should contain "<td>value1</td>"
|
64
|
+
And the file "results/advanced.html" should contain "<td>value2</td>"
|
65
|
+
And the file "results/advanced.html" should contain "<td>value3</td>"
|
66
|
+
|
67
|
+
Scenario: It should display the multi-line argument
|
68
|
+
Then the file "results/advanced.html" should contain "Hello with"
|
69
|
+
And the file "results/advanced.html" should contain "more than one"
|
70
|
+
And the file "results/advanced.html" should contain "line in a string"
|
71
|
+
|
72
|
+
Scenario: It should display errors for features
|
73
|
+
Then the file "results/basic.html" should contain "RSpec::Expectations::ExpectationNotMetError"
|
74
|
+
Then the file "results/advanced.html" should contain "RSpec::Expectations::ExpectationNotMetError"
|
75
|
+
Then the file "results/failing_background.html" should contain "RSpec::Expectations::ExpectationNotMetError"
|
76
|
+
|
77
|
+
Scenario: Embedding an image into the page
|
78
|
+
Then the file "results/basic.html" should contain "<img id='img_0' style='display: none' src='images/autotrader.png'/>"
|
79
|
+
And the file "results/basic.html" should contain "<a href='' onclick="
|
80
|
+
And the file "results/basic.html" should contain "img=document.getElementById('img_0'); img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false"
|
81
|
+
And the file "results/basic.html" should contain ">AutoTrader</a>"
|
82
|
+
|
83
|
+
Scenario: Displaying a background
|
84
|
+
Then the file "results/background.html" should contain "Background: A scenario can have a background"
|
85
|
+
And the file "results/background.html" should contain "When Cucumber puts"
|
86
|
+
|
87
|
+
Scenario: Feature pages should have a link back to the report summary
|
88
|
+
Then the file "results/advanced.html" should contain "<a href="
|
89
|
+
|
90
|
+
Scenario: Should create directories when directories exist in features directory
|
91
|
+
Then the following files should exist:
|
92
|
+
| results/more/more.html |
|
93
|
+
|
94
|
+
|
@@ -5,59 +5,65 @@ Feature: pretty face report
|
|
5
5
|
|
6
6
|
Scenario: Cucumber crefates an html report
|
7
7
|
Then the following files should exist:
|
8
|
-
| fixture.html |
|
8
|
+
| results/fixture.html |
|
9
9
|
|
10
10
|
Scenario: Generating the basic html page from the erb
|
11
|
-
Then the file "fixture.html" should contain "DOCTYPE html PUBLIC"
|
12
|
-
And the file "fixture.html" should contain "<html xmlns='http://www.w3.org/1999/xhtml'>"
|
13
|
-
And the file "fixture.html" should contain "<head>"
|
14
|
-
And the file "fixture.html" should contain "<body"
|
15
|
-
And the file "fixture.html" should contain "<title>Test Results</title>"
|
11
|
+
Then the file "results/fixture.html" should contain "DOCTYPE html PUBLIC"
|
12
|
+
And the file "results/fixture.html" should contain "<html xmlns='http://www.w3.org/1999/xhtml'>"
|
13
|
+
And the file "results/fixture.html" should contain "<head>"
|
14
|
+
And the file "results/fixture.html" should contain "<body"
|
15
|
+
And the file "results/fixture.html" should contain "<title>Test Results</title>"
|
16
16
|
|
17
17
|
Scenario: Generating some basic stats from the erb
|
18
|
-
Then the file "fixture.html" should contain "<th>Executed<"
|
19
|
-
And the file "fixture.html" should contain "<th>Average<br/>Duration"
|
20
|
-
And the file "fixture.html" should contain "Scenarios"
|
21
|
-
And the file "fixture.html" should contain "Steps"
|
18
|
+
Then the file "results/fixture.html" should contain "<th>Executed<"
|
19
|
+
And the file "results/fixture.html" should contain "<th>Average<br/>Duration"
|
20
|
+
And the file "results/fixture.html" should contain "Scenarios"
|
21
|
+
And the file "results/fixture.html" should contain "Steps"
|
22
22
|
|
23
23
|
Scenario: Including the styles for the main page
|
24
|
-
Then the file "fixture.html" should contain "<style type='text/css'
|
25
|
-
And the file "fixture.html" should contain "</style>"
|
24
|
+
Then the file "results/fixture.html" should contain "<link href='stylesheets/style.css' type='text/css' rel='stylesheet' />"
|
25
|
+
And the file "results/fixture.html" should not contain "</style>"
|
26
26
|
|
27
27
|
Scenario: Including an image / logo
|
28
|
-
Then the file "fixture.html" should contain "<img src="
|
29
|
-
And the file "fixture.html" should contain "images/face.jpg"
|
28
|
+
Then the file "results/fixture.html" should contain "<img src="
|
29
|
+
And the file "results/fixture.html" should contain "images/face.jpg"
|
30
|
+
|
31
|
+
Scenario: It should copy the style sheet to the stylesheets directory
|
32
|
+
Then the following files should exist:
|
33
|
+
| results/stylesheets/style.css |
|
30
34
|
|
31
35
|
Scenario: It should copy the logo image to the images directory
|
32
36
|
Then the following files should exist:
|
33
|
-
| images/face.jpg |
|
37
|
+
| results/images/face.jpg |
|
34
38
|
|
35
39
|
Scenario: It should show start time and duration in the header
|
36
|
-
Then the file "fixture.html" should contain "Tests started:"
|
37
|
-
And the file "fixture.html" should contain "Duration:"
|
40
|
+
Then the file "results/fixture.html" should contain "Tests started:"
|
41
|
+
And the file "results/fixture.html" should contain "Duration:"
|
38
42
|
|
39
43
|
Scenario: It should capture scenario and step statuses
|
40
|
-
Then the file "fixture.html" should contain "Passed"
|
41
|
-
And the file "fixture.html" should contain "Failed"
|
42
|
-
And the file "fixture.html" should contain "Pending"
|
43
|
-
And the file "fixture.html" should contain "Undefined"
|
44
|
-
And the file "fixture.html" should contain "Skipped"
|
44
|
+
Then the file "results/fixture.html" should contain "Passed"
|
45
|
+
And the file "results/fixture.html" should contain "Failed"
|
46
|
+
And the file "results/fixture.html" should contain "Pending"
|
47
|
+
And the file "results/fixture.html" should contain "Undefined"
|
48
|
+
And the file "results/fixture.html" should contain "Skipped"
|
45
49
|
|
46
50
|
Scenario: It should display all of the tests with failures
|
47
|
-
Then the file "fixture.html" should contain "Tests With Failures:"
|
51
|
+
Then the file "results/fixture.html" should contain "Tests With Failures:"
|
48
52
|
|
49
53
|
Scenario: It should display a list of all features / scenarios
|
50
|
-
Then the file "fixture.html" should contain "
|
54
|
+
Then the file "results/fixture.html" should contain "Feature Overview:"
|
51
55
|
|
52
56
|
Scenario: It should display useful information about each scenario
|
53
|
-
Then the file "fixture.html" should contain "
|
54
|
-
And the file "fixture.html" should contain "
|
55
|
-
And the file "fixture.html" should contain "
|
56
|
-
And the file "fixture.html" should contain "
|
57
|
+
Then the file "results/fixture.html" should contain "Feature"
|
58
|
+
And the file "results/fixture.html" should contain "File"
|
59
|
+
And the file "results/fixture.html" should contain "Passed"
|
60
|
+
And the file "results/fixture.html" should contain "Failed"
|
61
|
+
And the file "results/fixture.html" should contain "Pending"
|
62
|
+
And the file "results/fixture.html" should contain "Undefined"
|
63
|
+
And the file "results/fixture.html" should contain "Skipped"
|
57
64
|
|
58
65
|
Scenario: It should display the data from scenario outlines
|
59
|
-
Then the file "fixture.html" should contain "| aaa | bbb |"
|
60
|
-
And the file "fixture.html" should contain "| ccc | ddd |"
|
66
|
+
Then the file "results/fixture.html" should contain "| aaa | bbb |"
|
67
|
+
And the file "results/fixture.html" should contain "| ccc | ddd |"
|
61
68
|
|
62
|
-
|
63
|
-
Then the file "fixture.html" should contain "A scenario outline"
|
69
|
+
|
data/features/support/hooks.rb
CHANGED
data/fixtures/advanced.feature
CHANGED
@@ -11,4 +11,47 @@ Feature: Advanced scenarios
|
|
11
11
|
| aaa | bbb |
|
12
12
|
| ccc | ddd |
|
13
13
|
| eee | fff |
|
14
|
+
|
15
|
+
Scenario: Nested table in a step
|
16
|
+
When I have a nested table step like this:
|
17
|
+
| key1 | key2 | key3 |
|
18
|
+
| value1 | value2 | value3 |
|
19
|
+
Then the table should be displayed in the results
|
14
20
|
|
21
|
+
Scenario: A scenario with muti-line arguments
|
22
|
+
When Cucumber puts
|
23
|
+
"""
|
24
|
+
Hello with
|
25
|
+
more than one
|
26
|
+
line in a string
|
27
|
+
"""
|
28
|
+
Then it should say
|
29
|
+
"""
|
30
|
+
Hello with
|
31
|
+
more than one
|
32
|
+
line in a string
|
33
|
+
"""
|
34
|
+
|
35
|
+
Scenario Outline: Fails during examples
|
36
|
+
Given I am using a scenario outline
|
37
|
+
When I fail with <first>
|
38
|
+
Then I use <second>
|
39
|
+
Then the examples should not work
|
40
|
+
|
41
|
+
Examples:
|
42
|
+
| first | second |
|
43
|
+
| aaa | bbb |
|
44
|
+
| ccc | ddd |
|
45
|
+
| eee | fff |
|
46
|
+
|
47
|
+
Scenario Outline: Fails before examples
|
48
|
+
Given the first step fails
|
49
|
+
When I use <first>
|
50
|
+
And I use <second>
|
51
|
+
Then the examples should not work
|
52
|
+
|
53
|
+
Examples:
|
54
|
+
| first | second |
|
55
|
+
| aaa | bbb |
|
56
|
+
| ccc | ddd |
|
57
|
+
| eee | fff |
|
data/fixtures/basic.feature
CHANGED
@@ -1,12 +1,34 @@
|
|
1
1
|
Given /^I am using a scenario outline$/ do
|
2
|
-
|
2
|
+
|
3
3
|
end
|
4
4
|
|
5
5
|
When /^I use (.*?)$/ do |value|
|
6
6
|
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
When /^I fail with (.*?)$/ do |value|
|
10
|
+
true.should == false
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
Then /^the examples should(?: not)? work$/ do
|
15
|
+
sleep 1
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^I have a nested table step like this:$/ do |table|
|
10
19
|
|
11
20
|
end
|
12
21
|
|
22
|
+
Then /^the table should be displayed in the results$/ do
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
When /^Cucumber puts$/ do |some_string|
|
27
|
+
puts some_string
|
28
|
+
@last_string = some_string
|
29
|
+
sleep 1
|
30
|
+
end
|
31
|
+
|
32
|
+
Then /^it should say$/ do |some_string|
|
33
|
+
@last_string.should == some_string
|
34
|
+
end
|
@@ -1,5 +1,11 @@
|
|
1
1
|
When /^Cucumber puts "(.*?)"$/ do |some_string|
|
2
2
|
puts some_string
|
3
|
+
embed('autotrader.png', 'image/png', 'AutoTrader')
|
4
|
+
sleep 1
|
5
|
+
end
|
6
|
+
|
7
|
+
When /^Cucumber puts "(.*?)" in a background$/ do |some_string|
|
8
|
+
puts some_string
|
3
9
|
end
|
4
10
|
|
5
11
|
Then /^it should say hello$/ do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'action_view'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'cucumber/formatter/io'
|
4
4
|
require 'cucumber/formatter/duration'
|
@@ -16,31 +16,61 @@ module PrettyFace
|
|
16
16
|
include Cucumber::Formatter::Duration
|
17
17
|
include ViewHelper
|
18
18
|
|
19
|
+
attr_reader :report
|
20
|
+
|
19
21
|
def initialize(step_mother, path_or_io, options)
|
20
22
|
@path = path_or_io
|
21
23
|
@io = ensure_io(path_or_io, 'html')
|
24
|
+
@path_to_erb = File.join(File.dirname(__FILE__), '..', 'templates')
|
22
25
|
@step_mother = step_mother
|
23
26
|
@options = options
|
24
27
|
@report = Report.new
|
25
|
-
@
|
26
|
-
|
27
|
-
|
28
|
+
@img_id = 0
|
29
|
+
end
|
30
|
+
|
31
|
+
def embed(src, mime_type, label)
|
32
|
+
case(mime_type)
|
33
|
+
when /^image\/(png|gif|jpg|jpeg)/
|
34
|
+
embed_image(src, label)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def embed_image(src, label)
|
39
|
+
@report.current_scenario.image = src.split('/').last
|
40
|
+
@report.current_scenario.image_label = label
|
41
|
+
@report.current_scenario.image_id = "img_#{@img_id}"
|
42
|
+
@img_id += 1
|
43
|
+
FileUtils.cp src, "#{File.dirname(@path)}/images"
|
28
44
|
end
|
29
45
|
|
30
46
|
def before_features(features)
|
47
|
+
make_output_directories
|
31
48
|
@tests_started = Time.now
|
32
49
|
end
|
33
50
|
|
51
|
+
def features_summary_file
|
52
|
+
parts = @io.path.split('/')
|
53
|
+
parts[parts.length - 1]
|
54
|
+
end
|
55
|
+
|
34
56
|
def before_feature(feature)
|
35
|
-
@report.add_feature ReportFeature.new(feature)
|
57
|
+
@report.add_feature ReportFeature.new(feature, features_summary_file)
|
36
58
|
end
|
37
59
|
|
38
60
|
def after_feature(feature)
|
39
|
-
@report.current_feature.
|
61
|
+
@report.current_feature.close(feature)
|
62
|
+
end
|
63
|
+
|
64
|
+
def before_background(background)
|
65
|
+
@report.begin_background
|
66
|
+
end
|
67
|
+
|
68
|
+
def after_background(background)
|
69
|
+
@report.end_background
|
70
|
+
@report.current_feature.background << ReportStep.new(background)
|
40
71
|
end
|
41
72
|
|
42
73
|
def before_feature_element(feature_element)
|
43
|
-
@scenario_timer = Time.now
|
44
74
|
unless scenario_outline? feature_element
|
45
75
|
@report.add_scenario ReportScenario.new(feature_element)
|
46
76
|
end
|
@@ -52,12 +82,16 @@ module PrettyFace
|
|
52
82
|
end
|
53
83
|
end
|
54
84
|
|
55
|
-
def
|
56
|
-
|
85
|
+
def before_table_row(example_row)
|
86
|
+
@report.add_scenario ReportScenario.new(example_row) unless info_row?(example_row)
|
57
87
|
end
|
58
88
|
|
59
89
|
def after_table_row(example_row)
|
60
|
-
|
90
|
+
unless info_row?(example_row)
|
91
|
+
@report.current_scenario.populate(example_row)
|
92
|
+
build_scenario_outline_steps(example_row)
|
93
|
+
end
|
94
|
+
populate_cells(example_row) if example_row.instance_of? Cucumber::Ast::Table::Cells
|
61
95
|
end
|
62
96
|
|
63
97
|
def before_step(step)
|
@@ -65,7 +99,11 @@ module PrettyFace
|
|
65
99
|
end
|
66
100
|
|
67
101
|
def after_step(step)
|
68
|
-
process_step(step)
|
102
|
+
step = process_step(step) unless step_belongs_to_outline? step
|
103
|
+
if @cells
|
104
|
+
step.table = @cells
|
105
|
+
@cells = nil
|
106
|
+
end
|
69
107
|
end
|
70
108
|
|
71
109
|
def after_features(features)
|
@@ -73,6 +111,7 @@ module PrettyFace
|
|
73
111
|
@duration = format_duration(Time.now - @tests_started)
|
74
112
|
generate_report
|
75
113
|
copy_images_directory
|
114
|
+
copy_stylesheets_directory
|
76
115
|
end
|
77
116
|
|
78
117
|
def features
|
@@ -82,58 +121,104 @@ module PrettyFace
|
|
82
121
|
private
|
83
122
|
|
84
123
|
def generate_report
|
85
|
-
|
86
|
-
|
87
|
-
@io.puts
|
124
|
+
renderer = ActionView::Base.new(@path_to_erb)
|
125
|
+
filename = File.join(@path_to_erb, 'main')
|
126
|
+
@io.puts renderer.render(:file => filename, :locals => {:report => self})
|
127
|
+
features.each do |feature|
|
128
|
+
write_feature_file(feature)
|
129
|
+
end
|
88
130
|
end
|
89
131
|
|
90
|
-
def
|
91
|
-
|
132
|
+
def write_feature_file(feature)
|
133
|
+
renderer = ActionView::Base.new(@path_to_erb)
|
134
|
+
filename = File.join(@path_to_erb, 'feature')
|
135
|
+
output_file = "#{File.dirname(@path)}/#{feature.file}"
|
136
|
+
to_cut = output_file.split('/').last
|
137
|
+
directory = output_file.sub("/#{to_cut}", '')
|
138
|
+
FileUtils.mkdir directory unless File.directory? directory
|
139
|
+
file = File.new(output_file, Cucumber.file_mode('w'))
|
140
|
+
file.puts renderer.render(:file => filename, :locals => {:feature => feature})
|
141
|
+
file.flush
|
142
|
+
file.close
|
143
|
+
end
|
144
|
+
|
145
|
+
def make_output_directories
|
146
|
+
make_directory 'images'
|
147
|
+
make_directory 'stylesheets'
|
148
|
+
end
|
149
|
+
|
150
|
+
def make_directory(dir)
|
151
|
+
path = "#{File.dirname(@path)}/#{dir}"
|
92
152
|
FileUtils.mkdir path unless File.directory? path
|
93
|
-
|
94
|
-
|
153
|
+
end
|
154
|
+
|
155
|
+
def copy_directory(dir, file_names, file_extension)
|
156
|
+
path = "#{File.dirname(@path)}/#{dir}"
|
157
|
+
file_names.each do |file|
|
158
|
+
FileUtils.cp File.join(File.dirname(__FILE__), '..', 'templates', "#{file}.#{file_extension}"), path
|
95
159
|
end
|
96
160
|
end
|
97
161
|
|
98
|
-
def
|
99
|
-
|
100
|
-
|
162
|
+
def copy_images_directory
|
163
|
+
copy_directory 'images', ['face'], 'jpg'
|
164
|
+
copy_directory 'images', %w(failed passed pending undefined skipped), "png"
|
101
165
|
end
|
102
166
|
|
103
|
-
def
|
104
|
-
|
167
|
+
def copy_stylesheets_directory
|
168
|
+
copy_directory 'stylesheets', ['style'], 'css'
|
105
169
|
end
|
106
170
|
|
107
|
-
def
|
108
|
-
|
109
|
-
process_example_row(example_row)
|
110
|
-
end
|
111
|
-
@outline_steps = []
|
171
|
+
def process_scenario(scenario)
|
172
|
+
@report.current_scenario.populate(scenario)
|
112
173
|
end
|
113
174
|
|
114
|
-
def process_step(step)
|
115
|
-
|
116
|
-
|
117
|
-
|
175
|
+
def process_step(step, status=nil)
|
176
|
+
duration = Time.now - @step_timer
|
177
|
+
report_step = ReportStep.new(step)
|
178
|
+
report_step.duration = duration
|
179
|
+
report_step.status = status unless status.nil?
|
180
|
+
if step.background?
|
181
|
+
@report.current_feature.background << report_step if @report.processing_background_steps?
|
118
182
|
else
|
119
|
-
@report.add_step
|
183
|
+
@report.add_step report_step
|
120
184
|
end
|
185
|
+
report_step
|
121
186
|
end
|
122
187
|
|
123
188
|
def scenario_outline?(feature_element)
|
124
189
|
feature_element.is_a? Cucumber::Ast::ScenarioOutline
|
125
190
|
end
|
126
191
|
|
192
|
+
def info_row?(example_row)
|
193
|
+
return example_row.scenario_outline.nil? if example_row.respond_to? :scenario_outline
|
194
|
+
return true if example_row.instance_of? Cucumber::Ast::Table::Cells
|
195
|
+
false
|
196
|
+
end
|
197
|
+
|
127
198
|
def step_belongs_to_outline?(step)
|
128
199
|
scenario = step.instance_variable_get "@feature_element"
|
129
200
|
not scenario.nil?
|
130
201
|
end
|
131
202
|
|
132
|
-
def
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
203
|
+
def build_scenario_outline_steps(example_row)
|
204
|
+
si = example_row.instance_variable_get :@step_invocations
|
205
|
+
si.each do |row|
|
206
|
+
process_step(row, row.status)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def step_error(exception, step)
|
211
|
+
return nil if exception.nil?
|
212
|
+
exception.backtrace[-1] =~ /^#{step.file_colon_line}/ ? exception : nil
|
213
|
+
end
|
214
|
+
|
215
|
+
def populate_cells(example_row)
|
216
|
+
@cells ||= []
|
217
|
+
values = []
|
218
|
+
example_row.to_a.each do |cell|
|
219
|
+
values << cell.value
|
220
|
+
end
|
221
|
+
@cells << values
|
137
222
|
end
|
138
223
|
end
|
139
224
|
end
|