guard-cucumber 0.2.0 → 0.2.1

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.rdoc CHANGED
@@ -35,6 +35,17 @@ Please read {guard doc}[http://github.com/guard/guard#readme] for more info abou
35
35
  watch('^features/step_definitions') { 'features' }
36
36
  end
37
37
 
38
+ == Options
39
+
40
+ There are several options you can pass to the cucumber guard:
41
+
42
+ :color => false
43
+ :drb => true
44
+ :port => 1234
45
+ :bundler => false # don't use "bundle exec"
46
+ :rvm => ['1.8.7', '1.9.2'] # directly run your specs on multiple ruby
47
+ :preload => true # preload the cucumber environment (EXPERIMENTAL)
48
+
38
49
  == Development
39
50
 
40
51
  - Source hosted at {GitHub}[http://github.com/netzpirat/guard-cucumber]
@@ -5,37 +5,29 @@ require 'cucumber'
5
5
  module Guard
6
6
  class Cucumber < Guard
7
7
 
8
- autoload :Runner, 'guard/cucumber/runner'
9
- autoload :Inspector, 'guard/cucumber/inspector'
10
-
11
- attr_reader :configuration, :runtime
8
+ # Need to be an absolute path for the preload runner
9
+ autoload :Runner, File.expand_path(File.join(File.dirname(__FILE__), 'cucumber', 'runners', 'runner'))
10
+ autoload :PreloadRunner, File.expand_path(File.join(File.dirname(__FILE__), 'cucumber', 'runners', 'preload_runner'))
11
+ autoload :Inspector, File.expand_path(File.join(File.dirname(__FILE__), 'cucumber', 'inspector'))
12
12
 
13
13
  def start
14
- UI.info 'Preload cucumber environment. This could take a while...'
15
-
16
- @configuration = ::Cucumber::Cli::Configuration.new
17
- @runtime = ::Cucumber::Runtime.new(@configuration)
18
- @configuration.parse!(['features'])
19
-
20
- # Hack the support code, since loading the files takes most of the initialization time
21
- @support = ::Cucumber::Runtime::SupportCode.new(@runtime, @configuration)
22
- @support.load_files!(@configuration.support_to_load + @configuration.step_defs_to_load)
23
- @support.fire_hook(:after_configuration, @configuration)
24
- @runtime.instance_variable_set('@support_code', @support)
25
-
26
- UI.info 'Cucumber environment loaded.'
14
+ PreloadRunner.start if options[:preload]
27
15
  end
28
-
16
+
29
17
  def run_all
30
- configuration.parse!(['features'])
31
- Runner.run runtime, configuration, options.merge!({ :message => 'Run all Cucumber features' })
18
+ runner.run ['features'], options.merge!({ :message => 'Run all Cucumber features' })
32
19
  end
33
20
 
34
21
  def run_on_change(paths)
35
22
  paths = Inspector.clean(paths)
36
23
  options.merge!({ :message => 'Run all Cucumber features' }) if paths.include?('features')
37
- configuration.parse!(paths)
38
- Runner.run(runtime, configuration, options) unless paths.empty?
24
+ runner.run(paths, options) unless paths.empty?
25
+ end
26
+
27
+ private
28
+
29
+ def runner
30
+ options[:preload] ? PreloadRunner : Runner
39
31
  end
40
32
 
41
33
  end
@@ -1,3 +1,4 @@
1
+ require 'guard'
1
2
  require 'cucumber/formatter/progress'
2
3
 
3
4
  class CucumberFormatter < Cucumber::Formatter::Progress
@@ -0,0 +1,47 @@
1
+ require 'cucumber'
2
+ require 'guard/cucumber/cucumber_formatter'
3
+
4
+ module Guard
5
+ class Cucumber
6
+ module PreloadRunner
7
+ class << self
8
+ def start
9
+ UI.info '*** WARNING: Preload the Cucumber environment is known to have some issues with class reloading'
10
+ UI.info 'Preload cucumber environment. This could take a while...'
11
+
12
+ @configuration = ::Cucumber::Cli::Configuration.new
13
+ @runtime = ::Cucumber::Runtime.new(@configuration)
14
+ @configuration.parse!(['features'])
15
+
16
+ # Hack the support code, since loading the files takes most of the initialization time
17
+ @support = ::Cucumber::Runtime::SupportCode.new(@runtime, @configuration)
18
+ @support.load_files!(@configuration.support_to_load + @configuration.step_defs_to_load)
19
+ @support.fire_hook(:after_configuration, @configuration)
20
+ @runtime.instance_variable_set('@support_code', @support)
21
+
22
+ UI.info 'Cucumber environment loaded.'
23
+ end
24
+
25
+ def run(paths, options = {})
26
+ @configuration.parse!(paths)
27
+ features = @configuration.feature_files
28
+ message = options[:message] || run_message(features)
29
+ UI.info message, :reset => true
30
+
31
+ formatter = CucumberFormatter.new(@runtime, $stdout, @configuration.instance_variable_get('@options'))
32
+ runner = ::Cucumber::Ast::TreeWalker.new(@runtime, [formatter], @configuration)
33
+ @runtime.visitor = runner
34
+ loader = ::Cucumber::Runtime::FeaturesLoader.new(features, @configuration.filters, @configuration.tag_expression)
35
+ runner.visit_features(loader.features)
36
+ end
37
+
38
+ private
39
+
40
+ def run_message(paths)
41
+ paths == ['features'] ? 'Run all Cucumber features' : "Run Cucumber feature#{ paths.size == 1 ? '' : 's' } #{ paths.join(' ') }"
42
+ end
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,35 @@
1
+ module Guard
2
+ class Cucumber
3
+ module Runner
4
+ class << self
5
+ def run(paths, options = {})
6
+ message = options[:message] || (paths == ['features'] ? 'Run all Cucumber features' : "Run Cucumber features #{ paths.join(' ') }")
7
+ UI.info message, :reset => true
8
+ system(cucumber_command(paths, options))
9
+ end
10
+
11
+ private
12
+
13
+ def cucumber_command(paths, options)
14
+ cmd = []
15
+
16
+ cmd << "rvm #{options[:rvm].join(',')} exec" if options[:rvm].is_a?(Array)
17
+ cmd << 'bundle exec' if bundler? && options[:bundler] != false
18
+
19
+ cmd << 'cucumber'
20
+ cmd << "--require #{ File.expand_path(File.join(File.dirname(__FILE__), '..', 'cucumber_formatter.rb')) } --format CucumberFormatter"
21
+ cmd << '--color' if options[:color] != false
22
+ cmd << "--drb" if options[:drb]
23
+ cmd << "--port #{ options[:port] }" if options[:port] && options[:drb]
24
+ cmd << "--require features"
25
+ cmd = cmd + paths
26
+ cmd.join(' ')
27
+ end
28
+
29
+ def bundler?
30
+ @bundler ||= File.exist?("#{Dir.pwd}/Gemfile")
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,5 +1,5 @@
1
1
  module Guard
2
2
  module CucumberVersion
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Kessler
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-29 00:00:00 +02:00
18
+ date: 2010-11-10 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -42,12 +42,12 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 63
45
+ hash: 51
46
46
  segments:
47
47
  - 0
48
48
  - 9
49
- - 2
50
- version: 0.9.2
49
+ - 4
50
+ version: 0.9.4
51
51
  type: :runtime
52
52
  version_requirements: *id002
53
53
  - !ruby/object:Gem::Dependency
@@ -58,12 +58,12 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- hash: 19
61
+ hash: 17
62
62
  segments:
63
63
  - 1
64
64
  - 0
65
- - 2
66
- version: 1.0.2
65
+ - 3
66
+ version: 1.0.3
67
67
  type: :development
68
68
  version_requirements: *id003
69
69
  - !ruby/object:Gem::Dependency
@@ -74,12 +74,12 @@ dependencies:
74
74
  requirements:
75
75
  - - ~>
76
76
  - !ruby/object:Gem::Version
77
- hash: 13
77
+ hash: 11
78
78
  segments:
79
79
  - 2
80
- - 0
81
80
  - 1
82
- version: 2.0.1
81
+ - 0
82
+ version: 2.1.0
83
83
  type: :development
84
84
  version_requirements: *id004
85
85
  - !ruby/object:Gem::Dependency
@@ -90,12 +90,12 @@ dependencies:
90
90
  requirements:
91
91
  - - ~>
92
92
  - !ruby/object:Gem::Version
93
- hash: 19
93
+ hash: 11
94
94
  segments:
95
95
  - 0
96
96
  - 1
97
- - 4
98
- version: 0.1.4
97
+ - 8
98
+ version: 0.1.8
99
99
  type: :development
100
100
  version_requirements: *id005
101
101
  description: Guard::Cucumber automatically run your features (much like autotest)
@@ -110,7 +110,8 @@ extra_rdoc_files: []
110
110
  files:
111
111
  - lib/guard/cucumber/cucumber_formatter.rb
112
112
  - lib/guard/cucumber/inspector.rb
113
- - lib/guard/cucumber/runner.rb
113
+ - lib/guard/cucumber/runners/preload_runner.rb
114
+ - lib/guard/cucumber/runners/runner.rb
114
115
  - lib/guard/cucumber/templates/Guardfile
115
116
  - lib/guard/cucumber/version.rb
116
117
  - lib/guard/cucumber.rb
@@ -1,34 +0,0 @@
1
- require 'cucumber'
2
- require 'guard/cucumber/cucumber_formatter'
3
-
4
- module Guard
5
- class Cucumber
6
- module Runner
7
- class << self
8
-
9
- def run(runtime, configuration, options = {})
10
- features = configuration.feature_files
11
- message = options[:message] || run_message(features)
12
- UI.info message, :reset => true
13
-
14
- run_cucumber(features, runtime, configuration)
15
- end
16
-
17
- private
18
-
19
- def run_cucumber(features, runtime, configuration)
20
- formatter = CucumberFormatter.new(runtime, $stdout, configuration.instance_variable_get('@options'))
21
- runner = ::Cucumber::Ast::TreeWalker.new(runtime, [formatter], configuration)
22
- runtime.visitor = runner
23
- loader = ::Cucumber::Runtime::FeaturesLoader.new(features, configuration.filters, configuration.tag_expression)
24
- runner.visit_features(loader.features)
25
- end
26
-
27
- def run_message(paths)
28
- paths == ['features'] ? 'Run all Cucumber features' : "Run Cucumber feature#{ paths.size == 1 ? '' : 's' } #{ paths.join(' ') }"
29
- end
30
-
31
- end
32
- end
33
- end
34
- end