bumps 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ == 0.0.2 2009-09-03
2
+
3
+ * Compatibility with Cucumber 0.3.99 and above
4
+ * Uses AfterConfiguration hook instead of devious metaprogramming hijinx
5
+ * Compatability with Ruby 1.8.6
6
+
1
7
  == 0.0.1 2009-07-09
2
8
 
3
9
  * 1 major enhancement:
@@ -8,24 +8,23 @@ features/pull_remote_features.feature
8
8
  features/push_feature_results.feature
9
9
  features/steps/command_output.rb
10
10
  features/steps/cucumber_run.rb
11
- features/steps/env.rb
12
11
  features/steps/feature_report.rb
13
12
  features/steps/feature_server.rb
14
13
  features/steps/helpers/scenario_process.rb
14
+ features/support/env.rb
15
15
  lib/bumps.rb
16
16
  lib/bumps/configuration.rb
17
+ lib/bumps/cucumber_config.rb
17
18
  lib/bumps/feature.rb
18
- lib/bumps/hook_tasks.rb
19
- lib/bumps/pre_feature_load_hook.rb
20
19
  lib/bumps/remote_feature.rb
21
20
  lib/bumps/results_push_formatter.rb
21
+ lib/bumps_core.rb
22
22
  script/console
23
23
  script/destroy
24
24
  script/generate
25
25
  spec/bumps/configuration_spec.rb
26
+ spec/bumps/cucumber_config_spec.rb
26
27
  spec/bumps/feature_spec.rb
27
- spec/bumps/hook_tasks_spec.rb
28
- spec/bumps/pre_feature_load_hook_spec.rb
29
28
  spec/bumps/remote_feature_spec.rb
30
29
  spec/bumps/results_push_formatter_spec.rb
31
30
  spec/bumps_spec.rb
@@ -33,4 +32,4 @@ spec/spec.opts
33
32
  spec/spec_helper.rb
34
33
  tasks/rspec.rake
35
34
  test_features/remote_content/destroy_dr_thaddeus_venture.feature
36
- test_features/requires/env.rb
35
+ test_features/requires/support/env.rb
@@ -1,8 +1,10 @@
1
1
  = Bumps
2
2
 
3
3
  * http://github.com/brentsnook/bumps
4
+ * http://groups.google.com/group/bumps-for-cucumber
5
+ * http://fuglylogic.com/2009/07/20/bumps-remote-features-for-cucumber/
4
6
 
5
- Bumps shakes up {Cucumber}[http://cukes.info] by allowing you to pull feature content and push run results to and from a remote server. This means that your feature files no longer need to live with your steps and other code. This also means that you can publish the results of a Cucumber run to another system.
7
+ Bumps extends {Cucumber}[http://cukes.info] by allowing you to pull feature content and push run results to and from a remote server. This means that your feature files no longer need to live with your steps and other code. This also means that you can publish the results of a Cucumber run to another system.
6
8
 
7
9
  See the {wiki}[http://wiki.github.com/brentsnook/bumps] for more details.
8
10
 
@@ -22,7 +24,7 @@ Grab the code from github:
22
24
 
23
25
  First, start up a server that meets the {push/pull contract}[http://wiki.github.com/brentsnook/bumps/push-pull-contract].
24
26
 
25
- Secondly, bung this inside of your *env.rb* (or equivalent, just make sure it is under the feature directory):
27
+ Secondly, bung this inside of your <b>support/env.rb</b> (or equivalent, just make sure it is under a directory named <b>support</b> under the feature directory):
26
28
 
27
29
  require 'bumps'
28
30
  Bumps.configure { use_server 'http://mycompliantserver.com' }
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
2
- require File.dirname(__FILE__) + '/lib/bumps'
2
+ require File.expand_path(File.dirname(__FILE__) + '/lib/bumps_core')
3
3
 
4
4
  # Generate all the Rake tasks
5
5
  # Run 'rake -T' to see list of generated tasks (from gem root directory)
@@ -9,7 +9,7 @@ $hoe = Hoe.new('bumps', Bumps::VERSION) do |p|
9
9
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
10
10
  p.rubyforge_name = p.name
11
11
  p.extra_deps = [
12
- ['cucumber', ">= #{Bumps::LOWEST_SUPPORTED_CUCUMBER_VERSION}"],
12
+ ['cucumber', ">= 0.3.99"],
13
13
  ['nokogiri','>= 1.1.1'],
14
14
  ]
15
15
  p.extra_dev_deps = [
@@ -26,4 +26,5 @@ end
26
26
  require 'newgem/tasks' # load /tasks/*.rake
27
27
  Dir['tasks/**/*.rake'].each { |t| load t }
28
28
 
29
+ Rake::Task[:default].clear_prerequisites # clear out test-unit
29
30
  task :default => [:spec, :features]
data/TODO CHANGED
@@ -1,14 +1,14 @@
1
- - tag release
2
- - release gem on rubyforge
3
1
 
4
- - register google group and update wiki doco
2
+ --- 0.3.96 fix
5
3
 
4
+ - test with different ruby versions
6
5
 
7
- - add blog post on what it is, how to use it and why
6
+ - publish gem
7
+ - add to tools page on Cukes wiki
8
+ - announce on twitter, Bumps mailing list, Cukes mailing list, Wave list
8
9
 
9
- - publish on twitter
10
- - post to wave google group (links to blog)
11
- - post to cucumber google group (links to blog)
10
+ - delete fork
11
+
12
12
 
13
13
  --- LATER ---
14
14
 
@@ -17,4 +17,7 @@
17
17
  - can it be more of a synch than a straight clobber??? for speed mainly
18
18
  - extract process control logic out into a new gem
19
19
  - support obtaining details for a single feature ???
20
- - create lighthouse project
20
+
21
+
22
+
23
+
@@ -28,7 +28,7 @@ class PullServlet < HTTPServlet::AbstractServlet
28
28
 
29
29
  def feature_within file
30
30
  relative_path = file[(@options[0].length)..-1]
31
- "<feature name=\"#{relative_path}\"> #{IO.read(file)}\n </feature>"
31
+ "<feature name=\"#{relative_path}\"><![CDATA[#{IO.read(file)}\n]]></feature>"
32
32
  end
33
33
 
34
34
  def features_pattern
@@ -1,10 +1,3 @@
1
- require File.dirname(__FILE__) + "/../../lib/bumps"
2
-
3
- gem 'cucumber'
4
- require 'cucumber'
5
- gem 'rspec'
6
- require 'spec'
7
-
8
1
  module CucumberWorld
9
2
 
10
3
  def feature_report_file
@@ -32,7 +25,7 @@ module CucumberWorld
32
25
  end
33
26
 
34
27
  def test_require_file
35
- File.expand_path File.join(root, 'test_features', 'requires', 'env.rb')
28
+ File.expand_path File.join(root, 'test_features', 'requires', 'support', 'env.rb')
36
29
  end
37
30
 
38
31
  def test_features_directory
@@ -46,7 +39,7 @@ module CucumberWorld
46
39
  def each_feature
47
40
  Dir.glob("#{remote_features_directory}/**/*") do |feature_file|
48
41
  content = IO.read(feature_file).strip
49
- yield content.first.strip
42
+ yield content.split("\n").first.strip
50
43
  end
51
44
  end
52
45
 
@@ -1,25 +1,7 @@
1
- $:.unshift(File.dirname(__FILE__)) unless
2
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'bumps_core'))
3
2
 
4
- require 'rubygems'
5
- require 'cucumber'
6
-
7
- [
8
- 'remote_feature',
9
- 'feature',
10
- 'configuration',
11
- 'results_push_formatter',
12
- 'hook_tasks',
13
- 'pre_feature_load_hook'
14
- ].each {|file| require "bumps/#{file}"}
15
-
16
- module Bumps
17
-
18
- VERSION = '0.0.1'
19
- LOWEST_SUPPORTED_CUCUMBER_VERSION = '0.3.11'
20
-
21
- def self.configure &block
22
- Configuration.configure(&block)
23
- PreFeatureLoadHook.register_on Cucumber::Cli::Main
24
- end
3
+ # Cucumber hook
4
+ AfterConfiguration do |config|
5
+ Bumps::CucumberConfig.new(config).process!
6
+ Bumps::Feature.pull
25
7
  end
@@ -21,7 +21,8 @@ module Bumps
21
21
 
22
22
  def method_missing method, *args
23
23
  return @config[method] if @config.has_key?(method)
24
- method.to_s.end_with?('=') ? @config[method.to_s.chop.to_sym] = args[0] : super(method, args)
24
+ method_name = method.to_s
25
+ method_name =~ /=$/ ? @config[method_name.chop.to_sym] = args[0] : super(method, args)
25
26
  end
26
27
 
27
28
  def configure &block
@@ -0,0 +1,29 @@
1
+ module Bumps
2
+ class CucumberConfig
3
+
4
+ def initialize source_config
5
+ @source_config = source_config
6
+ end
7
+
8
+ def process!
9
+ validate
10
+ update_bumps_config
11
+ register_formatter
12
+ end
13
+
14
+ def validate
15
+ error_message = 'More than one feature directory/file was specified. ' +
16
+ 'Please only specify a single feature directory when using bumps'
17
+ raise error_message if @source_config.feature_dirs.size > 1
18
+ end
19
+
20
+ def update_bumps_config
21
+ Bumps::Configuration.feature_directory = @source_config.feature_dirs.first
22
+ Bumps::Configuration.output_stream = @source_config.out_stream
23
+ end
24
+
25
+ def register_formatter
26
+ @source_config.options[:formats] << ['Bumps::ResultsPushFormatter', Bumps::Configuration.output_stream]
27
+ end
28
+ end
29
+ end
@@ -35,7 +35,7 @@ module Bumps
35
35
  def absolute_path_under directory
36
36
  expanded_directory = File.expand_path directory
37
37
  file_path = File.expand_path(File.join(directory, name))
38
- unless file_path.start_with? expanded_directory
38
+ unless file_path =~ /^#{expanded_directory}/
39
39
  raise "Could not write feature to path #{file_path}, path is not below #{expanded_directory}"
40
40
  end
41
41
  file_path
@@ -5,7 +5,7 @@ require 'open-uri'
5
5
  module Bumps
6
6
 
7
7
  class RemoteFeature
8
-
8
+
9
9
  def self.fetch location
10
10
  parse(open(location){|f| f.read})
11
11
  end
@@ -18,6 +18,7 @@ module Bumps
18
18
  feature.name = feature_element.attribute('name').to_s
19
19
  feature
20
20
  end
21
- end
21
+ end
22
+
22
23
  end
23
24
  end
@@ -0,0 +1,22 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'rubygems'
5
+ require 'cucumber'
6
+
7
+ [
8
+ 'remote_feature',
9
+ 'feature',
10
+ 'configuration',
11
+ 'results_push_formatter',
12
+ 'cucumber_config'
13
+ ].each {|file| require "bumps/#{file}"}
14
+
15
+ module Bumps
16
+
17
+ VERSION = '0.0.2'
18
+
19
+ def self.configure &block
20
+ Configuration.configure(&block)
21
+ end
22
+ end
@@ -0,0 +1,77 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Bumps::CucumberConfig, 'processing' do
4
+ before do
5
+ @source_config = mock('source Cucumber config')
6
+ @config = Bumps::CucumberConfig.new @source_config
7
+ end
8
+
9
+ describe 'processing' do
10
+
11
+ it 'should validate cucumber configuration, update Bumps config then register formatter' do
12
+ @config.should_receive(:validate).ordered
13
+ @config.should_receive(:update_bumps_config).ordered
14
+ @config.should_receive(:register_formatter).ordered
15
+
16
+ @config.process!
17
+ end
18
+
19
+ end
20
+
21
+ describe 'validation' do
22
+
23
+ it 'should succeed if a single directory is specified' do
24
+ @source_config.stub!(:feature_dirs).and_return ['one']
25
+
26
+ lambda{ @config.validate }.should_not raise_error
27
+ end
28
+
29
+ it 'should fail if there is more than one feature directory specified' do
30
+ @source_config.stub!(:feature_dirs).and_return ['one', 'two']
31
+
32
+ lambda{ @config.validate }.should raise_error('More than one feature directory/file was specified. Please only specify a single feature directory when using bumps')
33
+ end
34
+
35
+ end
36
+
37
+ describe 'updating Bumps configuration' do
38
+
39
+ it 'should use fields from source Cucumber config' do
40
+ @source_config.stub!(:feature_dirs).and_return ['dir']
41
+ @source_config.stub!(:out_stream).and_return 'out stream'
42
+
43
+ Bumps::Configuration.should_receive(:output_stream=).with 'out stream'
44
+ Bumps::Configuration.should_receive(:feature_directory=).with 'dir'
45
+
46
+ @config.update_bumps_config
47
+ end
48
+
49
+ end
50
+
51
+ describe 'registering formatter' do
52
+
53
+ before do
54
+ # law of demeter seems like an even better idea after mocking a chain of three objects
55
+ @formats = mock 'formats'
56
+ options = mock 'options'
57
+ options.stub!(:[]).with(:formats).and_return @formats
58
+ @source_config.stub!(:options).and_return options
59
+ end
60
+
61
+ it 'should add the class name of the push formatter to the cucumber configuration' do
62
+ @formats.should_receive(:<<).with ['Bumps::ResultsPushFormatter', anything]
63
+
64
+ @config.register_formatter
65
+ end
66
+
67
+ it 'should use the configured output stream for output' do
68
+ output_stream = mock 'output stream'
69
+ Bumps::Configuration.stub!(:output_stream).and_return output_stream
70
+
71
+ @formats.should_receive(:<<).with [anything, output_stream]
72
+
73
+ @config.register_formatter
74
+ end
75
+ end
76
+
77
+ end
@@ -14,7 +14,7 @@ describe Bumps::Feature do
14
14
  Bumps::Configuration.stub!(:feature_directory).and_return 'feature_directory'
15
15
  Bumps::Configuration.stub!(:pull_url).and_return 'location'
16
16
 
17
- features = 3.times.collect do |index|
17
+ features = (1..3).collect do |index|
18
18
  feature = mock "feature #{index}"
19
19
  feature.should_receive(:write_to).with 'feature_directory'
20
20
  feature
@@ -48,7 +48,7 @@ describe Bumps::Feature do
48
48
  end
49
49
 
50
50
  it 'should display the total number of features retrieved and location they were written to' do
51
- features = 3.times.collect{|index| mock("feature #{index}").as_null_object}
51
+ features = (1..3).collect{|index| mock("feature #{index}").as_null_object}
52
52
  Bumps::RemoteFeature.stub!(:fetch).and_return features
53
53
  Bumps::Configuration.stub!(:feature_directory).and_return 'feature_directory'
54
54
  Bumps::Configuration.stub! :pull_url
@@ -82,7 +82,7 @@ describe Bumps::Feature do
82
82
  subject.stub!(:name).and_return '../../etc/bashrc'
83
83
  File.stub! :open # just in case
84
84
 
85
- lambda {subject.absolute_path_under '/stuff/features'}.should raise_error 'Could not write feature to path /etc/bashrc, path is not below /stuff/features'
85
+ lambda {subject.absolute_path_under '/stuff/features'}.should raise_error('Could not write feature to path /etc/bashrc, path is not below /stuff/features')
86
86
  end
87
87
  end
88
88
 
@@ -23,10 +23,10 @@ describe Bumps::RemoteFeature do
23
23
 
24
24
  describe 'when parsing' do
25
25
  it 'should extract all features from XML' do
26
- features = 2.times.collect do |index|
26
+ features = (0..1).collect do |idx|
27
27
  feature = Bumps::Feature.new
28
- feature.name = "feature #{index}"
29
- feature.content = "I am the content for feature #{index}"
28
+ feature.name = "feature #{idx}"
29
+ feature.content = "I am the content for feature #{idx}"
30
30
  feature
31
31
  end
32
32
 
@@ -65,6 +65,19 @@ XML
65
65
  XML
66
66
  subject.parse(xml).should eql([])
67
67
  end
68
-
68
+
69
+ it 'should preserve CDATA in feature content' do
70
+ xml = <<-XML
71
+ <?xml version="1.0"?>
72
+ <features>
73
+ <feature name="feature 0">
74
+ <![CDATA[content contains <b>CDATA</b> & it should be preserved]]>
75
+ </feature>
76
+ </features>
77
+ XML
78
+
79
+ subject.parse(xml).first.content.should match(%r{content contains <b>CDATA</b> & it should be preserved})
80
+ end
81
+
69
82
  end
70
83
  end
@@ -1,20 +1,34 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
- describe Bumps, 'configuration' do
3
+ # required for test of Cucumber hook
4
+ def AfterConfiguration &block
5
+ block.call 'source config'
6
+ end
4
7
 
5
- it 'should configure the new configuration using the given directives' do
6
- Bumps::PreFeatureLoadHook.stub! :register_on
8
+ describe Bumps do
7
9
 
8
- # how can we specify that it should be passed a reference to a block?
9
- Bumps::Configuration.should_receive(:configure)
10
-
11
- Bumps.configure {}
10
+ describe 'execution of Cucumber AfterConfiguration hook' do
11
+
12
+ it 'should process Cucumber config then perform a feature pull' do
13
+ Bumps::CucumberConfig.stub!(:new).with('source config').and_return(cukes_config = mock('Cukes config'))
14
+ cukes_config.should_receive(:process!).ordered
15
+ Bumps::Feature.should_receive(:pull).ordered
16
+
17
+ load File.expand_path(File.dirname(__FILE__) + '/../lib/bumps.rb')
18
+ end
19
+
12
20
  end
21
+
22
+ describe 'configuration' do
23
+
24
+ it 'should configure the new configuration using the given directives' do
13
25
 
14
- it 'should register a pre feature load hook on the main Cucumber class' do
15
- Bumps::PreFeatureLoadHook.should_receive(:register_on).with Cucumber::Cli::Main
26
+ # how can we specify that it should be passed a reference to a block?
27
+ Bumps::Configuration.should_receive(:configure)
16
28
 
17
- Bumps.configure {}
29
+ Bumps.configure {}
30
+ end
31
+
18
32
  end
19
33
 
20
34
  end
@@ -6,5 +6,4 @@ rescue LoadError
6
6
  require 'spec'
7
7
  end
8
8
 
9
- $:.unshift(File.dirname(__FILE__) + '/../lib')
10
- require 'bumps'
9
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/bumps_core')
@@ -0,0 +1,3 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'bumps')
2
+
3
+ Bumps.configure { use_server 'http://localhost:1981' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bumps
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brent Snook
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-09 00:00:00 +01:00
12
+ date: 2009-09-03 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.3.11
23
+ version: 0.3.99
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
@@ -84,24 +84,23 @@ files:
84
84
  - features/push_feature_results.feature
85
85
  - features/steps/command_output.rb
86
86
  - features/steps/cucumber_run.rb
87
- - features/steps/env.rb
88
87
  - features/steps/feature_report.rb
89
88
  - features/steps/feature_server.rb
90
89
  - features/steps/helpers/scenario_process.rb
90
+ - features/support/env.rb
91
91
  - lib/bumps.rb
92
92
  - lib/bumps/configuration.rb
93
+ - lib/bumps/cucumber_config.rb
93
94
  - lib/bumps/feature.rb
94
- - lib/bumps/hook_tasks.rb
95
- - lib/bumps/pre_feature_load_hook.rb
96
95
  - lib/bumps/remote_feature.rb
97
96
  - lib/bumps/results_push_formatter.rb
97
+ - lib/bumps_core.rb
98
98
  - script/console
99
99
  - script/destroy
100
100
  - script/generate
101
101
  - spec/bumps/configuration_spec.rb
102
+ - spec/bumps/cucumber_config_spec.rb
102
103
  - spec/bumps/feature_spec.rb
103
- - spec/bumps/hook_tasks_spec.rb
104
- - spec/bumps/pre_feature_load_hook_spec.rb
105
104
  - spec/bumps/remote_feature_spec.rb
106
105
  - spec/bumps/results_push_formatter_spec.rb
107
106
  - spec/bumps_spec.rb
@@ -109,9 +108,11 @@ files:
109
108
  - spec/spec_helper.rb
110
109
  - tasks/rspec.rake
111
110
  - test_features/remote_content/destroy_dr_thaddeus_venture.feature
112
- - test_features/requires/env.rb
111
+ - test_features/requires/support/env.rb
113
112
  has_rdoc: true
114
113
  homepage: http://github.com/brentsnook/bumps
114
+ licenses: []
115
+
115
116
  post_install_message:
116
117
  rdoc_options:
117
118
  - --main
@@ -133,9 +134,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
134
  requirements: []
134
135
 
135
136
  rubyforge_project: bumps
136
- rubygems_version: 1.3.1
137
+ rubygems_version: 1.3.5
137
138
  signing_key:
138
- specification_version: 2
139
+ specification_version: 3
139
140
  summary: Remote feature management for Cucumber.
140
141
  test_files: []
141
142
 
@@ -1,25 +0,0 @@
1
- module Bumps::HookTasks
2
-
3
- SetFeatureDirectoryTask = lambda do
4
- # nasty? hell yeah. got any better ideas? need access to that protected method...
5
- feature_directories = configuration.send :feature_dirs
6
-
7
- error_message = 'More than one feature directory/file was specified. ' +
8
- 'Please only specify a single feature directory when using bumps'
9
- raise error_message if feature_directories.size > 1
10
- Bumps::Configuration.feature_directory = feature_directories.first
11
- end
12
-
13
- PullFeaturesTask = lambda do
14
- Bumps::Feature.pull
15
- end
16
-
17
- RegisterPushFormatterTask = lambda do
18
- configuration.options[:formats]['Bumps::ResultsPushFormatter'] = Bumps::Configuration.output_stream
19
- end
20
-
21
- SetOutputStreamTask = lambda do
22
- Bumps::Configuration.output_stream = @out_stream
23
- end
24
-
25
- end
@@ -1,27 +0,0 @@
1
- module Bumps
2
- class PreFeatureLoadHook
3
- def self.register_on clazz
4
- clazz.class_eval do
5
-
6
- alias_method :original_load_plain_text_features, :load_plain_text_features
7
-
8
- def bumps_load_plain_text_features
9
- Bumps::PreFeatureLoadHook.tasks.each { |task| instance_eval(&task) }
10
- original_load_plain_text_features
11
- end
12
-
13
- alias_method :load_plain_text_features, :bumps_load_plain_text_features
14
-
15
- end
16
- end
17
-
18
- def self.tasks
19
- [
20
- HookTasks::SetFeatureDirectoryTask,
21
- Bumps::HookTasks::SetOutputStreamTask,
22
- HookTasks::PullFeaturesTask,
23
- HookTasks::RegisterPushFormatterTask
24
- ]
25
- end
26
- end
27
- end
@@ -1,98 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- class Target
4
-
5
- def out_stream= out
6
- @out_stream = out
7
- end
8
-
9
- end
10
-
11
- describe Bumps::HookTasks::SetFeatureDirectoryTask do
12
-
13
- before do
14
- @target = Target.new
15
- end
16
-
17
- subject {Bumps::HookTasks::SetFeatureDirectoryTask}
18
-
19
- it 'should set directory in the bumps configuration' do
20
- cukes_config = mock 'cukes_config'
21
- @target.stub!(:configuration).and_return cukes_config
22
- cukes_config.stub!(:feature_dirs).and_return ['feature_directory']
23
-
24
- Bumps::Configuration.should_receive(:feature_directory=).with 'feature_directory'
25
-
26
- @target.instance_eval &subject
27
- end
28
-
29
- it 'should fail if there is more than one feature directory specified' do
30
- cukes_config = mock 'cukes_config'
31
- @target.stub!(:configuration).and_return cukes_config
32
- cukes_config.stub!(:feature_dirs).and_return ['one', 'two']
33
-
34
- lambda{ @target.instance_eval &subject }.should raise_error('More than one feature directory/file was specified. Please only specify a single feature directory when using bumps')
35
- end
36
- end
37
-
38
- describe Bumps::HookTasks::PullFeaturesTask do
39
-
40
- before do
41
- @target = Target.new
42
- end
43
-
44
- subject {Bumps::HookTasks::PullFeaturesTask}
45
-
46
- it 'should pull features' do
47
- Bumps::Feature.should_receive :pull
48
-
49
- @target.instance_eval &subject
50
- end
51
- end
52
-
53
- describe Bumps::HookTasks::RegisterPushFormatterTask do
54
-
55
- before do
56
- @output_stream = mock 'output stream'
57
- @target = Target.new
58
-
59
- # law of demeter seems like an even better idea after mocking a chain of three objects
60
- @formats = mock 'formats'
61
- options = mock 'options'
62
- options.stub!(:[]).with(:formats).and_return @formats
63
- @target.stub!(:configuration).and_return mock('cukes_config', :options => options)
64
- end
65
-
66
- subject {Bumps::HookTasks::RegisterPushFormatterTask}
67
-
68
- it 'should add the class name of the push formatter to the cucumber configuration' do
69
- @formats.should_receive(:[]=).with('Bumps::ResultsPushFormatter', anything)
70
-
71
- @target.instance_eval &subject
72
- end
73
-
74
- it 'should use the configured output stream for output' do
75
- Bumps::Configuration.stub!(:output_stream).and_return @output_stream
76
-
77
- @formats.should_receive(:[]=).with(anything, @output_stream)
78
-
79
- @target.instance_eval &subject
80
- end
81
- end
82
-
83
- describe Bumps::HookTasks::SetOutputStreamTask do
84
-
85
- before do
86
- @out_stream = mock 'out stream'
87
- @target = Target.new
88
- @target.out_stream = @out_stream
89
- end
90
-
91
- subject {Bumps::HookTasks::SetOutputStreamTask}
92
-
93
- it 'should use target class output stream' do
94
- Bumps::Configuration.should_receive(:output_stream=).with @out_stream
95
-
96
- @target.instance_eval &subject
97
- end
98
- end
@@ -1,44 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper.rb'
2
-
3
- describe Bumps::PreFeatureLoadHook, 'when registered on a class' do
4
-
5
- before do
6
- class Clazz
7
- def load_plain_text_features;end
8
- def configuration;end
9
- end
10
-
11
- Bumps::PreFeatureLoadHook.register_on Clazz
12
-
13
- @instance = Clazz.new
14
- end
15
-
16
- it 'should run all tasks within the context of that class' do
17
- FirstTask = lambda {first_method}
18
- SecondTask = lambda {second_method}
19
- Bumps::PreFeatureLoadHook.stub!(:tasks).and_return [FirstTask, SecondTask]
20
-
21
- @instance.should_receive :first_method
22
- @instance.should_receive :second_method
23
-
24
- @instance.load_plain_text_features
25
- end
26
-
27
- it 'should call the original method after running tasks' do
28
- Bumps::PreFeatureLoadHook.stub!(:tasks).and_return []
29
-
30
- @instance.should_receive :original_load_plain_text_features
31
-
32
- @instance.load_plain_text_features
33
- end
34
-
35
- it 'should complete tasks in correct order' do
36
- # how can this be better expressed with an example?
37
- Bumps::PreFeatureLoadHook.tasks.should == [
38
- Bumps::HookTasks::SetFeatureDirectoryTask,
39
- Bumps::HookTasks::SetOutputStreamTask,
40
- Bumps::HookTasks::PullFeaturesTask,
41
- Bumps::HookTasks::RegisterPushFormatterTask
42
- ]
43
- end
44
- end
@@ -1,3 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'bumps')
2
-
3
- Bumps.configure { use_server 'http://localhost:1981' }