bumps 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Rakefile +1 -0
- data/TODO +0 -4
- data/features/pull_remote_features.feature +0 -2
- data/features/push_feature_results.feature +6 -2
- data/features/steps/command_output.rb +5 -1
- data/lib/bumps/feature.rb +2 -2
- data/lib/bumps/results_push_formatter.rb +17 -5
- data/lib/bumps_core.rb +1 -1
- data/spec/bumps/configuration_spec.rb +11 -11
- data/spec/bumps/cucumber_config_spec.rb +9 -9
- data/spec/bumps/feature_spec.rb +14 -20
- data/spec/bumps/remote_feature_spec.rb +8 -8
- data/spec/bumps/results_push_formatter_spec.rb +64 -60
- data/spec/bumps_spec.rb +7 -11
- data/spec/spec.opts +2 -1
- metadata +2 -2
data/History.txt
CHANGED
data/Rakefile
CHANGED
data/TODO
CHANGED
@@ -5,13 +5,11 @@ Feature: Pull remote features
|
|
5
5
|
So that the features can be authored using a separate tool
|
6
6
|
|
7
7
|
Scenario: Remote features pulled successfully
|
8
|
-
|
9
8
|
Given that a feature server is running
|
10
9
|
When a cucumber run is performed
|
11
10
|
Then the feature report will contain all remote features
|
12
11
|
|
13
12
|
Scenario: Feature server not reachable
|
14
|
-
|
15
13
|
Given that a feature server is not running
|
16
14
|
When a cucumber run is performed
|
17
15
|
Then the command output should show that features could not be pulled
|
@@ -5,7 +5,11 @@ Feature: Serve feature results
|
|
5
5
|
So that I can format my local feature data accordingly
|
6
6
|
|
7
7
|
Scenario: Push all feature results after a run
|
8
|
-
|
9
8
|
Given that a feature server is running
|
10
9
|
When a cucumber run is performed
|
11
|
-
Then the results of the feature run will be sent to the feature server
|
10
|
+
Then the results of the feature run will be sent to the feature server
|
11
|
+
|
12
|
+
Scenario: Feature server not reachable
|
13
|
+
Given that a feature server is not running
|
14
|
+
When a cucumber run is performed
|
15
|
+
Then the command output should show that features could not be pushed
|
@@ -1,3 +1,7 @@
|
|
1
1
|
Then /^the command output should show that features could not be pulled$/ do
|
2
2
|
command_output.should match(/Could not pull features/)
|
3
|
-
end
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^the command output should show that features could not be pushed$/ do
|
6
|
+
command_output.should match(/Failed to push results/)
|
7
|
+
end
|
data/lib/bumps/feature.rb
CHANGED
@@ -9,11 +9,11 @@ module Bumps
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.pull
|
12
|
-
Configuration.output_stream << "
|
12
|
+
Configuration.output_stream << "Retrieving features from #{Configuration.pull_url} ...\n"
|
13
13
|
begin
|
14
14
|
features = RemoteFeature.fetch(Configuration.pull_url)
|
15
15
|
rescue Exception => e
|
16
|
-
Configuration.output_stream << "
|
16
|
+
Configuration.output_stream << "Could not pull features: #{e}\n"
|
17
17
|
features = []
|
18
18
|
end
|
19
19
|
|
@@ -26,12 +26,15 @@ module Bumps
|
|
26
26
|
|
27
27
|
def push results
|
28
28
|
uri = URI.parse(Bumps::Configuration.push_url)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
begin
|
30
|
+
response, body = Net::HTTP.post_form uri, {:results => results}
|
31
|
+
rescue Exception => e
|
32
|
+
@io << failure_message(e.message)
|
33
|
+
return
|
34
34
|
end
|
35
|
+
|
36
|
+
response_ok = response.code_type == Net::HTTPOK
|
37
|
+
@io << (response_ok ? success_message : failure_message("HTTP #{response.code}: \n#{response.body}"))
|
35
38
|
end
|
36
39
|
|
37
40
|
def method_missing(method, *args, &block)
|
@@ -42,5 +45,14 @@ module Bumps
|
|
42
45
|
super(message, include_private) || formatter.respond_to?(message, include_private)
|
43
46
|
end
|
44
47
|
|
48
|
+
private
|
49
|
+
|
50
|
+
def failure_message(message)
|
51
|
+
"Failed to push results to #{Bumps::Configuration.push_url} - #{message}\n"
|
52
|
+
end
|
53
|
+
|
54
|
+
def success_message
|
55
|
+
"Successfully pushed results to #{Bumps::Configuration.push_url}\n"
|
56
|
+
end
|
45
57
|
end
|
46
58
|
end
|
data/lib/bumps_core.rb
CHANGED
@@ -5,56 +5,56 @@ describe Bumps::Configuration do
|
|
5
5
|
before {@output_stream = mock('output stream').as_null_object}
|
6
6
|
subject {Bumps::Configuration.new}
|
7
7
|
|
8
|
-
it '
|
8
|
+
it 'provides an output stream for writing messages' do
|
9
9
|
out_stream = mock 'out stream'
|
10
10
|
subject.output_stream = out_stream
|
11
11
|
|
12
12
|
subject.output_stream.should == out_stream
|
13
13
|
end
|
14
14
|
|
15
|
-
it '
|
15
|
+
it 'is configured using a block' do
|
16
16
|
subject.should_receive(:configuration_call)
|
17
17
|
|
18
18
|
subject.configure { configuration_call }
|
19
19
|
end
|
20
20
|
|
21
|
-
it '
|
21
|
+
it 'derives pull URL from server' do
|
22
22
|
subject.use_server 'http://server'
|
23
23
|
|
24
24
|
subject.pull_url.should == 'http://server/features/content'
|
25
25
|
end
|
26
26
|
|
27
|
-
it '
|
27
|
+
it 'derives push URL from server' do
|
28
28
|
subject.use_server 'http://server'
|
29
29
|
|
30
30
|
subject.push_url.should == 'http://server/features/results'
|
31
31
|
end
|
32
32
|
|
33
|
-
it '
|
33
|
+
it 'recognises a server URL with a trailing slash' do
|
34
34
|
subject.use_server 'http://server/'
|
35
35
|
|
36
36
|
subject.pull_url.should match(/^http:\/\/server\/[a-z]/)
|
37
37
|
end
|
38
38
|
|
39
|
-
it '
|
39
|
+
it 'allows a non-default push URL to be specified' do
|
40
40
|
subject.push_to 'http://url.com'
|
41
41
|
|
42
42
|
subject.push_url.should == 'http://url.com'
|
43
43
|
end
|
44
44
|
|
45
|
-
it '
|
45
|
+
it 'allows a non-default pull URL to be specified' do
|
46
46
|
subject.pull_from 'http://url.com'
|
47
47
|
|
48
48
|
subject.pull_url.should == 'http://url.com'
|
49
49
|
end
|
50
50
|
|
51
|
-
it '
|
51
|
+
it 'allows the feature directory to be set' do
|
52
52
|
subject.feature_directory = 'feature_directory'
|
53
53
|
|
54
54
|
subject.feature_directory.should == 'feature_directory'
|
55
55
|
end
|
56
56
|
|
57
|
-
it '
|
57
|
+
it 'allows results formatter to be specified' do
|
58
58
|
formatter_class = mock 'formatter class'
|
59
59
|
|
60
60
|
subject.format_results_with formatter_class
|
@@ -62,11 +62,11 @@ describe Bumps::Configuration do
|
|
62
62
|
subject.results_formatter.should == formatter_class
|
63
63
|
end
|
64
64
|
|
65
|
-
it '
|
65
|
+
it 'defaults the results formatter to Cucumber HTML formatter' do
|
66
66
|
subject.results_formatter.should == Cucumber::Formatter::Html
|
67
67
|
end
|
68
68
|
|
69
|
-
it '
|
69
|
+
it 'can have only one instance' do
|
70
70
|
singleton = mock 'singleton'
|
71
71
|
Bumps::Configuration.stub!(:singleton).and_return singleton
|
72
72
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
|
-
describe Bumps::CucumberConfig
|
3
|
+
describe Bumps::CucumberConfig do
|
4
4
|
before do
|
5
5
|
@source_config = mock('source Cucumber config')
|
6
6
|
@config = Bumps::CucumberConfig.new @source_config
|
@@ -8,7 +8,7 @@ describe Bumps::CucumberConfig, 'processing' do
|
|
8
8
|
|
9
9
|
describe 'processing' do
|
10
10
|
|
11
|
-
it '
|
11
|
+
it 'validates cucumber configuration, updates Bumps config then registers formatter' do
|
12
12
|
@config.should_receive(:validate).ordered
|
13
13
|
@config.should_receive(:update_bumps_config).ordered
|
14
14
|
@config.should_receive(:register_formatter).ordered
|
@@ -20,13 +20,13 @@ describe Bumps::CucumberConfig, 'processing' do
|
|
20
20
|
|
21
21
|
describe 'validation' do
|
22
22
|
|
23
|
-
it '
|
23
|
+
it 'passes when a single directory is specified' do
|
24
24
|
@source_config.stub!(:feature_dirs).and_return ['one']
|
25
25
|
|
26
26
|
lambda{ @config.validate }.should_not raise_error
|
27
27
|
end
|
28
28
|
|
29
|
-
it '
|
29
|
+
it 'fails when there is more than one feature directory specified' do
|
30
30
|
@source_config.stub!(:feature_dirs).and_return ['one', 'two']
|
31
31
|
|
32
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')
|
@@ -34,9 +34,9 @@ describe Bumps::CucumberConfig, 'processing' do
|
|
34
34
|
|
35
35
|
end
|
36
36
|
|
37
|
-
describe '
|
37
|
+
describe 'update' do
|
38
38
|
|
39
|
-
it '
|
39
|
+
it 'uses fields from source Cucumber config' do
|
40
40
|
@source_config.stub!(:feature_dirs).and_return ['dir']
|
41
41
|
@source_config.stub!(:out_stream).and_return 'out stream'
|
42
42
|
|
@@ -48,7 +48,7 @@ describe Bumps::CucumberConfig, 'processing' do
|
|
48
48
|
|
49
49
|
end
|
50
50
|
|
51
|
-
describe 'registering formatter' do
|
51
|
+
describe 'registering a formatter' do
|
52
52
|
|
53
53
|
before do
|
54
54
|
# law of demeter seems like an even better idea after mocking a chain of three objects
|
@@ -58,13 +58,13 @@ describe Bumps::CucumberConfig, 'processing' do
|
|
58
58
|
@source_config.stub!(:options).and_return options
|
59
59
|
end
|
60
60
|
|
61
|
-
it '
|
61
|
+
it 'adds the class name of the push formatter to the Cucumber configuration' do
|
62
62
|
@formats.should_receive(:<<).with ['Bumps::ResultsPushFormatter', anything]
|
63
63
|
|
64
64
|
@config.register_formatter
|
65
65
|
end
|
66
66
|
|
67
|
-
it '
|
67
|
+
it 'uses the configured output stream to write messages' do
|
68
68
|
output_stream = mock 'output stream'
|
69
69
|
Bumps::Configuration.stub!(:output_stream).and_return output_stream
|
70
70
|
|
data/spec/bumps/feature_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
3
|
describe Bumps::Feature do
|
4
|
-
describe '
|
4
|
+
describe 'pulling feature content' do
|
5
5
|
|
6
6
|
before do
|
7
7
|
@output_stream = mock('output stream').as_null_object
|
@@ -10,7 +10,7 @@ describe Bumps::Feature do
|
|
10
10
|
|
11
11
|
subject {Bumps::Feature}
|
12
12
|
|
13
|
-
it '
|
13
|
+
it 'writes fetched features to the feature directory' do
|
14
14
|
Bumps::Configuration.stub!(:feature_directory).and_return 'feature_directory'
|
15
15
|
Bumps::Configuration.stub!(:pull_url).and_return 'location'
|
16
16
|
|
@@ -27,27 +27,27 @@ describe Bumps::Feature do
|
|
27
27
|
subject.pull
|
28
28
|
end
|
29
29
|
|
30
|
-
it '
|
30
|
+
it 'displays an error message if the features could not be fetched' do
|
31
31
|
Bumps::Configuration.stub! :pull_url
|
32
32
|
Bumps::Configuration.stub! :feature_directory
|
33
33
|
Bumps::RemoteFeature.stub!(:fetch).and_raise "exception message"
|
34
34
|
|
35
|
-
@output_stream.should_receive(:<<).with "
|
35
|
+
@output_stream.should_receive(:<<).with "Could not pull features: exception message\n"
|
36
36
|
|
37
37
|
subject.pull
|
38
38
|
end
|
39
39
|
|
40
|
-
it '
|
40
|
+
it 'displays which location the features are being retrieved from' do
|
41
41
|
Bumps::RemoteFeature.stub!(:fetch).and_return []
|
42
42
|
Bumps::Configuration.stub!(:pull_url).and_return 'pull_url'
|
43
43
|
Bumps::Configuration.stub! :feature_directory
|
44
44
|
|
45
|
-
@output_stream.should_receive(:<<).with "
|
45
|
+
@output_stream.should_receive(:<<).with "Retrieving features from pull_url ...\n"
|
46
46
|
|
47
47
|
subject.pull
|
48
48
|
end
|
49
49
|
|
50
|
-
it '
|
50
|
+
it 'displays the total number of features retrieved and location they were written to' do
|
51
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'
|
@@ -59,36 +59,30 @@ describe Bumps::Feature do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
describe '
|
62
|
+
describe 'writing to file' do
|
63
63
|
|
64
|
-
it '
|
64
|
+
it 'uses absolute path' do
|
65
65
|
subject.stub(:absolute_path_under).with('directory').and_return 'path'
|
66
66
|
|
67
67
|
subject.should_receive(:write_content_to).with 'path'
|
68
68
|
|
69
69
|
subject.write_to 'directory'
|
70
70
|
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe 'when determining absolute feature file path' do
|
74
71
|
|
75
|
-
it '
|
72
|
+
it 'uses expanded directory and feature name' do
|
76
73
|
subject.stub!(:name).and_return 'name'
|
77
74
|
|
78
75
|
subject.absolute_path_under('/a/b/c/..').should == '/a/b/name'
|
79
76
|
end
|
80
77
|
|
81
|
-
it '
|
78
|
+
it 'fails if given path does not resolve to one below the feature directory' do
|
82
79
|
subject.stub!(:name).and_return '../../etc/bashrc'
|
83
80
|
File.stub! :open # just in case
|
84
81
|
|
85
82
|
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
83
|
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe 'when writing content' do
|
90
84
|
|
91
|
-
it '
|
85
|
+
it 'overwrites existing files' do
|
92
86
|
FileUtils.stub! :makedirs
|
93
87
|
|
94
88
|
File.should_receive(:open).with anything, 'w'
|
@@ -96,7 +90,7 @@ describe Bumps::Feature do
|
|
96
90
|
subject.write_content_to ''
|
97
91
|
end
|
98
92
|
|
99
|
-
it '
|
93
|
+
it 'forces the creation of directories in the feature name' do
|
100
94
|
File.stub! :open
|
101
95
|
|
102
96
|
FileUtils.should_receive(:makedirs).with 'features_dir/subdir'
|
@@ -104,7 +98,7 @@ describe Bumps::Feature do
|
|
104
98
|
subject.write_content_to 'features_dir/subdir/featurename.feature'
|
105
99
|
end
|
106
100
|
|
107
|
-
it '
|
101
|
+
it 'writes content' do
|
108
102
|
FileUtils.stub! :makedirs
|
109
103
|
@file = mock 'file'
|
110
104
|
File.stub!(:open).and_yield @file
|
@@ -4,15 +4,15 @@ describe Bumps::RemoteFeature do
|
|
4
4
|
|
5
5
|
subject {Bumps::RemoteFeature}
|
6
6
|
|
7
|
-
describe '
|
8
|
-
it '
|
7
|
+
describe 'fetching' do
|
8
|
+
it 'uses the given location' do
|
9
9
|
subject.should_receive(:open).with('location')
|
10
10
|
subject.stub! :parse
|
11
11
|
|
12
12
|
subject.fetch 'location'
|
13
13
|
end
|
14
14
|
|
15
|
-
it '
|
15
|
+
it 'parses the given document to obtain features' do
|
16
16
|
subject.stub!(:open).and_return 'document'
|
17
17
|
|
18
18
|
subject.should_receive(:parse).with 'document'
|
@@ -21,8 +21,8 @@ describe Bumps::RemoteFeature do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe '
|
25
|
-
it '
|
24
|
+
describe 'parsing' do
|
25
|
+
it 'extracts all features from XML' do
|
26
26
|
features = (0..1).collect do |idx|
|
27
27
|
feature = Bumps::Feature.new
|
28
28
|
feature.name = "feature #{idx}"
|
@@ -41,7 +41,7 @@ XML
|
|
41
41
|
subject.parse(xml).should eql(features)
|
42
42
|
end
|
43
43
|
|
44
|
-
it '
|
44
|
+
it 'trims leading and trailing whitespace from content' do
|
45
45
|
xml = <<-XML
|
46
46
|
<?xml version="1.0"?>
|
47
47
|
<features>
|
@@ -57,7 +57,7 @@ XML
|
|
57
57
|
subject.parse(xml).first.content.should == 'I am the content for feature 0'
|
58
58
|
end
|
59
59
|
|
60
|
-
it '
|
60
|
+
it 'returns an empty list when no features were found' do
|
61
61
|
xml = <<-XML
|
62
62
|
<?xml version="1.0"?>
|
63
63
|
<features>
|
@@ -66,7 +66,7 @@ XML
|
|
66
66
|
subject.parse(xml).should eql([])
|
67
67
|
end
|
68
68
|
|
69
|
-
it '
|
69
|
+
it 'preserves CDATA in feature content' do
|
70
70
|
xml = <<-XML
|
71
71
|
<?xml version="1.0"?>
|
72
72
|
<features>
|
@@ -18,7 +18,7 @@ describe Bumps::ResultsPushFormatter do
|
|
18
18
|
)
|
19
19
|
end
|
20
20
|
|
21
|
-
describe '
|
21
|
+
describe 'responding to' do
|
22
22
|
|
23
23
|
before do
|
24
24
|
@formatter_class = mock 'formatter class'
|
@@ -26,31 +26,46 @@ describe Bumps::ResultsPushFormatter do
|
|
26
26
|
Bumps::Configuration.stub!(:results_formatter).and_return @formatter_class
|
27
27
|
end
|
28
28
|
|
29
|
-
describe '
|
29
|
+
describe 'events' do
|
30
30
|
|
31
31
|
before do
|
32
32
|
@formatter_class.stub!(:new).and_return @formatter
|
33
33
|
Bumps::Configuration.stub!(:results_formatter).and_return @formatter_class
|
34
34
|
end
|
35
35
|
|
36
|
-
it '
|
36
|
+
it 'recognises events that the wrapped formatter handles' do
|
37
37
|
@formatter.stub!(:respond_to?).with('event', anything).and_return true
|
38
38
|
|
39
39
|
subject.before_features @features
|
40
40
|
subject.respond_to?('event').should == true
|
41
41
|
end
|
42
42
|
|
43
|
-
it '
|
43
|
+
it 'recognises events that it handles on its own' do
|
44
44
|
@formatter.stub!(:respond_to?).with('after_features', anything).and_return false
|
45
45
|
|
46
46
|
subject.before_features @features
|
47
47
|
subject.respond_to?('after_features').should == true
|
48
48
|
end
|
49
|
+
|
50
|
+
it 'notifies the wrapped formatter of all events' do
|
51
|
+
@formatter_class.stub!(:new).and_return @formatter
|
52
|
+
Bumps::Configuration.stub!(:results_formatter).and_return @formatter_class
|
53
|
+
events = [
|
54
|
+
:before_feature, :after_feature, :before_comment, :after_comment,
|
55
|
+
:comment_line, :after_tags, :before_background, :after_background,
|
56
|
+
# there are more, add as needed
|
57
|
+
]
|
58
|
+
|
59
|
+
events.each { |event| @formatter.should_receive(event).with('arguments')}
|
60
|
+
|
61
|
+
subject.before_features @features
|
62
|
+
events.each { |event| subject.send(event, 'arguments')}
|
63
|
+
end
|
49
64
|
end
|
50
65
|
|
51
|
-
describe 'before
|
66
|
+
describe 'before features' do
|
52
67
|
|
53
|
-
it '
|
68
|
+
it 'constructs the wrapped formatter using the step mother' do
|
54
69
|
@formatter_class.should_receive(:new).with(
|
55
70
|
@step_mother, anything, anything
|
56
71
|
).and_return @formatter
|
@@ -58,7 +73,7 @@ describe Bumps::ResultsPushFormatter do
|
|
58
73
|
subject.before_features @features
|
59
74
|
end
|
60
75
|
|
61
|
-
it '
|
76
|
+
it 'constructs the wrapped formatter using the options' do
|
62
77
|
@formatter_class.should_receive(:new).with(
|
63
78
|
anything, anything, @options
|
64
79
|
).and_return @formatter
|
@@ -66,7 +81,7 @@ describe Bumps::ResultsPushFormatter do
|
|
66
81
|
subject.before_features @features
|
67
82
|
end
|
68
83
|
|
69
|
-
it '
|
84
|
+
it 'obtains the results formatter from the configuration' do
|
70
85
|
@formatter_class.stub!(:new).and_return @formatter
|
71
86
|
|
72
87
|
Bumps::Configuration.should_receive(:results_formatter).and_return @formatter_class
|
@@ -74,7 +89,7 @@ describe Bumps::ResultsPushFormatter do
|
|
74
89
|
subject.before_features @features
|
75
90
|
end
|
76
91
|
|
77
|
-
it '
|
92
|
+
it 'notifies the wrapped formatter of the before_features event' do
|
78
93
|
Bumps::Configuration.stub!(:results_formatter).and_return @formatter_class
|
79
94
|
@formatter_class.stub!(:new).and_return @formatter
|
80
95
|
|
@@ -85,26 +100,8 @@ describe Bumps::ResultsPushFormatter do
|
|
85
100
|
|
86
101
|
end
|
87
102
|
|
88
|
-
describe '
|
89
|
-
|
90
|
-
it 'should notify the wrapped formatter of all events' do
|
91
|
-
@formatter_class.stub!(:new).and_return @formatter
|
92
|
-
Bumps::Configuration.stub!(:results_formatter).and_return @formatter_class
|
93
|
-
events = [
|
94
|
-
:before_feature, :after_feature, :before_comment, :after_comment,
|
95
|
-
:comment_line, :after_tags, :before_background, :after_background,
|
96
|
-
# there are more, add as needed
|
97
|
-
]
|
98
|
-
|
99
|
-
events.each { |event| @formatter.should_receive(event).with('arguments')}
|
100
|
-
|
101
|
-
subject.before_features @features
|
102
|
-
events.each { |event| subject.send(event, 'arguments')}
|
103
|
-
end
|
103
|
+
describe 'after features' do
|
104
104
|
|
105
|
-
end
|
106
|
-
|
107
|
-
describe 'after the running of features' do
|
108
105
|
before do
|
109
106
|
@results = mock('results').as_null_object
|
110
107
|
subject.stub!(:results).and_return @results
|
@@ -112,48 +109,47 @@ describe Bumps::ResultsPushFormatter do
|
|
112
109
|
subject.stub!(:push)
|
113
110
|
end
|
114
111
|
|
115
|
-
it '
|
112
|
+
it 'notifies the wrapped formatter after all features have been run' do
|
116
113
|
@formatter.should_receive(:after_features).with @features
|
117
114
|
|
118
115
|
subject.after_features @features
|
119
116
|
end
|
120
117
|
|
121
|
-
it '
|
118
|
+
it 'readies the captured results for pushing' do
|
122
119
|
@results.should_receive :close
|
123
120
|
|
124
121
|
subject.after_features @features
|
125
122
|
end
|
126
123
|
end
|
127
124
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
def after_feature feature
|
142
|
-
@io << "After feature: #{feature}"
|
143
|
-
end
|
144
|
-
end
|
145
|
-
Bumps::Configuration.stub(:results_formatter).and_return FormatterTestDouble
|
146
|
-
|
147
|
-
subject.should_receive(:push).with 'After feature: walk the dog'
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'captures then pushes results' do
|
128
|
+
class FormatterTestDouble
|
129
|
+
def initialize(step_mother, io, options)
|
130
|
+
@io = io
|
131
|
+
end
|
132
|
+
|
133
|
+
def before_features features
|
134
|
+
end
|
135
|
+
|
136
|
+
def after_features features
|
137
|
+
end
|
148
138
|
|
149
|
-
|
150
|
-
|
151
|
-
subject.after_features @features
|
139
|
+
def after_feature feature
|
140
|
+
@io << "After feature: #{feature}"
|
152
141
|
end
|
153
142
|
end
|
143
|
+
Bumps::Configuration.stub(:results_formatter).and_return FormatterTestDouble
|
144
|
+
|
145
|
+
subject.should_receive(:push).with 'After feature: walk the dog'
|
146
|
+
|
147
|
+
subject.before_features @features
|
148
|
+
subject.after_feature 'walk the dog'
|
149
|
+
subject.after_features @features
|
154
150
|
end
|
155
151
|
|
156
|
-
describe '
|
152
|
+
describe 'pushing results' do
|
157
153
|
|
158
154
|
before do
|
159
155
|
@response = mock 'response'
|
@@ -162,7 +158,7 @@ describe Bumps::ResultsPushFormatter do
|
|
162
158
|
Bumps::Configuration.stub!(:push_url).and_return @push_url
|
163
159
|
end
|
164
160
|
|
165
|
-
it '
|
161
|
+
it 'posts results to configured push URL' do
|
166
162
|
parsed_uri = mock 'parsed uri'
|
167
163
|
URI.stub!(:parse).with(@push_url).and_return parsed_uri
|
168
164
|
|
@@ -171,28 +167,36 @@ describe Bumps::ResultsPushFormatter do
|
|
171
167
|
subject.push 'results'
|
172
168
|
end
|
173
169
|
|
174
|
-
it '
|
170
|
+
it 'sends captured results in request' do
|
175
171
|
Net::HTTP.should_receive(:post_form).with(anything, {:results => 'results'}).and_return([@response, ''])
|
176
172
|
|
177
173
|
subject.push 'results'
|
178
174
|
end
|
179
175
|
|
180
|
-
it '
|
176
|
+
it 'displays a success message if results were pushed successfully' do
|
181
177
|
Net::HTTP.stub!(:post_form).and_return @response, ''
|
182
178
|
|
183
|
-
@io.should_receive(:<<).with "Successfully pushed results to #{@push_url}\n
|
179
|
+
@io.should_receive(:<<).with "Successfully pushed results to #{@push_url}\n"
|
184
180
|
|
185
181
|
subject.push 'results'
|
186
182
|
end
|
187
183
|
|
188
|
-
it
|
184
|
+
it "displays a failure message if push server doesn't respond with OK" do
|
189
185
|
@response.stub!(:code_type).and_return Net::HTTPInternalServerError
|
190
186
|
@response.stub!(:code).and_return 500
|
191
187
|
@response.stub!(:body).and_return 'response body'
|
192
188
|
|
193
189
|
Net::HTTP.stub!(:post_form).and_return @response, ''
|
194
190
|
|
195
|
-
@io.should_receive(:<<).with "Failed to push results to #{@push_url} - HTTP 500: \nresponse body\n
|
191
|
+
@io.should_receive(:<<).with "Failed to push results to #{@push_url} - HTTP 500: \nresponse body\n"
|
192
|
+
|
193
|
+
subject.push 'results'
|
194
|
+
end
|
195
|
+
|
196
|
+
it "displays a failure message if request to push server fails" do
|
197
|
+
Net::HTTP.stub!(:post_form).and_raise 'exception message'
|
198
|
+
|
199
|
+
@io.should_receive(:<<).with "Failed to push results to #{@push_url} - exception message\n"
|
196
200
|
|
197
201
|
subject.push 'results'
|
198
202
|
end
|
data/spec/bumps_spec.rb
CHANGED
@@ -7,9 +7,9 @@ end
|
|
7
7
|
|
8
8
|
describe Bumps do
|
9
9
|
|
10
|
-
describe '
|
10
|
+
describe 'AfterConfiguration hook' do
|
11
11
|
|
12
|
-
it '
|
12
|
+
it 'processes the Cucumber config then performs a feature pull' do
|
13
13
|
Bumps::CucumberConfig.stub!(:new).with('source config').and_return(cukes_config = mock('Cukes config'))
|
14
14
|
cukes_config.should_receive(:process!).ordered
|
15
15
|
Bumps::Feature.should_receive(:pull).ordered
|
@@ -19,16 +19,12 @@ describe Bumps do
|
|
19
19
|
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
it 'should configure the new configuration using the given directives' do
|
25
|
-
|
26
|
-
# how can we specify that it should be passed a reference to a block?
|
27
|
-
Bumps::Configuration.should_receive(:configure)
|
28
|
-
|
29
|
-
Bumps.configure {}
|
30
|
-
end
|
22
|
+
it 'is configured using the given directives' do
|
31
23
|
|
24
|
+
# how can we specify that it should be passed a reference to a block?
|
25
|
+
Bumps::Configuration.should_receive(:configure)
|
26
|
+
|
27
|
+
Bumps.configure {}
|
32
28
|
end
|
33
29
|
|
34
30
|
end
|
data/spec/spec.opts
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
--colour
|
1
|
+
--colour
|
2
|
+
-fs
|
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.
|
4
|
+
version: 0.0.4
|
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-
|
12
|
+
date: 2009-10-13 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|