guard-cucumber 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -58,30 +58,51 @@ Former `:color`, `:drb`, `:port` and `:profile` options are thus deprecated and
58
58
 
59
59
  ### List of available options
60
60
 
61
- :cli => '--profile guard -c' # Pass arbitrary Cucumber CLI arguments, default: '--no-profile --color --format progress --strict'
62
- :bundler => false # Don't use "bundle exec" to run the Cucumber command, default: true
63
- :rvm => ['1.8.7', '1.9.2'] # Directly run your features on multiple ruby versions, default: nil
64
- :notification => false # Don't display Growl (or Libnotify) notification, default: true
65
- :all_after_pass => false # don't run all features after changed features pass, default: true
66
- :all_on_start => false # don't run all the features at startup, default: true
67
- :keep_failed => false # keep failed features until them pass, default: true
61
+ :cli => '--profile guard -c' # Pass arbitrary Cucumber CLI arguments,
62
+ # default: '--no-profile --color --format progress --strict'
63
+
64
+ :bundler => false # Don't use "bundle exec" to run the Cucumber command
65
+ # default: true
66
+
67
+ :rvm => ['1.8.7', '1.9.2'] # Directly run your features on multiple ruby versions
68
+ # default: nil
69
+
70
+ :notification => false # Don't display Growl (or Libnotify) notification
71
+ # default: true
72
+
73
+ :all_after_pass => false # don't run all features after changed features pass
74
+ # default: true
75
+
76
+ :all_on_start => false # don't run all the features at startup
77
+ # default: true
78
+
79
+ :keep_failed => false # keep failed features until them pass
80
+ # default: true
68
81
 
69
82
  ## Cucumber configuration
70
83
 
71
- It's **very important** that you understand how Cucumber get its configuration, because it's often the origin of
72
- strange behaviour of guard-cucumber, like running always all features instead of only the modified feature.
84
+ It's **very important** that you understand how Cucumber gets configured, because it's often the origin of
85
+ strange behavior of guard-cucumber.
73
86
 
74
87
  Cucumber uses [cucumber.yml](https://github.com/cucumber/cucumber/wiki/cucumber.yml) for defining profiles
75
- of specific run configurations. When you don't pass a specific profile to the `:cli` option, the configuration
76
- of the `default` profile is used.
88
+ of specific run configurations. When you pass configurations through the `:cli` option but don't include a
89
+ specific profile with `--profile`, then the configurations from the `default` profile are also used.
77
90
 
78
91
  For example, when you're using the default cucumber.yml generated by [cucumber-rails](https://github.com/cucumber/cucumber-rails),
79
92
  then the default profile forces guard-cucumber to always run all features, because it appends the `features` folder.
80
93
 
81
94
  ### Configure Cucumber solely from Guard
82
95
 
83
- If you want to configure Cucumber from Guard solely, then you should either pass `--no-profile` to the `:cli` option
84
- or remove cucumber.yml completely.
96
+ If you want to configure Cucumber from Guard solely, then you should pass `--no-profile` to the `:cli` option.
97
+
98
+ Since guard-cucumber version 0.3.2, the default `:cli` options are:
99
+
100
+ --no-profile --color --format progress --strict
101
+
102
+ This default configuration has been chosen to avoid strange behavior when mixing configurations form
103
+ the cucumber.yml default profile with the guard-cucumber `:cli` option.
104
+
105
+ You can safely remove `config/cucumber.yml`, since all configuration is done in the `Guardfile`.
85
106
 
86
107
  ### Use a separate Guard profile
87
108
 
@@ -48,11 +48,24 @@ module Guard
48
48
  run_all if @last_failed && @options[:all_after_pass]
49
49
  else
50
50
  # remember failed paths for the next change
51
- @failed_paths += paths if @options[:keep_failed]
51
+ @failed_paths += read_failed_features if @options[:keep_failed]
52
52
  # track whether the changed feature failed for the next change
53
53
  @last_failed = true
54
54
  end
55
55
  end
56
56
 
57
+ private
58
+
59
+ def read_failed_features
60
+ failed = []
61
+
62
+ if File.exist?('rerun.txt')
63
+ failed = File.open('rerun.txt').read.split(' ')
64
+ File.delete('rerun.txt')
65
+ end
66
+
67
+ failed
68
+ end
69
+
57
70
  end
58
71
  end
@@ -1,5 +1,6 @@
1
1
  require 'guard'
2
2
  require 'cucumber/formatter/console'
3
+ require 'cucumber/formatter/io'
3
4
 
4
5
  module Guard
5
6
  class Cucumber
@@ -9,13 +10,41 @@ module Guard
9
10
  attr_reader :step_mother
10
11
 
11
12
  def initialize(step_mother, path_or_io, options)
13
+ @options = options
14
+ @file_names = []
12
15
  @step_mother = step_mother
13
16
  end
14
17
 
15
18
  def after_features(features)
19
+ notify_summary
20
+ write_rerun_features
21
+ end
22
+
23
+ def before_feature_element(feature_element)
24
+ @rerun = false
25
+ @feature_name = feature_element.name
26
+ end
27
+
28
+ def after_feature_element(feature_element)
29
+ if @rerun
30
+ file, line = *feature_element.file_colon_line.split(':')
31
+ @file_names << file
32
+ end
33
+ end
34
+
35
+ def step_name(keyword, step_match, status, source_indent, background)
36
+ if [:failed, :pending, :undefined].index(status)
37
+ @rerun = true
38
+ step_name = step_match.format_args(lambda { |param| "*#{ param }*" })
39
+ ::Guard::Notifier.notify step_name, :title => @feature_name, :image => icon_for(status)
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def notify_summary
16
46
  icon, messages = '', []
17
47
 
18
- # summary of the run
19
48
  [:failed, :skipped, :undefined, :pending, :passed].reverse.each do |status|
20
49
  if step_mother.steps(status).any?
21
50
  icon = icon_for(status)
@@ -24,35 +53,25 @@ module Guard
24
53
  end
25
54
 
26
55
  ::Guard::Notifier.notify messages.reverse.join(', '), :title => 'Cucumber Results', :image => icon
56
+ end
27
57
 
28
- # details about failures, what to work on
29
- [:failed, :pending, :undefined].each do |status|
30
- if step_mother.steps(status).any?
31
- icon = icon_for(status)
32
- step_mother.steps(status).each do |step|
33
- ::Guard::Notifier.notify step.name, :title => "#{status} steps", :image => icon
34
- end
35
-
36
- break
37
- end
58
+ def write_rerun_features
59
+ File.open('rerun.txt', 'w') do |f|
60
+ f.puts @file_names.join(' ')
38
61
  end
39
62
  end
40
63
 
41
- private
42
-
43
64
  def icon_for(status)
44
65
  case status
45
- when :passed
46
- :success
47
- when :pending, :undefined, :skipped
48
- :pending
49
- when :failed
50
- :failed
66
+ when :passed
67
+ :success
68
+ when :pending, :undefined, :skipped
69
+ :pending
70
+ when :failed
71
+ :failed
51
72
  end
52
73
  end
53
74
 
54
75
  end
55
-
56
76
  end
57
-
58
77
  end
@@ -1,5 +1,5 @@
1
1
  guard 'cucumber' do
2
- watch(%r{features/.+\.feature})
3
- watch(%r{features/support/.+}) { 'features' }
4
- watch(%r{features/step_definitions/(.+)_steps\.rb}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
2
+ watch(%r{^features/.+\.feature$})
3
+ watch(%r{^features/support/.+$}) { '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.3.2'
3
+ VERSION = '0.3.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: guard-cucumber
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.2
5
+ version: 0.3.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Kessler
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-19 00:00:00 +02:00
13
+ date: 2011-06-06 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency