cucumber-nc 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -2
- data/CHANGELOG.md +11 -0
- data/Gemfile +3 -1
- data/cucumber-nc.gemspec +1 -1
- data/lib/cucumber_nc.rb +36 -32
- data/spec/cucumbernc_spec.rb +97 -13
- metadata +13 -19
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 56e1d5715e8e716553cda195cbe20cd572843ce1
|
4
|
+
data.tar.gz: 45588b64495e10b017451c202a03487e77babeda
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5b043be336b7bd257a351acedf9593a274bb4cd2493b95f78d0e96f2fadb1488a805ec329a3865e138f87859815b2557501b302d208e68ece00a4bb4c9c41006
|
7
|
+
data.tar.gz: 2a38bcaca654921809be05be739ab9f627e6ad4e881bca49f7f82735dd617d3b9aff5370e952eaea924b2a2bbf81830e96a50f3c4a8f365843a621b8cc1c2744
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Changes
|
2
|
+
|
3
|
+
## v0.0.2, 2014-04-02
|
4
|
+
|
5
|
+
* Add `pry` as a development dependency in Gemfile.
|
6
|
+
* Update `.gitignore` to be friendly to `RVM` et al.
|
7
|
+
* Merge pull request #1: "Update notification body and fix count of failed scenarios"
|
8
|
+
|
9
|
+
## v0.0.1, 2012-08-26
|
10
|
+
|
11
|
+
Initial release.
|
data/Gemfile
CHANGED
data/cucumber-nc.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |gem|
|
3
3
|
gem.name = 'cucumber-nc'
|
4
|
-
gem.version = '0.0.
|
4
|
+
gem.version = '0.0.2'
|
5
5
|
gem.authors = ['Jon Frisby', 'Odin Dutton']
|
6
6
|
gem.email = ['jfrisby@mrjoy.com', 'odindutton@gmail.com']
|
7
7
|
gem.description = 'https://github.com/MrJoy/cucumber-nc'
|
data/lib/cucumber_nc.rb
CHANGED
@@ -48,13 +48,13 @@ class CucumberNc
|
|
48
48
|
(num == 1) ? str : "#{str}s"
|
49
49
|
end
|
50
50
|
|
51
|
-
def summary_line(features
|
51
|
+
def summary_line(features)
|
52
52
|
scenarios = step_mother.scenarios.count
|
53
|
-
scenarios_failed =
|
53
|
+
scenarios_failed = step_mother.scenarios(:failed).count
|
54
54
|
scenarios_undefined = step_mother.scenarios(:undefined).count
|
55
55
|
scenarios_pending = step_mother.scenarios(:pending).count
|
56
|
-
scenarios_passing = step_mother.
|
57
|
-
|
56
|
+
scenarios_passing = step_mother.scenarios(:passed).count
|
57
|
+
|
58
58
|
steps = step_mother.steps.count
|
59
59
|
steps_failed = step_mother.steps(:failed).count
|
60
60
|
steps_skipped = step_mother.steps(:skipped).count
|
@@ -62,49 +62,53 @@ class CucumberNc
|
|
62
62
|
steps_pending = step_mother.steps(:pending).count
|
63
63
|
steps_passing = step_mother.steps(:passed).count
|
64
64
|
|
65
|
-
# 5 scenarios (1 undefined, 3 pending, 1 passed)
|
66
|
-
# 35 steps (23 skipped, 1 undefined, 3 pending, 8 passed)
|
67
|
-
# 0m0.024s
|
68
|
-
|
69
|
-
# 5 scenarios (1 undefined, 3 pending, 1 passed)
|
70
|
-
# 35 steps (26 skipped, 1 undefined, 3 pending, 5 passed)
|
71
|
-
|
72
65
|
counts = []
|
73
|
-
counts << "#{
|
74
|
-
counts << "#{
|
75
|
-
counts << "#{
|
76
|
-
counts << "#{scenarios_passing}
|
66
|
+
counts << "#{scenarios_undefined} undefined" if scenarios_undefined > 0
|
67
|
+
counts << "#{scenarios_pending} pending" if scenarios_pending > 0
|
68
|
+
counts << "#{scenarios_failed} failed" if scenarios_failed > 0
|
69
|
+
counts << "#{scenarios_passing} passed" if scenarios_passing > 0
|
77
70
|
|
78
|
-
|
71
|
+
# 5 scenarios (1 undefined, 3 pending, 1 passed)
|
72
|
+
case counts.count
|
73
|
+
when 4
|
74
|
+
summary = "#{scenarios} #{pluralize(scenarios, "scenario")} (#{counts[0]}, #{counts[1]}, #{counts[2]},\n#{counts[3]})\n"
|
75
|
+
else
|
76
|
+
summary = "#{scenarios} #{pluralize(scenarios, "scenario")} (#{counts.join(', ')})\n"
|
77
|
+
end
|
79
78
|
|
80
79
|
counts = []
|
81
|
-
counts << "#{
|
82
|
-
counts << "#{steps_skipped}
|
83
|
-
counts << "#{
|
84
|
-
counts << "#{
|
85
|
-
counts << "#{steps_passing}
|
80
|
+
counts << "#{steps_undefined} undefined" if steps_undefined > 0
|
81
|
+
counts << "#{steps_skipped} skipped" if steps_skipped > 0
|
82
|
+
counts << "#{steps_pending} pending" if steps_pending > 0
|
83
|
+
counts << "#{steps_failed} failed" if steps_failed > 0
|
84
|
+
counts << "#{steps_passing} passed" if steps_passing > 0
|
86
85
|
|
87
|
-
|
86
|
+
# 35 steps (23 skipped, 1 undefined, 3 pending, 8 passed)
|
87
|
+
case counts.count
|
88
|
+
when 4
|
89
|
+
summary << "#{steps} #{pluralize(steps, "step")} (#{counts[0]}, #{counts[1]}, #{counts[2]},\n#{counts[3]})"
|
90
|
+
when 5
|
91
|
+
summary << "#{steps} #{pluralize(steps, "step")} (#{counts[0]}, #{counts[1]}, #{counts[2]},\n#{counts[3]}, #{counts[4]})"
|
92
|
+
else
|
93
|
+
summary << "#{steps} #{pluralize(steps, "step")} (#{ counts.join(', ') })"
|
94
|
+
end
|
88
95
|
|
89
96
|
summary
|
90
97
|
end
|
91
98
|
|
92
99
|
def print_summary(features)
|
93
|
-
failures = step_mother.
|
94
|
-
scenarios(:failed).
|
95
|
-
select { |s| s.is_a?(Cucumber::Ast::Scenario) || s.is_a?(Cucumber::Ast::OutlineTable::ExampleRow) }.
|
96
|
-
collect { |s| (s.is_a?(Cucumber::Ast::OutlineTable::ExampleRow)) ? s.scenario_outline : s }
|
97
|
-
|
98
100
|
body = []
|
99
|
-
body <<
|
100
|
-
|
101
|
+
body << summary_line(features)
|
102
|
+
|
103
|
+
# 0m0.024s
|
104
|
+
body << "#{ format_duration(features.duration) }"
|
101
105
|
|
102
106
|
name = File.basename(File.expand_path('.'))
|
103
107
|
|
104
|
-
title =
|
105
|
-
"\u26D4 #{name}: #{
|
108
|
+
title = unless step_mother.scenarios(:failed).empty?
|
109
|
+
"\u26D4 #{ name }: #{ step_mother.scenarios(:failed).count } failed #{ pluralize(step_mother.scenarios(:failed).count, 'scenario') }"
|
106
110
|
else
|
107
|
-
"\u2705 #{name}: Success"
|
111
|
+
"\u2705 #{ name }: Success"
|
108
112
|
end
|
109
113
|
|
110
114
|
say title, body.join("\n")
|
data/spec/cucumbernc_spec.rb
CHANGED
@@ -1,9 +1,73 @@
|
|
1
1
|
require 'cucumber_nc'
|
2
|
+
require 'set'
|
3
|
+
require 'bigdecimal'
|
4
|
+
|
5
|
+
class Duration
|
6
|
+
attr_accessor :duration
|
7
|
+
def initialize(d)
|
8
|
+
@duration = BigDecimal.new(d, 4)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class StepMocker
|
13
|
+
ALLOWED_SCENARIO_STATUSES=Set.new([:passed, :pending, :undefined, :failed])
|
14
|
+
class << ALLOWED_SCENARIO_STATUSES; def to_s; self.to_a.join(", "); end; end
|
15
|
+
ALLOWED_STEP_STATUSES=Set.new([:passed, :pending, :undefined, :skipped, :failed])
|
16
|
+
class << ALLOWED_STEP_STATUSES; def to_s; self.to_a.join(", "); end; end
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
clear_mocks
|
20
|
+
end
|
21
|
+
|
22
|
+
def scenarios(status=nil)
|
23
|
+
return self.data.
|
24
|
+
select { |scenario| status.nil? || scenario[:status] == status }
|
25
|
+
end
|
26
|
+
|
27
|
+
def steps(status=nil)
|
28
|
+
return self.data.
|
29
|
+
map { |scenario| scenario[:steps] }.
|
30
|
+
flatten.
|
31
|
+
select { |step| status.nil? || step == status }
|
32
|
+
end
|
33
|
+
|
34
|
+
def clear_mocks
|
35
|
+
self.data = []
|
36
|
+
return self
|
37
|
+
end
|
38
|
+
|
39
|
+
def add_scenario(status)
|
40
|
+
raise ArgumentError.new("Scenario status must be one of: #{ALLOWED_SCENARIO_STATUSES}, got '#{status}'!") unless(ALLOWED_SCENARIO_STATUSES.include?(status))
|
41
|
+
scenario_mock = {
|
42
|
+
:status => status,
|
43
|
+
:steps => [],
|
44
|
+
}
|
45
|
+
|
46
|
+
class << scenario_mock[:steps]
|
47
|
+
def add_step(status)
|
48
|
+
raise ArgumentError.new("Step status must be one of: #{ALLOWED_STEP_STATUSES}, got '#{status}'!") unless(ALLOWED_STEP_STATUSES.include?(status))
|
49
|
+
self << status
|
50
|
+
return self
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
yield scenario_mock[:steps] if(block_given?)
|
55
|
+
|
56
|
+
self.data << scenario_mock
|
57
|
+
return self
|
58
|
+
end
|
59
|
+
|
60
|
+
protected
|
61
|
+
|
62
|
+
attr_accessor :data
|
63
|
+
end
|
2
64
|
|
3
65
|
describe CucumberNc do
|
66
|
+
let(:step_mocker) do
|
67
|
+
StepMocker.new
|
68
|
+
end
|
69
|
+
|
4
70
|
let(:formatter) do
|
5
|
-
# TODO: Implement me....
|
6
|
-
#step_mocker =
|
7
71
|
CucumberNc.new(step_mocker, nil, nil)
|
8
72
|
end
|
9
73
|
|
@@ -13,30 +77,50 @@ describe CucumberNc do
|
|
13
77
|
let(:success) { "\u2705" }
|
14
78
|
let(:failure) { "\u26D4" }
|
15
79
|
|
16
|
-
it '
|
80
|
+
it 'gives TerminalNotifier an accurate summary' do
|
81
|
+
step_mocker.
|
82
|
+
clear_mocks.
|
83
|
+
add_scenario(:failed) do |mock|
|
84
|
+
mock.add_step(:passed)
|
85
|
+
mock.add_step(:failed)
|
86
|
+
mock.add_step(:pending)
|
87
|
+
end
|
88
|
+
|
17
89
|
TerminalNotifier.should_receive(:notify).with(
|
18
|
-
"
|
19
|
-
:title => "#{failure} #{current_dir}: 1 failed
|
90
|
+
"1 scenario (1 failed)\n3 steps (1 pending, 1 failed, 1 passed)\n0.0m0.001s",
|
91
|
+
:title => "#{failure} #{current_dir}: 1 failed scenario"
|
20
92
|
)
|
21
93
|
|
22
|
-
formatter.
|
94
|
+
formatter.send(:print_summary, Duration.new(0.001))
|
23
95
|
end
|
24
96
|
|
25
|
-
it '
|
97
|
+
it 'properly indicates failure to TerminalNotifier' do
|
98
|
+
step_mocker.
|
99
|
+
clear_mocks.
|
100
|
+
add_scenario(:failed) do |mock|
|
101
|
+
mock.add_step(:failed)
|
102
|
+
end
|
103
|
+
|
26
104
|
TerminalNotifier.should_receive(:notify).with(
|
27
|
-
"
|
28
|
-
:title => "#{failure} #{current_dir}: 1 failed
|
105
|
+
"1 scenario (1 failed)\n1 step (1 failed)\n0.0m0.001s",
|
106
|
+
:title => "#{failure} #{current_dir}: 1 failed scenario"
|
29
107
|
)
|
30
108
|
|
31
|
-
formatter.
|
109
|
+
formatter.send(:print_summary, Duration.new(0.001))
|
32
110
|
end
|
33
111
|
|
34
|
-
it '
|
112
|
+
it 'properly indicates success to TerminalNotifier' do
|
113
|
+
step_mocker.
|
114
|
+
clear_mocks.
|
115
|
+
add_scenario(:passed) do |mock|
|
116
|
+
mock.add_step(:passed)
|
117
|
+
end
|
118
|
+
|
35
119
|
TerminalNotifier.should_receive(:notify).with(
|
36
|
-
"
|
120
|
+
"1 scenario (1 passed)\n1 step (1 passed)\n0.0m0.001s",
|
37
121
|
:title => "#{success} #{current_dir}: Success"
|
38
122
|
)
|
39
123
|
|
40
|
-
formatter.
|
124
|
+
formatter.send(:print_summary, Duration.new(0.001))
|
41
125
|
end
|
42
126
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cucumber-nc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jon Frisby
|
@@ -10,38 +9,34 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: terminal-notifier
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- - ~>
|
18
|
+
- - "~>"
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: 1.4.2
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- - ~>
|
25
|
+
- - "~>"
|
29
26
|
- !ruby/object:Gem::Version
|
30
27
|
version: 1.4.2
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: cucumber
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- - ~>
|
32
|
+
- - "~>"
|
37
33
|
- !ruby/object:Gem::Version
|
38
34
|
version: '1.2'
|
39
35
|
type: :runtime
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- - ~>
|
39
|
+
- - "~>"
|
45
40
|
- !ruby/object:Gem::Version
|
46
41
|
version: '1.2'
|
47
42
|
description: https://github.com/MrJoy/cucumber-nc
|
@@ -52,7 +47,8 @@ executables: []
|
|
52
47
|
extensions: []
|
53
48
|
extra_rdoc_files: []
|
54
49
|
files:
|
55
|
-
- .gitignore
|
50
|
+
- ".gitignore"
|
51
|
+
- CHANGELOG.md
|
56
52
|
- Gemfile
|
57
53
|
- LICENSE
|
58
54
|
- README.md
|
@@ -62,28 +58,26 @@ files:
|
|
62
58
|
- spec/cucumbernc_spec.rb
|
63
59
|
homepage: https://github.com/MrJoy/cucumber-nc
|
64
60
|
licenses: []
|
61
|
+
metadata: {}
|
65
62
|
post_install_message:
|
66
63
|
rdoc_options: []
|
67
64
|
require_paths:
|
68
65
|
- lib
|
69
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
67
|
requirements:
|
72
|
-
- -
|
68
|
+
- - ">="
|
73
69
|
- !ruby/object:Gem::Version
|
74
70
|
version: '0'
|
75
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
72
|
requirements:
|
78
|
-
- -
|
73
|
+
- - ">="
|
79
74
|
- !ruby/object:Gem::Version
|
80
75
|
version: '0'
|
81
76
|
requirements: []
|
82
77
|
rubyforge_project:
|
83
|
-
rubygems_version:
|
78
|
+
rubygems_version: 2.2.2
|
84
79
|
signing_key:
|
85
|
-
specification_version:
|
80
|
+
specification_version: 4
|
86
81
|
summary: Cucumber formatter for Mountain Lion's Notification Center
|
87
82
|
test_files:
|
88
83
|
- spec/cucumbernc_spec.rb
|
89
|
-
has_rdoc:
|