cucumber_growlnotify 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "bundler", "~> 1.0.0"
10
+ gem "jeweler", "~> 1.5.2"
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,16 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.5.2)
6
+ bundler (~> 1.0.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.8.7)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.0.0)
16
+ jeweler (~> 1.5.2)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Rodrigo Oliveira
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = cucumber_growlnotify
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to cucumber_growlnotify
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Rodrigo Oliveira. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,47 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "cucumber_growlnotify"
16
+ gem.homepage = "http://github.com/rodrigodealer/cucumber_growlnotify"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{This gem notifies throught growl that your cucumber tests are passing or not}
19
+ gem.description = %Q{This gem notifies throught growl that your cucumber tests are passing or not}
20
+ gem.email = "rodrigo.dealer@gmail.com"
21
+ gem.authors = ["Rodrigo Oliveira"]
22
+ gem.add_dependency "cucumber", "0.10.0"
23
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
24
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
25
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
26
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
27
+ end
28
+ Jeweler::RubygemsDotOrgTasks.new
29
+
30
+ require 'rake/testtask'
31
+ Rake::TestTask.new(:test) do |test|
32
+ test.libs << 'lib' << 'test'
33
+ test.pattern = 'test/**/test_*.rb'
34
+ test.verbose = true
35
+ end
36
+
37
+ task :default => :test
38
+
39
+ require 'rake/rdoctask'
40
+ Rake::RDocTask.new do |rdoc|
41
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
42
+
43
+ rdoc.rdoc_dir = 'rdoc'
44
+ rdoc.title = "cucumber_growlnotify #{version}"
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,243 @@
1
+ require 'fileutils'
2
+ require 'cucumber/formatter/console'
3
+ require 'cucumber/formatter/io'
4
+ require 'gherkin/formatter/escaping'
5
+
6
+ module Cucumber
7
+ module Formatter
8
+ class Growl
9
+ include FileUtils
10
+ include Console
11
+ include Io
12
+ include Gherkin::Formatter::Escaping
13
+ attr_writer :indent
14
+ attr_reader :step_mother
15
+
16
+ def initialize(step_mother, path_or_io, options)
17
+ @step_mother, @io, @options = step_mother, ensure_io(path_or_io, "pretty"), options
18
+ @exceptions = []
19
+ @indent = 0
20
+ @prefixes = options[:prefixes] || {}
21
+ @delayed_announcements = []
22
+ @passed = 0
23
+ @failure = 0
24
+ end
25
+
26
+ def after_features(features)
27
+ print_summary(features) unless @options[:autoformat]
28
+ end
29
+
30
+ def before_feature(feature)
31
+ @exceptions = []
32
+ @indent = 0
33
+ if @options[:autoformat]
34
+ file = File.join(@options[:autoformat], feature.file)
35
+ dir = File.dirname(file)
36
+ mkdir_p(dir) unless File.directory?(dir)
37
+ @io = ensure_file(file, "pretty")
38
+ end
39
+ end
40
+
41
+ def comment_line(comment_line)
42
+ @io.puts(comment_line.indent(@indent))
43
+ @io.flush
44
+ end
45
+
46
+ def after_tags(tags)
47
+ if @indent == 1
48
+ @io.puts
49
+ @io.flush
50
+ end
51
+ end
52
+
53
+ def tag_name(tag_name)
54
+ tag = format_string(tag_name, :tag).indent(@indent)
55
+ @io.print(tag)
56
+ @io.flush
57
+ @indent = 1
58
+ end
59
+
60
+ def feature_name(keyword, name)
61
+ @io.puts("#{keyword}: #{name}")
62
+ @io.puts
63
+ @io.flush
64
+ end
65
+
66
+ def before_feature_element(feature_element)
67
+ @indent = 2
68
+ @scenario_indent = 2
69
+ end
70
+
71
+ def after_feature_element(feature_element)
72
+ @io.puts
73
+ @io.flush
74
+ end
75
+
76
+ def before_background(background)
77
+ @indent = 2
78
+ @scenario_indent = 2
79
+ @in_background = true
80
+ end
81
+
82
+ def after_background(background)
83
+ @in_background = nil
84
+ @io.puts
85
+ @io.flush
86
+ end
87
+
88
+ def background_name(keyword, name, file_colon_line, source_indent)
89
+ print_feature_element_name(keyword, name, file_colon_line, source_indent)
90
+ end
91
+
92
+ def before_examples_array(examples_array)
93
+ @indent = 4
94
+ @io.puts
95
+ @visiting_first_example_name = true
96
+ end
97
+
98
+ def examples_name(keyword, name)
99
+ puts unless @visiting_first_example_name
100
+ @visiting_first_example_name = false
101
+ names = name.strip.empty? ? [name.strip] : name.split("\n")
102
+ @io.puts(" #{keyword}: #{names[0]}")
103
+ names[1..-1].each {|s| @io.puts " #{s}" } unless names.empty?
104
+ @io.flush
105
+ @indent = 6
106
+ @scenario_indent = 6
107
+ end
108
+
109
+ def before_outline_table(outline_table)
110
+ @table = outline_table
111
+ end
112
+
113
+ def after_outline_table(outline_table)
114
+ @table = nil
115
+ @indent = 4
116
+ end
117
+
118
+ def scenario_name(keyword, name, file_colon_line, source_indent)
119
+ print_feature_element_name(keyword, name, file_colon_line, source_indent)
120
+ end
121
+
122
+ def before_step(step)
123
+ @current_step = step
124
+ @indent = 6
125
+ end
126
+
127
+ def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
128
+ @hide_this_step = false
129
+ if exception
130
+ if @exceptions.include?(exception)
131
+ @hide_this_step = true
132
+ return
133
+ end
134
+ @exceptions << exception
135
+ end
136
+ if status != :failed && @in_background ^ background
137
+ @hide_this_step = true
138
+ return
139
+ end
140
+ @status = status
141
+ end
142
+
143
+ def step_name(keyword, step_match, status, source_indent, background)
144
+ return if @hide_this_step
145
+ source_indent = nil unless @options[:source]
146
+ name_to_report = format_step(keyword, step_match, status, source_indent)
147
+ @io.puts(name_to_report.indent(@scenario_indent + 2))
148
+ if status == :passed
149
+ @passed += 1
150
+ else
151
+ @failure += 1
152
+ end
153
+ print_announcements
154
+ end
155
+
156
+ def py_string(string)
157
+ return if @hide_this_step
158
+ s = %{"""\n#{string}\n"""}.indent(@indent)
159
+ s = s.split("\n").map{|l| l =~ /^\s+$/ ? '' : l}.join("\n")
160
+ @io.puts(format_string(s, @current_step.status))
161
+ @io.flush
162
+ end
163
+
164
+ def exception(exception, status)
165
+ return if @hide_this_step
166
+ print_exception(exception, status, @indent)
167
+ @io.flush
168
+ end
169
+
170
+ def before_multiline_arg(multiline_arg)
171
+ return if @options[:no_multiline] || @hide_this_step
172
+ @table = multiline_arg
173
+ end
174
+
175
+ def after_multiline_arg(multiline_arg)
176
+ @table = nil
177
+ end
178
+
179
+ def before_table_row(table_row)
180
+ return if !@table || @hide_this_step
181
+ @col_index = 0
182
+ @io.print ' |'.indent(@indent-2)
183
+ end
184
+
185
+ def after_table_row(table_row)
186
+ return if !@table || @hide_this_step
187
+ print_table_row_announcements
188
+ @io.puts
189
+ if table_row.exception && !@exceptions.include?(table_row.exception)
190
+ print_exception(table_row.exception, table_row.status, @indent)
191
+ end
192
+ end
193
+
194
+ def after_table_cell(cell)
195
+ return unless @table
196
+ @col_index += 1
197
+ end
198
+
199
+ def table_cell_value(value, status)
200
+ return if !@table || @hide_this_step
201
+ status ||= @status || :passed
202
+ width = @table.col_width(@col_index)
203
+ cell_text = escape_cell(value.to_s || '')
204
+ padded = cell_text + (' ' * (width - cell_text.unpack('U*').length))
205
+ prefix = cell_prefix(status)
206
+ @io.print(' ' + format_string("#{prefix}#{padded}", status) + ::Term::ANSIColor.reset(" |"))
207
+ @io.flush
208
+ end
209
+
210
+ private
211
+
212
+ def print_feature_element_name(keyword, name, file_colon_line, source_indent)
213
+ @io.puts if @scenario_indent == 6
214
+ names = name.empty? ? [name] : name.split("\n")
215
+ line = "#{keyword}: #{names[0]}".indent(@scenario_indent)
216
+ @io.print(line)
217
+ if @options[:source]
218
+ line_comment = " # #{file_colon_line}".indent(source_indent)
219
+ @io.print(format_string(line_comment, :comment))
220
+ end
221
+ @io.puts
222
+ names[1..-1].each {|s| @io.puts " #{s}"}
223
+ @io.flush
224
+ end
225
+
226
+ def cell_prefix(status)
227
+ @prefixes[status]
228
+ end
229
+
230
+ def growl(title, msg, pri=0, sticky="")
231
+ system "growlnotify -p 0 -n '#{title}' -m '#{msg}' #{title}"
232
+ end
233
+
234
+ def print_summary(features)
235
+ print_stats(features, @options.custom_profiles)
236
+ print_snippets(@options)
237
+ print_passing_wip(@options)
238
+ message = @passed.to_s + " steps passed \n" + @failure.to_s + " steps failed"
239
+ growl('Cucumber', message)
240
+ end
241
+ end
242
+ end
243
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'cucumber_growlnotify'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestCucumberGrowlnotify < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cucumber_growlnotify
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Rodrigo Oliveira
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-09 00:00:00 -03:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 1.0.0
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: jeweler
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 1.5.2
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: cucumber
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.10.0
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ description: This gem notifies throught growl that your cucumber tests are passing or not
50
+ email: rodrigo.dealer@gmail.com
51
+ executables: []
52
+
53
+ extensions: []
54
+
55
+ extra_rdoc_files:
56
+ - LICENSE.txt
57
+ - README.rdoc
58
+ files:
59
+ - .document
60
+ - Gemfile
61
+ - Gemfile.lock
62
+ - LICENSE.txt
63
+ - README.rdoc
64
+ - Rakefile
65
+ - VERSION
66
+ - lib/cucumber_growlnotify.rb
67
+ - test/helper.rb
68
+ - test/test_cucumber_growlnotify.rb
69
+ has_rdoc: true
70
+ homepage: http://github.com/rodrigodealer/cucumber_growlnotify
71
+ licenses:
72
+ - MIT
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: -833004313900545806
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: "0"
93
+ requirements: []
94
+
95
+ rubyforge_project:
96
+ rubygems_version: 1.6.2
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: This gem notifies throught growl that your cucumber tests are passing or not
100
+ test_files:
101
+ - test/helper.rb
102
+ - test/test_cucumber_growlnotify.rb