guard-cucumber 1.2.2 → 1.3.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/README.md +16 -1
- data/lib/guard/cucumber.rb +1 -0
- data/lib/guard/cucumber/focuser.rb +81 -0
- data/lib/guard/cucumber/inspector.rb +2 -2
- data/lib/guard/cucumber/runner.rb +7 -5
- data/lib/guard/cucumber/version.rb +1 -1
- metadata +20 -6
data/README.md
CHANGED
@@ -102,6 +102,11 @@ Former `:color`, `:drb`, `:port` and `:profile` options are thus deprecated and
|
|
102
102
|
# other shell script.
|
103
103
|
# The example generates: 'xvfb-run bundle exec cucumber ...'
|
104
104
|
# default: nil
|
105
|
+
|
106
|
+
:focus_on => 'dev' # Focus on scenarios tagged with '@dev'
|
107
|
+
# If '@dev' is on line 6 in 'foo.feature',
|
108
|
+
# this example runs: 'bundle exec cucumber foo.feature:6'
|
109
|
+
# default: nil
|
105
110
|
```
|
106
111
|
|
107
112
|
## Cucumber configuration
|
@@ -165,6 +170,16 @@ end
|
|
165
170
|
|
166
171
|
There is a section with alternative configurations on the [Wiki](https://github.com/netzpirat/guard-cucumber/wiki/Spork-configurations).
|
167
172
|
|
173
|
+
## Cucumber with Zeus
|
174
|
+
|
175
|
+
To use Guard::Cucumber with [Zeus](https://github.com/burke/zeus), just set the command prefix:
|
176
|
+
```
|
177
|
+
guard 'cucumber', :cli => '--format progress --no-profile', :command_prefix => 'zeus' do
|
178
|
+
...
|
179
|
+
end
|
180
|
+
```
|
181
|
+
You may also want to set `:bundler => false` to avoid using Bundler, as recommended in the Zeus documenation.
|
182
|
+
|
168
183
|
Issues
|
169
184
|
------
|
170
185
|
|
@@ -206,7 +221,7 @@ and follow [@netzpirat](https://twitter.com/#!/netzpirat) on Twitter for project
|
|
206
221
|
|
207
222
|
## Contributors
|
208
223
|
|
209
|
-
See the GitHub list of [contributors](https://github.com/netzpirat/guard-
|
224
|
+
See the GitHub list of [contributors](https://github.com/netzpirat/guard-cucumber/contributors).
|
210
225
|
|
211
226
|
Since guard-cucumber is very close to guard-rspec, some contributions by the following authors have been
|
212
227
|
incorporated into guard-cucumber:
|
data/lib/guard/cucumber.rb
CHANGED
@@ -0,0 +1,81 @@
|
|
1
|
+
module Guard
|
2
|
+
class Cucumber
|
3
|
+
|
4
|
+
# The Cucumber focuser updates cucumber feature paths to
|
5
|
+
# focus on sections tagged with a provided focus_tag.
|
6
|
+
#
|
7
|
+
# For example, if the `foo.feature` file has the provided focus tag
|
8
|
+
# `@bar` on line 8, then the path will be updated using the cucumber
|
9
|
+
# syntax for focusing on a section:
|
10
|
+
#
|
11
|
+
# foo.feature:8
|
12
|
+
#
|
13
|
+
# If '@bar' is found on lines 8 and 16, the path is updated as follows:
|
14
|
+
#
|
15
|
+
# foo.feature:8:16
|
16
|
+
#
|
17
|
+
# The path is not updated if it does not contain the focus tag.
|
18
|
+
#
|
19
|
+
module Focuser
|
20
|
+
class << self
|
21
|
+
|
22
|
+
# Focus the supplied paths using the provided focus tag.
|
23
|
+
#
|
24
|
+
# @param [Array<String>] paths the locations of the feature files
|
25
|
+
# @param [String] focus_tag the focus tag to look for in each path
|
26
|
+
# @return [Array<String>] the updated paths
|
27
|
+
#
|
28
|
+
def focus(paths, focus_tag)
|
29
|
+
return false if paths.empty?
|
30
|
+
|
31
|
+
paths.inject([]) do |updated_paths, path|
|
32
|
+
focused_line_numbers = scan_path_for_focus_tag(path, focus_tag)
|
33
|
+
|
34
|
+
unless focused_line_numbers.empty?
|
35
|
+
updated_paths << append_line_numbers_to_path(
|
36
|
+
focused_line_numbers, path
|
37
|
+
)
|
38
|
+
else
|
39
|
+
updated_paths << path
|
40
|
+
end
|
41
|
+
|
42
|
+
updated_paths
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Checks to see if the file at path contains the focus tag
|
47
|
+
#
|
48
|
+
# @param [String] path the file path to search
|
49
|
+
# @param [String] focus_tag the focus tag to look for in each path
|
50
|
+
# @return [Array<Integer>] the line numbers that include the focus tag in path
|
51
|
+
#
|
52
|
+
def scan_path_for_focus_tag(path, focus_tag)
|
53
|
+
line_numbers = []
|
54
|
+
|
55
|
+
File.open(path, 'r') do |f|
|
56
|
+
while (line = f.gets)
|
57
|
+
if line.include?(focus_tag)
|
58
|
+
line_numbers << f.lineno
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
line_numbers
|
64
|
+
end
|
65
|
+
|
66
|
+
# Appends the line numbers to the path
|
67
|
+
#
|
68
|
+
# @param [Array<Integer>] line_numbers the line numbers to append to the path
|
69
|
+
# @param [String] path the path that will receive the appended line numbers
|
70
|
+
# @return [String] the string containing the path appended with the line number
|
71
|
+
#
|
72
|
+
def append_line_numbers_to_path(line_numbers, path)
|
73
|
+
line_numbers.each { |num| path += ':' + num.to_s }
|
74
|
+
|
75
|
+
path
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -27,7 +27,7 @@ module Guard
|
|
27
27
|
|
28
28
|
# Tests if the file is the features folder.
|
29
29
|
#
|
30
|
-
# @param [String]
|
30
|
+
# @param [String] path the file
|
31
31
|
# @param [Array<String>] feature_sets the feature sets
|
32
32
|
# @return [Boolean] when the file is the feature folder
|
33
33
|
#
|
@@ -37,7 +37,7 @@ module Guard
|
|
37
37
|
|
38
38
|
# Tests if the file is valid.
|
39
39
|
#
|
40
|
-
# @param [String]
|
40
|
+
# @param [String] path the file
|
41
41
|
# @param [Array<String>] feature_sets the feature sets
|
42
42
|
# @return [Boolean] when the file valid
|
43
43
|
#
|
@@ -21,6 +21,8 @@ module Guard
|
|
21
21
|
return false if paths.empty?
|
22
22
|
|
23
23
|
message = options[:message] || (paths == ['features'] ? "Running all Cucumber features: #{ cucumber_command(paths, options) }" : "Running Cucumber features: #{ cucumber_command(paths, options) }")
|
24
|
+
paths = options[:focus_on] ? Focuser.focus(paths, options[:focus_on]) : paths
|
25
|
+
|
24
26
|
UI.info message, :reset => true
|
25
27
|
|
26
28
|
system(cucumber_command(paths, options))
|
@@ -41,7 +43,7 @@ module Guard
|
|
41
43
|
def cucumber_command(paths, options)
|
42
44
|
cmd = []
|
43
45
|
cmd << options[:command_prefix] if options[:command_prefix]
|
44
|
-
cmd << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].is_a?(Array)
|
46
|
+
cmd << "rvm #{ options[:rvm].join(',') } exec" if options[:rvm].is_a?(Array)
|
45
47
|
cmd << 'bundle exec' if (bundler? && options[:bundler] != false) || (bundler? && options[:binstubs].is_a?(TrueClass))
|
46
48
|
cmd << cucumber_exec(options)
|
47
49
|
cmd << options[:cli] if options[:cli]
|
@@ -49,9 +51,9 @@ module Guard
|
|
49
51
|
if options[:notification] != false
|
50
52
|
notification_formatter_path = File.expand_path(File.join(File.dirname(__FILE__), 'notification_formatter.rb'))
|
51
53
|
cmd << "--require #{ notification_formatter_path }"
|
52
|
-
cmd <<
|
54
|
+
cmd << '--format Guard::Cucumber::NotificationFormatter'
|
53
55
|
cmd << "--out #{ null_device }"
|
54
|
-
cmd << (options[:feature_sets] || ['features']).map {|path| "--require #{path}"}.join(' ')
|
56
|
+
cmd << (options[:feature_sets] || ['features']).map {|path| "--require #{ path }"}.join(' ')
|
55
57
|
end
|
56
58
|
|
57
59
|
(cmd + paths).join(' ')
|
@@ -62,7 +64,7 @@ module Guard
|
|
62
64
|
# @return [String] Cucumber executable
|
63
65
|
#
|
64
66
|
def cucumber_exec(options = {})
|
65
|
-
options[:binstubs] == true && ( bundler? || options[:bundler] != false ) ?
|
67
|
+
options[:binstubs] == true && ( bundler? || options[:bundler] != false ) ? 'bin/cucumber' : 'cucumber'
|
66
68
|
end
|
67
69
|
|
68
70
|
# Simple test if bundler should be used. it just checks for the `Gemfile`.
|
@@ -70,7 +72,7 @@ module Guard
|
|
70
72
|
# @return [Boolean] bundler exists
|
71
73
|
#
|
72
74
|
def bundler?
|
73
|
-
@bundler ||= File.exist?("#{Dir.pwd}/Gemfile")
|
75
|
+
@bundler ||= File.exist?("#{ Dir.pwd }/Gemfile")
|
74
76
|
end
|
75
77
|
|
76
78
|
# Returns a null device for all OS.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: guard
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: 1.2.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: bundler
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.1'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.1'
|
46
62
|
description: Guard::Cucumber automatically run your features (much like autotest)
|
47
63
|
email:
|
48
64
|
- michi@netzpiraten.ch
|
@@ -50,6 +66,7 @@ executables: []
|
|
50
66
|
extensions: []
|
51
67
|
extra_rdoc_files: []
|
52
68
|
files:
|
69
|
+
- lib/guard/cucumber/focuser.rb
|
53
70
|
- lib/guard/cucumber/inspector.rb
|
54
71
|
- lib/guard/cucumber/notification_formatter.rb
|
55
72
|
- lib/guard/cucumber/runner.rb
|
@@ -71,9 +88,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
88
|
- - ! '>='
|
72
89
|
- !ruby/object:Gem::Version
|
73
90
|
version: '0'
|
74
|
-
segments:
|
75
|
-
- 0
|
76
|
-
hash: 646156643643387503
|
77
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
92
|
none: false
|
79
93
|
requirements:
|
@@ -82,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
96
|
version: 1.3.6
|
83
97
|
requirements: []
|
84
98
|
rubyforge_project: guard-cucumber
|
85
|
-
rubygems_version: 1.8.
|
99
|
+
rubygems_version: 1.8.23
|
86
100
|
signing_key:
|
87
101
|
specification_version: 3
|
88
102
|
summary: Guard plugin for Cucumber
|