codefumes 0.1.10 → 0.2.0
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/Gemfile +19 -0
- data/Gemfile.lock +135 -0
- data/History.txt +12 -0
- data/LICENSE +20 -0
- data/Manifest.txt +40 -19
- data/README.txt +11 -29
- data/Rakefile +15 -10
- data/bin/fumes +214 -0
- data/config/website.yml +2 -0
- data/cucumber.yml +2 -0
- data/features/claiming_a_project.feature +46 -0
- data/features/deleting_a_project.feature +32 -0
- data/features/releasing_a_project.feature +50 -0
- data/features/step_definitions/cli_steps.rb +98 -0
- data/features/step_definitions/common_steps.rb +168 -0
- data/features/step_definitions/filesystem_steps.rb +19 -0
- data/features/storing_user_api_key.feature +41 -0
- data/features/support/common.rb +29 -0
- data/features/support/env.rb +24 -0
- data/features/support/matchers.rb +11 -0
- data/features/synchronizing_repository_with_project.feature +33 -0
- data/lib/codefumes.rb +10 -8
- data/lib/codefumes/api.rb +20 -11
- data/lib/codefumes/api/build.rb +139 -0
- data/lib/codefumes/api/claim.rb +74 -0
- data/lib/codefumes/api/commit.rb +150 -0
- data/lib/codefumes/api/payload.rb +93 -0
- data/lib/codefumes/api/project.rb +158 -0
- data/lib/codefumes/cli_helpers.rb +54 -0
- data/lib/codefumes/config_file.rb +3 -2
- data/lib/codefumes/errors.rb +21 -0
- data/lib/codefumes/exit_codes.rb +10 -0
- data/lib/codefumes/harvester.rb +113 -0
- data/lib/codefumes/quick_build.rb +43 -0
- data/lib/codefumes/quick_metric.rb +20 -0
- data/lib/codefumes/source_control.rb +137 -0
- data/lib/integrity_notifier/codefumes.haml +11 -0
- data/lib/integrity_notifier/codefumes.rb +62 -0
- data/spec/codefumes/{build_spec.rb → api/build_spec.rb} +14 -24
- data/spec/codefumes/{claim_spec.rb → api/claim_spec.rb} +42 -3
- data/spec/codefumes/{commit_spec.rb → api/commit_spec.rb} +34 -24
- data/spec/codefumes/api/payload_spec.rb +148 -0
- data/spec/codefumes/api/project_spec.rb +286 -0
- data/spec/codefumes/api_spec.rb +38 -15
- data/spec/codefumes/config_file_spec.rb +69 -13
- data/spec/codefumes/harvester_spec.rb +118 -0
- data/spec/codefumes/source_control_spec.rb +199 -0
- data/spec/codefumes_service_helpers.rb +23 -19
- data/spec/fixtures/sample_project_dirs/no_scm/description +4 -0
- data/spec/spec_helper.rb +1 -0
- data/tasks/cucumber.rake +11 -0
- metadata +145 -60
- data/bin/cf_claim_project +0 -9
- data/bin/cf_release_project +0 -10
- data/bin/cf_store_credentials +0 -10
- data/lib/cf_claim_project/cli.rb +0 -95
- data/lib/cf_release_project/cli.rb +0 -76
- data/lib/cf_store_credentials/cli.rb +0 -50
- data/lib/codefumes/build.rb +0 -131
- data/lib/codefumes/claim.rb +0 -57
- data/lib/codefumes/commit.rb +0 -144
- data/lib/codefumes/payload.rb +0 -103
- data/lib/codefumes/project.rb +0 -129
- data/spec/cf_claim_project/cli_spec.rb +0 -17
- data/spec/cf_release_project/cli_spec.rb +0 -41
- data/spec/cf_store_credentials/cli_spec.rb +0 -28
- data/spec/codefumes/payload_spec.rb +0 -155
- data/spec/codefumes/project_spec.rb +0 -274
@@ -1,155 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
-
|
3
|
-
module PayloadSpecHelper
|
4
|
-
end
|
5
|
-
|
6
|
-
describe "Payload" do
|
7
|
-
include CodeFumesServiceHelpers::Payload
|
8
|
-
|
9
|
-
after(:all) do
|
10
|
-
FakeWeb.allow_net_connect = false
|
11
|
-
FakeWeb.clean_registry
|
12
|
-
end
|
13
|
-
|
14
|
-
before(:each) do
|
15
|
-
setup_fixture_base
|
16
|
-
@payload = Payload.new(:public_key => @pub_key, :private_key => @priv_key, :content => {:commits => @commit_data})
|
17
|
-
@payload_query = {:payload => {:commits => @commit_data}}
|
18
|
-
@basic_auth_params = {:username => @pub_key, :password => @priv_key}
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "save" do
|
22
|
-
it "sets basic auth with the public and private key" do
|
23
|
-
register_create_uri(["401", "Unauthorized"], "")
|
24
|
-
Payload.should_receive(:post).with("/projects/#{@project.public_key}/payloads", :query => @payload_query, :basic_auth => @basic_auth_params).and_return(mock("response", :code => 401))
|
25
|
-
@payload.save
|
26
|
-
end
|
27
|
-
|
28
|
-
context "with valid parameters" do
|
29
|
-
before(:each) do
|
30
|
-
register_create_uri(["201", "Created"])
|
31
|
-
end
|
32
|
-
|
33
|
-
it "sets a value for 'created_at'" do
|
34
|
-
@payload.created_at.should == nil
|
35
|
-
@payload.save.should == true
|
36
|
-
@payload.created_at.should_not == nil
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "with Unauthorized response" do
|
41
|
-
before(:each) do
|
42
|
-
register_create_uri(["401", "Unauthorized"], "")
|
43
|
-
end
|
44
|
-
|
45
|
-
it "does not set 'created_at'" do
|
46
|
-
@payload.created_at.should == nil
|
47
|
-
@payload.save.should == false
|
48
|
-
@payload.created_at.should == nil
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when the payload does not have any content" do
|
53
|
-
before(:each) do
|
54
|
-
@payload = Payload.new(:public_key => @project.public_key, :content => {:commits => ""})
|
55
|
-
end
|
56
|
-
|
57
|
-
it "returns true without attempting to save to the site" do
|
58
|
-
Payload.should_not_receive(:post)
|
59
|
-
@payload.save.should == true
|
60
|
-
end
|
61
|
-
|
62
|
-
it "does not set the value of created_at" do
|
63
|
-
@payload.save
|
64
|
-
@payload.created_at.should == nil
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "with invalid parameters" do
|
69
|
-
before(:each) do
|
70
|
-
register_create_uri
|
71
|
-
end
|
72
|
-
|
73
|
-
it "does not set a value for 'created_at'" do
|
74
|
-
@payload.save.should == false
|
75
|
-
@payload.created_at.should == nil
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "calling the class method" do
|
81
|
-
describe "'prepare'" do
|
82
|
-
context "when supplying nil content" do
|
83
|
-
it "returns an empty array" do
|
84
|
-
Payload.prepare(nil).should == []
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
context "when supplying an empty Hash" do
|
89
|
-
it "returns an empty array" do
|
90
|
-
Payload.prepare({}).should == []
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
context "when supplying hash does not contain a :public_key key" do
|
95
|
-
it "raises an ArgumentError exception" do
|
96
|
-
lambda {Payload.prepare({:commits => []})}.should raise_error(ArgumentError)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context "when supplying hash does not contain a :commits key" do
|
101
|
-
it "raises an ArgumentError exception" do
|
102
|
-
lambda {Payload.prepare({:public_key => "pub_key1"})}.should raise_error(ArgumentError)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
context "when supplying a hash with less than 4,000 characters" do
|
107
|
-
before(:each) do
|
108
|
-
single_commit_ex = {:identifier => "92dd08477f0ca144ee0f12ba083760dd810760a2_000"}
|
109
|
-
commit_count = 4000 / single_commit_ex.to_s.length
|
110
|
-
commits = commit_count.times.map do |index|
|
111
|
-
{:identifier => "92dd08477f0ca144ee0f12ba083760dd810760a2_#{index}"}
|
112
|
-
end
|
113
|
-
@prepared = Payload.prepare({:public_key => 'fjsk', :private_key => 'something_super_secret', :content => {:commits => commits}})
|
114
|
-
end
|
115
|
-
|
116
|
-
it "returns an Array with a single payload element" do
|
117
|
-
@prepared.should be_instance_of(Array)
|
118
|
-
@prepared.size.should == 1
|
119
|
-
@prepared.first.should be_instance_of(Payload)
|
120
|
-
end
|
121
|
-
|
122
|
-
it "sets the private_key on all payloads" do
|
123
|
-
@prepared.each do |payload|
|
124
|
-
payload.project_private_key.should == 'something_super_secret'
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
context "when supplying a hash with approximately 15,000 characters" do
|
130
|
-
before(:each) do
|
131
|
-
single_commit_ex = {:identifier => "92dd08477f0ca144ee0f12ba083760dd810760a2_000"}
|
132
|
-
commit_count = 15000 / single_commit_ex.to_s.length + 1
|
133
|
-
commits = commit_count.times.map do |index|
|
134
|
-
{:identifier => "92dd08477f0ca144ee0f12ba083760dd810760a2_#{index}"}
|
135
|
-
end
|
136
|
-
raw_payload = {:public_key => 'fjsk', :private_key => 'something_super_secret', :content => {:commits => commits}}
|
137
|
-
@prepared = Payload.prepare(raw_payload)
|
138
|
-
end
|
139
|
-
|
140
|
-
it "returns an Array with a four payload elements" do
|
141
|
-
@prepared.should be_instance_of(Array)
|
142
|
-
@prepared.size.should == 4
|
143
|
-
all_are_payloads = @prepared.all? {|chunk| chunk.instance_of?(Payload)}
|
144
|
-
all_are_payloads.should == true
|
145
|
-
end
|
146
|
-
|
147
|
-
it "sets the private_key on all payloads" do
|
148
|
-
@prepared.each do |payload|
|
149
|
-
payload.project_private_key.should == 'something_super_secret'
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
@@ -1,274 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
-
|
3
|
-
describe "Project" do
|
4
|
-
include CodeFumesServiceHelpers::Project
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
setup_fixture_base
|
8
|
-
end
|
9
|
-
|
10
|
-
after(:all) do
|
11
|
-
FakeWeb.allow_net_connect = false
|
12
|
-
FakeWeb.clean_registry
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "save" do
|
16
|
-
context "with valid parameters" do
|
17
|
-
context "when the public key has not been taken yet (or no key provided)" do
|
18
|
-
before(:each) do
|
19
|
-
register_no_param_create_uri
|
20
|
-
end
|
21
|
-
|
22
|
-
[ :public_key,
|
23
|
-
:private_key,
|
24
|
-
:short_uri,
|
25
|
-
:community_uri,
|
26
|
-
:api_uri].each do |method_name|
|
27
|
-
it "sets the '#{method_name.to_s}'" do
|
28
|
-
project = CodeFumes::Project.new
|
29
|
-
project.send(method_name).should be_nil
|
30
|
-
project.save
|
31
|
-
project.send(method_name).should_not be_nil
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "when the public key has already been taken" do
|
37
|
-
context "when response is success" do
|
38
|
-
before(:each) do
|
39
|
-
@project.name = @updated_name
|
40
|
-
register_show_uri
|
41
|
-
register_update_uri
|
42
|
-
@project.stub!(:exists?).and_return(true)
|
43
|
-
@project.save.should be_true
|
44
|
-
end
|
45
|
-
|
46
|
-
it "sets basic auth with the public and private key" do
|
47
|
-
Project.should_receive(:put).with("/projects/#{@project.public_key}", :query => {:project => {:name => @updated_name}}, :basic_auth => {:username => @project.public_key, :password => @project.private_key}).and_return(mock("response", :code => 401))
|
48
|
-
@project.save
|
49
|
-
end
|
50
|
-
|
51
|
-
it "updates the value of 'name' for the project associated with the supplied public key" do
|
52
|
-
# This seems like a pointless assertion, since it's being set in the before block, but it
|
53
|
-
# wouldn't be true if request was not successful, as #name is updated w/ the content
|
54
|
-
# returned in the response
|
55
|
-
@project.name.should == @updated_name
|
56
|
-
end
|
57
|
-
|
58
|
-
[ :public_key,
|
59
|
-
:private_key,
|
60
|
-
:short_uri,
|
61
|
-
:community_uri,
|
62
|
-
:name,
|
63
|
-
:api_uri].each do |method_name|
|
64
|
-
it "sets the '#{method_name.to_s}'" do
|
65
|
-
@project.send(method_name).should_not be_nil
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "respons is Unauthorized" do
|
71
|
-
before(:each) do
|
72
|
-
@updated_name = "different_name"
|
73
|
-
@project = CodeFumes::Project.new(:public_key => 'existing_public_key', :private_key => 'bad_key', :name => @updated_name)
|
74
|
-
FakeWeb.register_uri(:put, "http://#{@project.public_key}:#{@project.private_key}@codefumes.com/api/v1/xml/projects/existing_public_key?project[name]=#{@project.name}",
|
75
|
-
:status => ["401", "Unauthorized"])
|
76
|
-
@project.stub!(:exists?).and_return(true)
|
77
|
-
end
|
78
|
-
it "returns false" do
|
79
|
-
@project.save.should be_false
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "with invalid parameters" do
|
86
|
-
before(:each) do
|
87
|
-
register_show_uri(["404", "Not found"], "")
|
88
|
-
register_no_param_create_uri(["422", "Unprocessable Entity"], "")
|
89
|
-
end
|
90
|
-
|
91
|
-
it "does not set the 'private_key'" do
|
92
|
-
project = Project.new
|
93
|
-
project.save.should be_false
|
94
|
-
project.private_key.should be_nil
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
context "delete" do
|
100
|
-
before(:each) do
|
101
|
-
FakeWeb.register_uri( :delete, @authd_project_api_uri,
|
102
|
-
:status => ["200", "Successful"],
|
103
|
-
:body => "")
|
104
|
-
end
|
105
|
-
|
106
|
-
it "sets basic auth with the public and private key" do
|
107
|
-
Project.should_receive(:delete).with("/projects/#{@project.public_key}", :basic_auth => {:username => @project.public_key, :password => @project.private_key}).and_return(mock("response", :code => 401))
|
108
|
-
@project.delete
|
109
|
-
end
|
110
|
-
|
111
|
-
context "with Sucessful response" do
|
112
|
-
it "returns true" do
|
113
|
-
@project.delete.should be_true
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context "with Unauthorized response" do
|
118
|
-
it "returns false when invalid Unauthorized response is received" do
|
119
|
-
register_delete_uri(["401", "Unauthorized"], "")
|
120
|
-
@project.delete.should be_false
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe "exists?" do
|
126
|
-
context "when the specified public_key has been reserved already" do
|
127
|
-
it "returns true" do
|
128
|
-
register_show_uri
|
129
|
-
Project.new(:public_key => @pub_key).exists?.should be_true
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context "when the public_key is not set" do
|
134
|
-
it "returns false when the public key is nil" do
|
135
|
-
Project.new.exists?.should be_false
|
136
|
-
end
|
137
|
-
|
138
|
-
it "returns false when the public key is an empty string" do
|
139
|
-
Project.new(:public_key => "").exists?.should be_false
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
context "when the specified public_key is available" do
|
144
|
-
before(:each) do
|
145
|
-
register_show_uri(["404", "Not Found"], "")
|
146
|
-
end
|
147
|
-
|
148
|
-
it "returns false" do
|
149
|
-
Project.new(:public_key => @pub_key).exists?.should be_false
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe "to_config" do
|
155
|
-
before(:each) do
|
156
|
-
register_show_uri(["404", "Not Found"], "")
|
157
|
-
register_create_uri
|
158
|
-
@project.save
|
159
|
-
end
|
160
|
-
|
161
|
-
it "returns an object keyed by the project's public_key as a symbol" do
|
162
|
-
@project.to_config.should include(@project.public_key.to_sym)
|
163
|
-
end
|
164
|
-
|
165
|
-
context "the content under the project's public_key element" do
|
166
|
-
[:private_key, :api_uri, :short_uri].each do |project_attribute|
|
167
|
-
it "includes a key-value pair of ':#{project_attribute.to_s} => [project's #{project_attribute.to_s}]'" do
|
168
|
-
value = @project.send(project_attribute)
|
169
|
-
@project.to_config[@project.public_key.to_sym].should include(project_attribute => value)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
it "doesn't include the private_key in the hash if it is nil" do
|
175
|
-
public_key = "key_to_happiness"
|
176
|
-
Project.new(:public_key => public_key).to_config[public_key.to_sym].should_not have_key(:private_key)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
describe "claim" do
|
181
|
-
before(:each) do
|
182
|
-
@project = Project.new(:public_key => 'public_key_value', :private_key => 'private_key_value')
|
183
|
-
@api_key = "USERS_API_KEY"
|
184
|
-
ConfigFile.stub!(:credentials).and_return({:api_key => @api_key})
|
185
|
-
end
|
186
|
-
|
187
|
-
it "delegates the request to the Claim class" do
|
188
|
-
Claim.should_receive(:create).with(@project, @api_key)
|
189
|
-
@project.claim
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
describe "protected attributes" do
|
194
|
-
[:api_uri, :community_uri, :short_uri].each do |attribute_name|
|
195
|
-
it "values passed in during initiazation for '#{attribute_name.to_s}' are silently ignored" do
|
196
|
-
p = Project.new(attribute_name => Time.now.to_s)
|
197
|
-
p.send(attribute_name).should be_nil
|
198
|
-
end
|
199
|
-
|
200
|
-
it "calling '#{attribute_name.to_s}= [value]' is not supported" do
|
201
|
-
p = Project.new
|
202
|
-
lambda {p.send("#{attribute_name}=", "my_value")}.should raise_error
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
describe "accessible attributes" do
|
208
|
-
before(:each) do
|
209
|
-
@value = 'my_value'
|
210
|
-
end
|
211
|
-
|
212
|
-
[:public_key, :name].each do |attribute_name|
|
213
|
-
it "values for '#{attribute_name.to_s}' are allowed to be modified by the client" do
|
214
|
-
p = Project.new(attribute_name => @value )
|
215
|
-
p.send(attribute_name).should == @value
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
describe "calling the class method" do
|
221
|
-
describe "'find'" do
|
222
|
-
context "and specifying a public_key which is already associated to a project on the site" do
|
223
|
-
it "returns an initialized instance of the Project class" do
|
224
|
-
register_show_uri
|
225
|
-
expected_config = {
|
226
|
-
@pub_key.to_sym =>
|
227
|
-
{
|
228
|
-
:private_key=>"private_key_value",
|
229
|
-
:api_uri=>"http://codefumes.com/api/v1/xml/projects/#{@pub_key}.xml",
|
230
|
-
:short_uri=>"http://codefumes.com/p/#{@pub_key}"
|
231
|
-
}
|
232
|
-
}
|
233
|
-
Project.find(@pub_key).to_config.should == expected_config
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
context "and specifying a public_key which is not associated to any project on the site yet" do
|
238
|
-
before(:each) do
|
239
|
-
register_show_uri(["404", "Not Found"], "")
|
240
|
-
end
|
241
|
-
|
242
|
-
it "returns nil" do
|
243
|
-
Project.find(@pub_key).should == nil
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
describe "reinitialize" do
|
250
|
-
context "when the server has returned a build_status of 'running_build'" do
|
251
|
-
it "returns 'running'" do
|
252
|
-
project = Project.new
|
253
|
-
project.reinitialize!({'build_status' => "running_build"})
|
254
|
-
project.build_status.should == 'running'
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
context "when the server has returned a build_status of 'nobuilds'" do
|
259
|
-
it "returns 'nobuilds'" do
|
260
|
-
project = Project.new
|
261
|
-
project.reinitialize!({'build_status' => "nobuilds"})
|
262
|
-
project.build_status.should == 'nobuilds'
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
context "when the server has returned a build_status of ''" do
|
267
|
-
it "returns nil" do
|
268
|
-
project = Project.new
|
269
|
-
project.reinitialize!({'build_status' => ""})
|
270
|
-
project.build_status.should be_nil
|
271
|
-
end
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|