cucumber-nc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem 'rake'
7
+ gem 'rspec'
8
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jon Frisby, Odin Dutton
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # Cucumber Notification Center
2
+
3
+ cucumber-nc is a Cucumber formatter for Mountain Lion's Notification Center.
4
+
5
+ ## Installation
6
+
7
+ Installing cucumber-nc is easy. Just put it in your Gemfile
8
+ (`gem 'cucumber-nc'`) and run your features like this from now on:
9
+
10
+ ```
11
+ $ cucumber --format pretty --format CucumberNc --out /dev/null
12
+ ```
13
+
14
+ You will want to specify another formatter as cucumber-nc does not provide any
15
+ other output.
16
+
17
+ If you want to use cucumber-nc as your default formatter, simply put this option
18
+ in your cucumber.yml file:
19
+
20
+ ```
21
+ --format CucumberNc --out /dev/null
22
+ ```
23
+
24
+ ## Contributing
25
+
26
+ Found an issue? Have a great idea? Want to help? Great! Create an issue issue
27
+ for it, or even better; fork the project and fix the problem yourself. Pull
28
+ requests are always welcome. :)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |gem|
3
+ gem.name = 'cucumber-nc'
4
+ gem.version = '0.0.1'
5
+ gem.authors = ['Jon Frisby', 'Odin Dutton']
6
+ gem.email = ['jfrisby@mrjoy.com', 'odindutton@gmail.com']
7
+ gem.description = 'https://github.com/MrJoy/cucumber-nc'
8
+ gem.summary = "Cucumber formatter for Mountain Lion's Notification Center"
9
+ gem.homepage = 'https://github.com/MrJoy/cucumber-nc'
10
+
11
+ gem.add_dependency 'terminal-notifier', '~> 1.4.2'
12
+ gem.add_dependency 'cucumber', '~> 1.2'
13
+
14
+ gem.files = `git ls-files`.split($\)
15
+ gem.executables = []
16
+ gem.test_files = gem.files.grep(%r{^(spec)/})
17
+ gem.require_paths = ['lib']
18
+ end
@@ -0,0 +1,116 @@
1
+ require 'cucumber/formatter/duration'
2
+ require 'cucumber/formatter/io'
3
+ require 'terminal-notifier'
4
+
5
+ class CucumberNc
6
+ include Cucumber::Formatter::Duration
7
+ include Cucumber::Formatter::Io
8
+
9
+ attr_reader :step_mother
10
+ def initialize(step_mother, path_or_io, options)
11
+ @step_mother, @options = step_mother, options
12
+ end
13
+
14
+ def after_features(features)
15
+ print_summary(features)
16
+ end
17
+
18
+ def before_feature(feature); end
19
+ def comment_line(comment_line); end
20
+ def after_tags(tags); end
21
+ def tag_name(tag_name); end
22
+ def feature_name(keyword, name); end
23
+ def before_feature_element(feature_element); end
24
+ def after_feature_element(feature_element); end
25
+ def before_background(background); end
26
+ def after_background(background); end
27
+ def background_name(keyword, name, file_colon_line, source_indent); end
28
+ def before_examples_array(examples_array); end
29
+ def examples_name(keyword, name); end
30
+ def before_outline_table(outline_table); end
31
+ def after_outline_table(outline_table); end
32
+ def scenario_name(keyword, name, file_colon_line, source_indent); end
33
+ def before_step(step); end
34
+ def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line); end
35
+ def step_name(keyword, step_match, status, source_indent, background, file_colon_line); end
36
+ def doc_string(string); end
37
+ def exception(exception, status); end
38
+ def before_multiline_arg(multiline_arg); end
39
+ def after_multiline_arg(multiline_arg); end
40
+ def before_table_row(table_row); end
41
+ def after_table_row(table_row); end
42
+ def after_table_cell(cell); end
43
+ def table_cell_value(value, status); end
44
+
45
+ private
46
+
47
+ def pluralize(num, str)
48
+ (num == 1) ? str : "#{str}s"
49
+ end
50
+
51
+ def summary_line(features, failures)
52
+ scenarios = step_mother.scenarios.count
53
+ scenarios_failed = failures.count
54
+ scenarios_undefined = step_mother.scenarios(:undefined).count
55
+ scenarios_pending = step_mother.scenarios(:pending).count
56
+ scenarios_passing = step_mother.steps(:passed).count -
57
+ (scenarios_failed + scenarios_undefined + scenarios_pending)
58
+ steps = step_mother.steps.count
59
+ steps_failed = step_mother.steps(:failed).count
60
+ steps_skipped = step_mother.steps(:skipped).count
61
+ steps_undefined = step_mother.steps(:undefined).count
62
+ steps_pending = step_mother.steps(:pending).count
63
+ steps_passing = step_mother.steps(:passed).count
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
+ counts = []
73
+ counts << "#{scenarios_failed} fail" if(scenarios_failed > 0)
74
+ counts << "#{scenarios_undefined} undef" if(scenarios_undefined > 0)
75
+ counts << "#{scenarios_pending} pend" if(scenarios_pending > 0)
76
+ counts << "#{scenarios_passing} pass"
77
+
78
+ summary = "#{scenarios} #{pluralize(scenarios, "scenario")} (#{counts.join(', ')})\n\n"
79
+
80
+ counts = []
81
+ counts << "#{steps_failed} fail" if(steps_failed > 0)
82
+ counts << "#{steps_skipped} skip" if(steps_skipped > 0)
83
+ counts << "#{steps_undefined} undef" if(steps_undefined > 0)
84
+ counts << "#{steps_pending} pend" if(steps_pending > 0)
85
+ counts << "#{steps_passing} pass"
86
+
87
+ summary << "#{steps} #{pluralize(steps, "step")} (#{counts.join(', ')})"
88
+
89
+ summary
90
+ end
91
+
92
+ 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
+ body = []
99
+ body << "Finished in #{format_duration(features.duration)}"
100
+ body << summary_line(features, failures)
101
+
102
+ name = File.basename(File.expand_path('.'))
103
+
104
+ title = if(!failures.empty?)
105
+ "\u26D4 #{name}: #{failures.count} failed #{pluralize(failures.count, 'scenario')}"
106
+ else
107
+ "\u2705 #{name}: Success"
108
+ end
109
+
110
+ say title, body.join("\n")
111
+ end
112
+
113
+ def say(title, body)
114
+ TerminalNotifier.notify body, :title => title
115
+ end
116
+ end
@@ -0,0 +1,42 @@
1
+ require 'cucumber_nc'
2
+
3
+ describe CucumberNc do
4
+ let(:formatter) do
5
+ # TODO: Implement me....
6
+ #step_mocker =
7
+ CucumberNc.new(step_mocker, nil, nil)
8
+ end
9
+
10
+ let(:current_dir) { File.basename(File.expand_path '.') }
11
+
12
+ # emoji
13
+ let(:success) { "\u2705" }
14
+ let(:failure) { "\u26D4" }
15
+
16
+ it 'returns the summary' do
17
+ TerminalNotifier.should_receive(:notify).with(
18
+ "Finished in 0.0001 seconds\n3 examples, 1 failure, 1 pending",
19
+ :title => "#{failure} #{current_dir}: 1 failed example"
20
+ )
21
+
22
+ formatter.dump_summary(0.0001, 3, 1, 1)
23
+ end
24
+
25
+ it 'returns a failing notification' do
26
+ TerminalNotifier.should_receive(:notify).with(
27
+ "Finished in 0.0001 seconds\n1 example, 1 failure",
28
+ :title => "#{failure} #{current_dir}: 1 failed example"
29
+ )
30
+
31
+ formatter.dump_summary(0.0001, 1, 1, 0)
32
+ end
33
+
34
+ it 'returns a success notification' do
35
+ TerminalNotifier.should_receive(:notify).with(
36
+ "Finished in 0.0001 seconds\n1 example, 0 failures",
37
+ :title => "#{success} #{current_dir}: Success"
38
+ )
39
+
40
+ formatter.dump_summary(0.0001, 1, 0, 0)
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cucumber-nc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jon Frisby
9
+ - Odin Dutton
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-08-26 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: terminal-notifier
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 1.4.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 1.4.2
31
+ - !ruby/object:Gem::Dependency
32
+ name: cucumber
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '1.2'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '1.2'
47
+ description: https://github.com/MrJoy/cucumber-nc
48
+ email:
49
+ - jfrisby@mrjoy.com
50
+ - odindutton@gmail.com
51
+ executables: []
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - Gemfile
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - cucumber-nc.gemspec
61
+ - lib/cucumber_nc.rb
62
+ - spec/cucumbernc_spec.rb
63
+ homepage: https://github.com/MrJoy/cucumber-nc
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.24
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Cucumber formatter for Mountain Lion's Notification Center
87
+ test_files:
88
+ - spec/cucumbernc_spec.rb
89
+ has_rdoc: