guard-cucumber 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Guard::Cucumber
2
2
 
3
- Guard::Cucumber allows you to automatically run Cucumber features when files are modified. It is tested on Ruby 1.8.7 & 1.9.2.
3
+ Guard::Cucumber allows you to automatically run Cucumber features when files are modified.
4
+ It is tested on Ruby 1.8.7 & 1.9.2.
4
5
 
5
6
  ## Install
6
7
 
@@ -14,7 +15,7 @@ Add it to your `Gemfile`, preferably inside the test group:
14
15
 
15
16
  gem 'guard-cucumber'
16
17
 
17
- Add Guard definition to your `Guardfile` by running this command:
18
+ Add the default Guard::Cucumber template to your `Guardfile` by running this command:
18
19
 
19
20
  guard init cucumber
20
21
 
@@ -24,26 +25,40 @@ Please read the [Guard usage documentation](http://github.com/guard/guard#readme
24
25
 
25
26
  ## Guardfile
26
27
 
27
- Guard::Cucumber can be adapted to all kind of projects. Please read the
28
- [Guard documentation](http://github.com/guard/guard#readme) for more information about the Guardfile DSL.
28
+ Guard::Cucumber can be adapted to all kind of projects and comes with a default template that looks like this:
29
29
 
30
30
  guard 'cucumber' do
31
31
  watch(%r{features/.+\.feature})
32
- watch(%r{features/support/.+}) { 'features' }
33
- watch(%r{features/step_definitions/.+}) { 'features' }
32
+ watch(%r{features/support/.+}) { 'features' }
33
+ watch(%r{features/step_definitions/(.+)_steps\.rb}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
34
34
  end
35
35
 
36
+ Expressed in plain English, this configuration tells Guard::Cucumber:
37
+
38
+ 1. When a file within the features directory that ends in feature is modified, just run that single feature.
39
+ 2. When any file within features/support directory is modified, run all features.
40
+ 3. When a file within the features/step_definitions directory that ends in \_steps.rb is modified,
41
+ run the first feature that matches the name (\_steps.rb replaced by .feature) and when no feature is found,
42
+ then run all features.
43
+
44
+ Please read the [Guard documentation](http://github.com/guard/guard#readme) for more information about the Guardfile DSL.
45
+
36
46
  ## Options
37
47
 
38
- There are several options you can pass to Guard::Cucumber to customize the arguments when calling Cucumber:
48
+ You can pass any of the standard Cucumber CLI options using the :cli option:
49
+
50
+ guard 'cucumber', :cli => '-c --drb --port 1234 --profile custom' do
51
+ ...
52
+ end
53
+
54
+ Former `:color`, `:drb`, `:port` and `:profile` options are thus deprecated and have no effect anymore.
55
+
56
+ ### List of available options
39
57
 
40
- :color => false # Disable colored output
41
- :drb => true # Enable Spork DRb server
42
- :port => 1234 # Set custom Spork port
43
- :bundler => false # Don't use "bundle exec"
44
- :rvm => ['1.8.7', '1.9.2'] # Directly run your specs on multiple ruby
45
- :profile => 'cucumber_profile' # Let cucumber use another profile than the default one
46
- :command => 'whatever' # Pass any other command to cucumber
58
+ :cli => '-c -f pretty' # Pass arbitrary Cucumber CLI arguments, default: nil
59
+ :bundler => false # Don't use "bundle exec" to run the Cucumber command, default: true
60
+ :rvm => ['1.8.7', '1.9.2'] # Directly run your features on multiple ruby versions, default: nil
61
+ :notification => false # Don't display Growl (or Libnotify) notification, default: true
47
62
 
48
63
  ## Development
49
64
 
@@ -0,0 +1,44 @@
1
+ require 'guard'
2
+ require 'cucumber/formatter/console'
3
+
4
+ module Guard
5
+ class Cucumber
6
+ class NotificationFormatter
7
+ include ::Cucumber::Formatter::Console
8
+
9
+ attr_reader :step_mother
10
+
11
+ def initialize(step_mother, path_or_io, options)
12
+ @step_mother = step_mother
13
+ end
14
+
15
+ def after_features(features)
16
+ icon, messages = '', []
17
+ [:failed, :skipped, :undefined, :pending, :passed].reverse.each do |status|
18
+ if step_mother.steps(status).any?
19
+ icon = icon_for(status)
20
+ messages << dump_count(step_mother.steps(status).length, 'step', status.to_s)
21
+ end
22
+ end
23
+
24
+ ::Guard::Notifier.notify messages.reverse.join(', '), :title => 'Cucumber Results', :image => icon
25
+ end
26
+
27
+ private
28
+
29
+ def icon_for(status)
30
+ case status
31
+ when :passed
32
+ :success
33
+ when :pending, :undefined, :skipped
34
+ :pending
35
+ when :failed
36
+ :failed
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -1,5 +1,6 @@
1
1
  require 'cucumber'
2
- require 'guard/cucumber/cucumber_formatter'
2
+ require 'cucumber/formatter/progress'
3
+ require 'guard/cucumber/notification_formatter'
3
4
 
4
5
  module Guard
5
6
  class Cucumber
@@ -28,8 +29,11 @@ module Guard
28
29
  message = options[:message] || run_message(features)
29
30
  UI.info message, :reset => true
30
31
 
31
- formatter = CucumberFormatter.new(@runtime, $stdout, @configuration.instance_variable_get('@options'))
32
- runner = ::Cucumber::Ast::TreeWalker.new(@runtime, [formatter], @configuration)
32
+ formatters = [
33
+ NotificationFormatter.new(@runtime, $stdout, @configuration.instance_variable_get('@options')),
34
+ ::Cucumber::Formatter::Progress.new(@runtime, $stdout, @configuration.instance_variable_get('@options'))
35
+ ]
36
+ runner = ::Cucumber::Ast::TreeWalker.new(@runtime, formatters, @configuration)
33
37
  @runtime.visitor = runner
34
38
  loader = ::Cucumber::Runtime::FeaturesLoader.new(features, @configuration.filters, @configuration.tag_expression)
35
39
  runner.visit_features(loader.features)
@@ -12,37 +12,26 @@ module Guard
12
12
 
13
13
  def cucumber_command(paths, options)
14
14
  cmd = []
15
-
16
15
  cmd << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].is_a?(Array)
17
16
  cmd << 'bundle exec' if bundler? && options[:bundler] != false
18
17
 
19
18
  cmd << 'cucumber'
20
- cmd << "--profile #{options[:profile]}" if options[:profile]
21
- cmd << "--require #{ File.expand_path(File.join(File.dirname(__FILE__), '..', 'cucumber_formatter.rb')) } --format CucumberFormatter"
22
- cmd << '--color' if options[:color] != false
23
- cmd << "--drb" if options[:drb]
24
- cmd << "--port #{ options[:port] }" if options[:port] && options[:drb]
25
-
26
- if not require_command?(options)
27
- if options[:drb]
28
- cmd << "--require features/support"
29
- cmd << "--require features/step_definitions"
30
- else
31
- cmd << "--require features"
32
- end
19
+ cmd << options[:cli] if options[:cli]
20
+
21
+ if options[:notification] != false
22
+ cmd << "--require #{ File.expand_path(File.join(File.dirname(__FILE__), '..', 'notification_formatter.rb')) } --format Guard::Cucumber::NotificationFormatter --out #{ null_device }"
23
+ cmd << "--require features"
33
24
  end
34
25
 
35
- cmd << options[:command] if options[:command]
36
- cmd = cmd + paths
37
- cmd.join(' ')
26
+ (cmd + paths).join(' ')
38
27
  end
39
28
 
40
29
  def bundler?
41
30
  @bundler ||= File.exist?("#{Dir.pwd}/Gemfile")
42
31
  end
43
32
 
44
- def require_command?(options)
45
- !options[:command].nil? && options[:command] =~ /^--require/
33
+ def null_device
34
+ RUBY_PLATFORM.index('mswin') ? 'NUL' : '/dev/null'
46
35
  end
47
36
 
48
37
  end
@@ -1,5 +1,5 @@
1
1
  guard 'cucumber' do
2
2
  watch(%r{features/.+\.feature})
3
3
  watch(%r{features/support/.+}) { 'features' }
4
- watch(%r{features/step_definitions/.+}) { 'features' }
4
+ watch(%r{features/step_definitions/(.+)_steps\.rb}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module CucumberVersion
3
- VERSION = '0.2.4'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
4
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 4
10
- version: 0.2.4
5
+ version: 0.3.0
11
6
  platform: ruby
12
7
  authors:
13
8
  - Michael Kessler
@@ -15,7 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-03-14 00:00:00 +01:00
13
+ date: 2011-03-28 00:00:00 +02:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
@@ -26,11 +21,6 @@ dependencies:
26
21
  requirements:
27
22
  - - ~>
28
23
  - !ruby/object:Gem::Version
29
- hash: 19
30
- segments:
31
- - 0
32
- - 3
33
- - 0
34
24
  version: 0.3.0
35
25
  type: :runtime
36
26
  version_requirements: *id001
@@ -42,11 +32,6 @@ dependencies:
42
32
  requirements:
43
33
  - - ~>
44
34
  - !ruby/object:Gem::Version
45
- hash: 55
46
- segments:
47
- - 0
48
- - 10
49
- - 0
50
35
  version: 0.10.0
51
36
  type: :runtime
52
37
  version_requirements: *id002
@@ -58,11 +43,6 @@ dependencies:
58
43
  requirements:
59
44
  - - ~>
60
45
  - !ruby/object:Gem::Version
61
- hash: 3
62
- segments:
63
- - 1
64
- - 0
65
- - 10
66
46
  version: 1.0.10
67
47
  type: :development
68
48
  version_requirements: *id003
@@ -74,11 +54,6 @@ dependencies:
74
54
  requirements:
75
55
  - - ~>
76
56
  - !ruby/object:Gem::Version
77
- hash: 27
78
- segments:
79
- - 2
80
- - 5
81
- - 0
82
57
  version: 2.5.0
83
58
  type: :development
84
59
  version_requirements: *id004
@@ -90,11 +65,6 @@ dependencies:
90
65
  requirements:
91
66
  - - ~>
92
67
  - !ruby/object:Gem::Version
93
- hash: 23
94
- segments:
95
- - 0
96
- - 2
97
- - 0
98
68
  version: 0.2.0
99
69
  type: :development
100
70
  version_requirements: *id005
@@ -108,8 +78,8 @@ extensions: []
108
78
  extra_rdoc_files: []
109
79
 
110
80
  files:
111
- - lib/guard/cucumber/cucumber_formatter.rb
112
81
  - lib/guard/cucumber/inspector.rb
82
+ - lib/guard/cucumber/notification_formatter.rb
113
83
  - lib/guard/cucumber/runners/preload_runner.rb
114
84
  - lib/guard/cucumber/runners/runner.rb
115
85
  - lib/guard/cucumber/templates/Guardfile
@@ -131,25 +101,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
101
  requirements:
132
102
  - - ">="
133
103
  - !ruby/object:Gem::Version
134
- hash: 3
135
- segments:
136
- - 0
137
104
  version: "0"
138
105
  required_rubygems_version: !ruby/object:Gem::Requirement
139
106
  none: false
140
107
  requirements:
141
108
  - - ">="
142
109
  - !ruby/object:Gem::Version
143
- hash: 23
144
- segments:
145
- - 1
146
- - 3
147
- - 6
148
110
  version: 1.3.6
149
111
  requirements: []
150
112
 
151
113
  rubyforge_project: guard-cucumber
152
- rubygems_version: 1.6.1
114
+ rubygems_version: 1.6.2
153
115
  signing_key:
154
116
  specification_version: 3
155
117
  summary: Guard gem for Cucumber
@@ -1,33 +0,0 @@
1
- require 'guard'
2
- require 'cucumber/formatter/progress'
3
-
4
- class CucumberFormatter < Cucumber::Formatter::Progress
5
-
6
- def print_stats(features, profiles = [])
7
- super features, profiles
8
-
9
- icon, messages = '', []
10
- [:failed, :skipped, :undefined, :pending, :passed].reverse.each do |status|
11
- if step_mother.steps(status).any?
12
- icon = icon_for(status)
13
- messages << dump_count(step_mother.steps(status).length, 'step', status.to_s)
14
- end
15
- end
16
-
17
- ::Guard::Notifier.notify messages.reverse.join(', '), :title => 'Cucumber Results', :image => icon
18
- end
19
-
20
- private
21
-
22
- def icon_for(status)
23
- case status
24
- when :passed
25
- :success
26
- when :pending, :undefined, :skipped
27
- :pending
28
- when :failed
29
- :failed
30
- end
31
- end
32
-
33
- end