bumps 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,98 @@
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
@@ -0,0 +1,44 @@
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
@@ -0,0 +1,70 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Bumps::RemoteFeature do
4
+
5
+ subject {Bumps::RemoteFeature}
6
+
7
+ describe 'when fetching' do
8
+ it 'should retrieve features from the given location' do
9
+ subject.should_receive(:open).with('location')
10
+ subject.stub! :parse
11
+
12
+ subject.fetch 'location'
13
+ end
14
+
15
+ it 'should parse the given document to obtain features' do
16
+ subject.stub!(:open).and_return 'document'
17
+
18
+ subject.should_receive(:parse).with 'document'
19
+
20
+ subject.fetch ''
21
+ end
22
+ end
23
+
24
+ describe 'when parsing' do
25
+ it 'should extract all features from XML' do
26
+ features = 2.times.collect do |index|
27
+ feature = Bumps::Feature.new
28
+ feature.name = "feature #{index}"
29
+ feature.content = "I am the content for feature #{index}"
30
+ feature
31
+ end
32
+
33
+ xml = <<-XML
34
+ <?xml version="1.0"?>
35
+ <features>
36
+ <feature name="feature 0">I am the content for feature 0</feature>
37
+ <feature name="feature 1">I am the content for feature 1</feature>
38
+ </features>
39
+ XML
40
+
41
+ subject.parse(xml).should eql(features)
42
+ end
43
+
44
+ it 'should trim leading and trailing whitespace from content' do
45
+ xml = <<-XML
46
+ <?xml version="1.0"?>
47
+ <features>
48
+ <feature name="feature 0">
49
+
50
+
51
+ I am the content for feature 0
52
+
53
+ </feature>
54
+ </features>
55
+ XML
56
+
57
+ subject.parse(xml).first.content.should == 'I am the content for feature 0'
58
+ end
59
+
60
+ it 'should return an empty feature list when none were found' do
61
+ xml = <<-XML
62
+ <?xml version="1.0"?>
63
+ <features>
64
+ </features>
65
+ XML
66
+ subject.parse(xml).should eql([])
67
+ end
68
+
69
+ end
70
+ end
@@ -0,0 +1,126 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+
3
+ describe Bumps::ResultsPushFormatter do
4
+
5
+ before do
6
+ @step_mother = mock 'step_mother'
7
+ @io = mock('io').as_null_object
8
+ @options = mock 'options'
9
+
10
+ @features = mock('features').as_null_object
11
+ end
12
+
13
+ subject do
14
+ Bumps::ResultsPushFormatter.new(
15
+ @step_mother,
16
+ @io,
17
+ @options
18
+ )
19
+ end
20
+
21
+ it 'should capture results before pushing them' do
22
+ results = mock 'results'
23
+
24
+ subject.should_receive(:results_of_running).with(@features).and_return results
25
+ subject.should_receive(:push).with results
26
+
27
+ subject.visit_features @features
28
+ end
29
+
30
+ describe 'when capturing results' do
31
+
32
+ before do
33
+ @formatter_class = mock 'formatter class'
34
+ Bumps::Configuration.stub!(:results_formatter).and_return @formatter_class
35
+ end
36
+
37
+ it 'should obtain the results formatter from the configuration' do
38
+ @formatter_class.stub!(:new).and_return mock('formatter').as_null_object
39
+
40
+ Bumps::Configuration.should_receive(:results_formatter).and_return @formatter_class
41
+
42
+ subject.results_of_running @features
43
+ end
44
+
45
+ it 'should construct the wrapped formatter using the step mother' do
46
+ @formatter_class.should_receive(:new).with(
47
+ @step_mother, anything, anything
48
+ ).and_return mock('formatter').as_null_object
49
+
50
+ subject.results_of_running @features
51
+ end
52
+
53
+ it 'should construct the wrapped formatter using the options' do
54
+ @formatter_class.should_receive(:new).with(
55
+ anything, anything, @options
56
+ ).and_return mock('formatter').as_null_object
57
+
58
+ subject.results_of_running @features
59
+ end
60
+
61
+ it 'should return results of visiting features with wrapped formatter' do
62
+
63
+ class FormatterTestDouble
64
+ def initialize io
65
+ @io = io
66
+ end
67
+
68
+ def visit_features features
69
+ @io << 'results'
70
+ end
71
+ end
72
+
73
+ @formatter_class.stub!(:new) do |step_mother, io, options|
74
+ FormatterTestDouble.new(io)
75
+ end
76
+
77
+ subject.results_of_running(@features).should =='results'
78
+ end
79
+
80
+ end
81
+
82
+ describe 'when pushing results' do
83
+
84
+ before do
85
+ @response = mock 'response'
86
+ @response.stub!(:code_type).and_return Net::HTTPOK
87
+ @push_url = 'http://push.com'
88
+ Bumps::Configuration.stub!(:push_url).and_return @push_url
89
+ end
90
+
91
+ it 'should post results to configured push URL' do
92
+ parsed_uri = mock 'parsed uri'
93
+ URI.stub!(:parse).with(@push_url).and_return parsed_uri
94
+
95
+ Net::HTTP.should_receive(:post_form).with(parsed_uri, anything).and_return([@response, ''])
96
+
97
+ subject.push 'results'
98
+ end
99
+
100
+ it 'should send captured results in request' do
101
+ Net::HTTP.should_receive(:post_form).with(anything, {:results => 'results'}).and_return([@response, ''])
102
+
103
+ subject.push 'results'
104
+ end
105
+
106
+ it 'should output a success message if results were pushed successfully' do
107
+ Net::HTTP.stub!(:post_form).and_return @response, ''
108
+
109
+ @io.should_receive(:<<).with "Successfully pushed results to #{@push_url}\n\n"
110
+
111
+ subject.push 'results'
112
+ end
113
+
114
+ it 'should output a failure message if results could not be pushed' do
115
+ @response.stub!(:code_type).and_return Net::HTTPInternalServerError
116
+ @response.stub!(:code).and_return 500
117
+ @response.stub!(:body).and_return 'response body'
118
+
119
+ Net::HTTP.stub!(:post_form).and_return @response, ''
120
+
121
+ @io.should_receive(:<<).with "Failed to push results to #{@push_url} - HTTP 500: \nresponse body\n\n"
122
+
123
+ subject.push 'results'
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,20 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe Bumps, 'configuration' do
4
+
5
+ it 'should configure the new configuration using the given directives' do
6
+ Bumps::PreFeatureLoadHook.stub! :register_on
7
+
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 {}
12
+ end
13
+
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
16
+
17
+ Bumps.configure {}
18
+ end
19
+
20
+ end
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'bumps'
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
@@ -0,0 +1,12 @@
1
+ Feature: Destroy Dr Thaddeus Venture
2
+
3
+ As The Monarch
4
+ I want to destroy Dr Thaddeus Venture
5
+ Just because
6
+
7
+ Scenario: Brock Samson shows up
8
+
9
+ Given an evil plan is in effect
10
+ When Brock Samson shows up
11
+ Then all henchmen will be killed
12
+ And the plan will fail
@@ -0,0 +1,3 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'bumps')
2
+
3
+ Bumps.configure { use_server 'http://localhost:1981' }
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bumps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brent Snook
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-09 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: cucumber
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.3.11
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: nokogiri
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.1
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: newgem
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 1.2.3
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: rspec
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.2.7
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: hoe
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 1.8.0
64
+ version:
65
+ description: ""
66
+ email:
67
+ - brent@fuglylogic.com
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ extra_rdoc_files:
73
+ - History.txt
74
+ - Manifest.txt
75
+ - README.rdoc
76
+ files:
77
+ - History.txt
78
+ - Manifest.txt
79
+ - README.rdoc
80
+ - Rakefile
81
+ - TODO
82
+ - examples/feature_server
83
+ - features/pull_remote_features.feature
84
+ - features/push_feature_results.feature
85
+ - features/steps/command_output.rb
86
+ - features/steps/cucumber_run.rb
87
+ - features/steps/env.rb
88
+ - features/steps/feature_report.rb
89
+ - features/steps/feature_server.rb
90
+ - features/steps/helpers/scenario_process.rb
91
+ - lib/bumps.rb
92
+ - lib/bumps/configuration.rb
93
+ - lib/bumps/feature.rb
94
+ - lib/bumps/hook_tasks.rb
95
+ - lib/bumps/pre_feature_load_hook.rb
96
+ - lib/bumps/remote_feature.rb
97
+ - lib/bumps/results_push_formatter.rb
98
+ - script/console
99
+ - script/destroy
100
+ - script/generate
101
+ - spec/bumps/configuration_spec.rb
102
+ - spec/bumps/feature_spec.rb
103
+ - spec/bumps/hook_tasks_spec.rb
104
+ - spec/bumps/pre_feature_load_hook_spec.rb
105
+ - spec/bumps/remote_feature_spec.rb
106
+ - spec/bumps/results_push_formatter_spec.rb
107
+ - spec/bumps_spec.rb
108
+ - spec/spec.opts
109
+ - spec/spec_helper.rb
110
+ - tasks/rspec.rake
111
+ - test_features/remote_content/destroy_dr_thaddeus_venture.feature
112
+ - test_features/requires/env.rb
113
+ has_rdoc: true
114
+ homepage: http://github.com/brentsnook/bumps
115
+ post_install_message:
116
+ rdoc_options:
117
+ - --main
118
+ - README.rdoc
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: "0"
126
+ version:
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: "0"
132
+ version:
133
+ requirements: []
134
+
135
+ rubyforge_project: bumps
136
+ rubygems_version: 1.3.1
137
+ signing_key:
138
+ specification_version: 2
139
+ summary: Remote feature management for Cucumber.
140
+ test_files: []
141
+