guard-cucumber 0.1.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.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Michael Kessler
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,52 @@
1
+ = Guard::Cucumber
2
+
3
+ CoffeeScript guard allows to automatically launch Cucumber features when files are modified.
4
+
5
+ - Tested on Ruby 1.8.7 & 1.9.2.
6
+
7
+ == Install
8
+
9
+ Please be sure to have {guard}[http://github.com/guard/guard] installed before continue.
10
+
11
+ Install the gem:
12
+
13
+ gem install guard-cucumber
14
+
15
+ Add it to your Gemfile (inside test group):
16
+
17
+ gem 'guard-cucumber'
18
+
19
+ Add guard definition to your Guardfile by running this command:
20
+
21
+ guard init cucumber
22
+
23
+ == Usage
24
+
25
+ Please read {guard usage doc}[http://github.com/guard/guard#readme]
26
+
27
+ == Guardfile
28
+
29
+ Cucumber guard can be really be adapated to all kind of projects.
30
+ Please read {guard doc}[http://github.com/guard/guard#readme] for more info about Guardfile DSL.
31
+
32
+ guard 'cucumber' do
33
+ watch('^features/(.*).feature')
34
+ watch('^features/support') { 'features' }
35
+ watch('^features/step_definitions') { 'features' }
36
+ end
37
+
38
+ == Development
39
+
40
+ - Source hosted at {GitHub}[http://github.com/netzpirat/guard-cucumber]
41
+ - Report issues/Questions/Feature requests on {GitHub Issues}[http://github.com/netzpirat/guard-cucumber/issues]
42
+
43
+ Pull requests are very welcome! Make sure your patches are well tested.
44
+
45
+ == Authors
46
+
47
+ {Michael Kessler}[http://github.com/netzpirat]
48
+
49
+ == Kudo
50
+
51
+ Many thanks to {Thibaud Guillaume-Gentil}[http://github.com/thibaudgg] for creating the excellent {guard}[http://github.com/guard/guard]
52
+ gem.
@@ -0,0 +1,20 @@
1
+ require 'guard'
2
+ require 'guard/guard'
3
+
4
+ module Guard
5
+ class Cucumber < Guard
6
+
7
+ autoload :Runner, 'guard/cucumber/runner'
8
+ autoload :Inspector, 'guard/cucumber/inspector'
9
+
10
+ def run_all
11
+ Runner.run ['features'], :message => 'Run all Cucumber features'
12
+ end
13
+
14
+ def run_on_change(paths)
15
+ paths = Inspector.clean(paths)
16
+ Runner.run(paths, options) unless paths.empty?
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,41 @@
1
+ module Guard
2
+ class Cucumber
3
+ module Inspector
4
+ class << self
5
+
6
+ def clean(paths)
7
+ paths.uniq!
8
+ paths.compact!
9
+ paths = paths.select { |p| cucumber_file?(p) || cucumber_folder?(p) }
10
+ paths = paths.delete_if { |p| included_in_other_path?(p, paths) }
11
+ clear_cucumber_files_list
12
+ paths
13
+ end
14
+
15
+ private
16
+
17
+ def cucumber_folder?(path)
18
+ path.match(/^\/?features/) && !path.match(/\..+$/)
19
+ end
20
+
21
+ def cucumber_file?(path)
22
+ cucumber_files.include?(path)
23
+ end
24
+
25
+ def cucumber_files
26
+ @cucumber_files ||= Dir.glob('features/**/*.feature')
27
+ end
28
+
29
+ def clear_cucumber_files_list
30
+ @cucumber_files = nil
31
+ end
32
+
33
+ def included_in_other_path?(path, paths)
34
+ paths = paths.select { |p| p != path }
35
+ paths.any? { |p| path.include?(p) && (path.gsub(p, '')).include?('/') }
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,56 @@
1
+ require 'open3'
2
+
3
+ module Guard
4
+ class Cucumber
5
+ module Runner
6
+ class << self
7
+ include Open3
8
+
9
+ def run(paths, options = {})
10
+ message = options[:message] || run_message(paths)
11
+ UI.info message, :reset => true
12
+
13
+ status, message = execute_cucumber(paths)
14
+ ::Guard::Notifier.notify(message, :title => 'Cucumber results', :image => (status == 0 ? :success : :failed))
15
+ end
16
+
17
+ private
18
+
19
+ def execute_cucumber(paths)
20
+ message = ''
21
+ status = 0
22
+
23
+ popen2e(cucumber_command(paths)) do |input, output, wait_thread|
24
+ input.close
25
+ while !output.eof?
26
+ line = output.readline
27
+ message << line if line =~ /^\d+ (steps|scenarios)/
28
+ puts line
29
+ end
30
+ status = wait_thread.value
31
+ end
32
+
33
+ [status, message.gsub(/\[\d+m\d*?/, '')]
34
+ end
35
+
36
+ def cucumber_command(paths)
37
+ cmd = []
38
+ cmd << 'bundle exec' if bundler?
39
+ cmd << 'cucumber'
40
+ cmd << '--color'
41
+ cmd = cmd + paths
42
+ cmd.join(' ')
43
+ end
44
+
45
+ def bundler?
46
+ @bundler ||= File.exist?("#{Dir.pwd}/Gemfile")
47
+ end
48
+
49
+ def run_message(paths)
50
+ paths == ['features'] ? 'Run all Cucumber features' : "Run Cucumber feature#{ paths.size == 1 ? '' : 's' } #{ paths.join(' ') }"
51
+ end
52
+
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,5 @@
1
+ guard 'cucumber' do
2
+ watch('^features/(.*).feature')
3
+ watch('^features/support') { 'features' }
4
+ watch('^features/step_definitions') { 'features' }
5
+ end
@@ -0,0 +1,5 @@
1
+ module Guard
2
+ module CucumberVersion
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-cucumber
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Michael Kessler
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-28 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: guard
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 19
30
+ segments:
31
+ - 0
32
+ - 2
33
+ - 2
34
+ version: 0.2.2
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: cucumber
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 63
46
+ segments:
47
+ - 0
48
+ - 9
49
+ - 2
50
+ version: 0.9.2
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: bundler
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 19
62
+ segments:
63
+ - 1
64
+ - 0
65
+ - 2
66
+ version: 1.0.2
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 13
78
+ segments:
79
+ - 2
80
+ - 0
81
+ - 1
82
+ version: 2.0.1
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: guard-rspec
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ hash: 19
94
+ segments:
95
+ - 0
96
+ - 1
97
+ - 4
98
+ version: 0.1.4
99
+ type: :development
100
+ version_requirements: *id005
101
+ description: Guard::Cucumber automatically run your features (much like autotest)
102
+ email:
103
+ - michi@netzpiraten.ch
104
+ executables: []
105
+
106
+ extensions: []
107
+
108
+ extra_rdoc_files: []
109
+
110
+ files:
111
+ - lib/guard/cucumber/inspector.rb
112
+ - lib/guard/cucumber/runner.rb
113
+ - lib/guard/cucumber/templates/Guardfile
114
+ - lib/guard/cucumber/version.rb
115
+ - lib/guard/cucumber.rb
116
+ - LICENSE
117
+ - README.rdoc
118
+ has_rdoc: true
119
+ homepage: http://github.com/netzpirat/guard-cucumber
120
+ licenses: []
121
+
122
+ post_install_message:
123
+ rdoc_options: []
124
+
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ hash: 3
133
+ segments:
134
+ - 0
135
+ version: "0"
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ hash: 23
142
+ segments:
143
+ - 1
144
+ - 3
145
+ - 6
146
+ version: 1.3.6
147
+ requirements: []
148
+
149
+ rubyforge_project: guard-cucumber
150
+ rubygems_version: 1.3.7
151
+ signing_key:
152
+ specification_version: 3
153
+ summary: Guard gem for Cucumber
154
+ test_files: []
155
+