codefumes 0.1.2 → 0.1.3
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/History.txt +11 -0
- data/Manifest.txt +9 -4
- data/README.txt +7 -3
- data/Rakefile +8 -2
- data/bin/cf_claim_project +9 -0
- data/bin/store_codefumes_credentials +10 -0
- data/lib/cf_claim_project/cli.rb +81 -0
- data/lib/codefumes/api.rb +7 -6
- data/lib/codefumes/claim.rb +24 -0
- data/lib/codefumes/commit.rb +16 -16
- data/lib/codefumes/config_file.rb +30 -9
- data/lib/codefumes/payload.rb +7 -7
- data/lib/codefumes/project.rb +28 -14
- data/lib/codefumes.rb +4 -3
- data/lib/store_codefumes_credentials/cli.rb +49 -0
- data/spec/cf_claim_project/cli_spec.rb +15 -0
- data/spec/codefumes/api_spec.rb +10 -3
- data/spec/codefumes/claim_spec.rb +30 -0
- data/spec/codefumes/commit_spec.rb +15 -99
- data/spec/codefumes/config_file_spec.rb +95 -8
- data/spec/codefumes/payload_spec.rb +6 -4
- data/spec/codefumes/project_spec.rb +18 -0
- data/spec/codefumes_service_stubs.rb +54 -0
- data/spec/spec_helper.rb +5 -7
- data/spec/store_codefumes_credentials/cli_spec.rb +22 -0
- data/tasks/rspec.rake +1 -0
- data/website/index.html +88 -50
- data/website/stylesheets/screen.css +36 -128
- metadata +35 -10
- data/config/website.yml.sample +0 -2
- data/website/index.txt +0 -55
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/template.html.erb +0 -50
@@ -1,49 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
|
-
|
4
|
-
commit_xml = <<-END_OF_COMMIT
|
5
|
-
<commit>
|
6
|
-
<identifier>f3badd5624dfbcf5176f0471261731e1b92ce957</identifier>
|
7
|
-
<author_name>John Doe</author_name>
|
8
|
-
<author_email>jdoe@example.com</author_email>
|
9
|
-
<committer_name>John Doe</committer_name>
|
10
|
-
<committer_email>jdoe@example.com</committer_email>
|
11
|
-
<short_message>Made command-line option for 'name' actually work</short_message>
|
12
|
-
<message>
|
13
|
-
Made command-line option for 'name' actually work
|
14
|
-
- Commentd out hard-coded 'require' line used for testing
|
15
|
-
</message>
|
16
|
-
<parent_identifiers>9ddj48423jdsjds5176f0471261731e1b92ce957,3ewdjok23jdsjds5176f0471261731e1b92ce957,284djsksjfjsjds5176f0471261731e1b92ce957</parent_identifiers>
|
17
|
-
<committed_at>Wed May 20 09:09:06 -0500 2009</committed_at>
|
18
|
-
<authored_at>Wed May 20 09:09:06 -0500 2009</authored_at>
|
19
|
-
<uploaded_at>2009-06-04 02:43:20 UTC</uploaded_at>
|
20
|
-
<api_uri>http://localhost:3000/api/v1/commits/f3badd5624dfbcf5176f0471261731e1b92ce957.xml</api_uri>
|
21
|
-
<line_additions>20</line_additions>
|
22
|
-
<line_deletions>10</line_deletions>
|
23
|
-
<line_total>30</line_total>
|
24
|
-
<affected_file_count>2</affected_file_count>
|
25
|
-
END_OF_COMMIT
|
26
|
-
|
27
|
-
if options[:include_custom_attributes]
|
28
|
-
commit_xml <<
|
29
|
-
<<-END_OF_COMMIT
|
30
|
-
<custom_attributes>
|
31
|
-
<coverage>83</coverage>
|
32
|
-
<random_attribute>1</random_attribute>
|
33
|
-
</custom_attributes>
|
34
|
-
END_OF_COMMIT
|
35
|
-
end
|
36
|
-
|
37
|
-
commit_xml << "\n</commit>"
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
def register_index_uri
|
42
|
-
FakeWeb.register_uri(
|
43
|
-
:get, "http://www.codefumes.com:80/api/v1/xml/projects/apk/commits",
|
44
|
-
:status => ["200", "Ok"],
|
45
|
-
:string => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<commits>\n#{single_commit}\n#{single_commit}\n#{single_commit}\n</commits>\n")
|
46
|
-
end
|
3
|
+
include CodeFumesServiceStubs
|
47
4
|
|
48
5
|
describe "Commit" do
|
49
6
|
before(:all) do
|
@@ -58,10 +15,7 @@ describe "Commit" do
|
|
58
15
|
describe "find" do
|
59
16
|
context "with a valid commit identifier" do
|
60
17
|
before(:each) do
|
61
|
-
|
62
|
-
:get, "http://www.codefumes.com:80/api/v1/xml/commits/f3badd5624dfbcf5176f0471261731e1b92ce957",
|
63
|
-
:status => ["200", "Ok"],
|
64
|
-
:string => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n#{single_commit}")
|
18
|
+
stub_codefumes_uri("commits/#{@identifier}", ["200", "Ok"], single_commit)
|
65
19
|
@commit = Commit.find(@identifier)
|
66
20
|
end
|
67
21
|
|
@@ -91,8 +45,7 @@ describe "Commit" do
|
|
91
45
|
context "with a non-existant commit identifier" do
|
92
46
|
before(:each) do
|
93
47
|
@identifier = "non_existant_commit_identifier"
|
94
|
-
|
95
|
-
:status => ["404", "Not Found"])
|
48
|
+
stub_codefumes_uri("commits/#{@identifier}", ["404", "Not Found"], "")
|
96
49
|
end
|
97
50
|
|
98
51
|
it "returns nil" do
|
@@ -104,14 +57,12 @@ describe "Commit" do
|
|
104
57
|
describe "calling 'latest'" do
|
105
58
|
before(:each) do
|
106
59
|
@project_public_key = "apk"
|
60
|
+
@request_uri = "projects/#{@project_public_key}/commits/latest"
|
107
61
|
end
|
108
62
|
|
109
63
|
context "with valid parameters" do
|
110
64
|
before(:each) do
|
111
|
-
|
112
|
-
:get, "http://www.codefumes.com:80/api/v1/xml/projects/#{@project_public_key}/commits/latest",
|
113
|
-
:status => ["200", "Ok"],
|
114
|
-
:string => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n#{single_commit}")
|
65
|
+
stub_codefumes_uri(@request_uri, ["200", "Ok"], single_commit)
|
115
66
|
end
|
116
67
|
|
117
68
|
it "returns a commit object for the latest commit" do
|
@@ -121,10 +72,7 @@ describe "Commit" do
|
|
121
72
|
|
122
73
|
context "with invalid parameters" do
|
123
74
|
before(:each) do
|
124
|
-
|
125
|
-
:get, "http://www.codefumes.com:80/api/v1/xml/projects/#{@project_public_key}/commits/latest",
|
126
|
-
:status => ["404", "Not Found"],
|
127
|
-
:string => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n#{single_commit}")
|
75
|
+
stub_codefumes_uri(@request_uri, ["404", "Not Found"], single_commit)
|
128
76
|
end
|
129
77
|
|
130
78
|
it "returns nil" do
|
@@ -136,45 +84,28 @@ describe "Commit" do
|
|
136
84
|
describe "calling 'latest_identifier'" do
|
137
85
|
before(:each) do
|
138
86
|
@project_public_key = "apk"
|
87
|
+
@request_uri = "projects/#{@project_public_key}/commits/latest"
|
139
88
|
end
|
140
89
|
|
141
90
|
context "with valid parameters" do
|
142
91
|
context "when the specified project has commits stored" do
|
143
|
-
before(:each) do
|
144
|
-
FakeWeb.register_uri(
|
145
|
-
:get, "http://www.codefumes.com:80/api/v1/xml/projects/#{@project_public_key}/commits/latest",
|
146
|
-
:status => ["200", "Ok"],
|
147
|
-
:string => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n#{single_commit}")
|
148
|
-
end
|
149
|
-
|
150
92
|
it "returns the commit identifier of the latest commit" do
|
93
|
+
stub_codefumes_uri(@request_uri, ["200", "Ok"], single_commit)
|
151
94
|
Commit.latest_identifier(@project_public_key).should == @identifier
|
152
95
|
end
|
153
96
|
end
|
154
97
|
|
155
98
|
context "when the specified project does not have any commits stored" do
|
156
|
-
before(:each) do
|
157
|
-
FakeWeb.register_uri(
|
158
|
-
:get, "http://www.codefumes.com:80/api/v1/xml/projects/#{@project_public_key}/commits/latest",
|
159
|
-
:status => ["404", "Not Found"],
|
160
|
-
:string => "")
|
161
|
-
end
|
162
|
-
|
163
99
|
it "returns nil" do
|
100
|
+
stub_codefumes_uri(@request_uri, ["404", "Not Found"], single_commit)
|
164
101
|
Commit.latest_identifier(@project_public_key).should == nil
|
165
102
|
end
|
166
103
|
end
|
167
104
|
end
|
168
105
|
|
169
106
|
context "with invalid parameters" do
|
170
|
-
before(:each) do
|
171
|
-
FakeWeb.register_uri(
|
172
|
-
:get, "http://www.codefumes.com:80/api/v1/xml/projects/#{@project_public_key}/commits/latest",
|
173
|
-
:status => ["404", "Not Found"],
|
174
|
-
:string => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n#{single_commit}")
|
175
|
-
end
|
176
|
-
|
177
107
|
it "returns nil" do
|
108
|
+
stub_codefumes_uri(@request_uri, ["404", "Not Found"], single_commit)
|
178
109
|
Commit.latest(@project_public_key).should == nil
|
179
110
|
end
|
180
111
|
end
|
@@ -182,25 +113,19 @@ describe "Commit" do
|
|
182
113
|
|
183
114
|
describe "calling 'all'" do
|
184
115
|
before(:each) do
|
185
|
-
register_index_uri
|
186
116
|
@project_public_key = "apk"
|
187
117
|
end
|
188
118
|
|
189
119
|
context "with valid parameters" do
|
190
120
|
it "returns an array of commits" do
|
121
|
+
register_index_uri
|
191
122
|
Commit.all(@project_public_key).should have(3).items
|
192
123
|
end
|
193
124
|
end
|
194
125
|
|
195
126
|
context "with invalid parameters" do
|
196
|
-
before(:each) do
|
197
|
-
FakeWeb.register_uri(
|
198
|
-
:get, "http://www.codefumes.com:80/api/v1/xml/projects/apk/commits",
|
199
|
-
:status => ["404", "Not Found"],
|
200
|
-
:string => "")
|
201
|
-
end
|
202
|
-
|
203
127
|
it "returns nil" do
|
128
|
+
stub_codefumes_uri("projects/apk/commits", ["404", "Not Found"], single_commit)
|
204
129
|
Commit.all(@project_public_key).should == nil
|
205
130
|
end
|
206
131
|
end
|
@@ -208,12 +133,9 @@ describe "Commit" do
|
|
208
133
|
|
209
134
|
describe "the convenience method" do
|
210
135
|
before(:each) do
|
136
|
+
stub_codefumes_uri("commits/f3badd5624dfbcf5176f0471261731e1b92ce957", ["200", "Ok"], single_commit)
|
211
137
|
@email = "jdoe@example.com"
|
212
138
|
@name = "John Doe"
|
213
|
-
FakeWeb.register_uri(
|
214
|
-
:get, "http://www.codefumes.com:80/api/v1/xml/commits/f3badd5624dfbcf5176f0471261731e1b92ce957",
|
215
|
-
:status => ["200", "Ok"],
|
216
|
-
:string => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n#{single_commit}")
|
217
139
|
@commit = Commit.find(@identifier)
|
218
140
|
end
|
219
141
|
|
@@ -239,10 +161,7 @@ describe "Commit" do
|
|
239
161
|
|
240
162
|
context "when the commit does not have any custom attributes" do
|
241
163
|
before(:each) do
|
242
|
-
|
243
|
-
:get, "http://www.codefumes.com:80/api/v1/xml/projects/#{@project_public_key}/commits/latest",
|
244
|
-
:status => ["200", "Ok"],
|
245
|
-
:string => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n#{single_commit}")
|
164
|
+
stub_codefumes_uri("projects/#{@project_public_key}/commits/latest", ["200", "Ok"], single_commit)
|
246
165
|
end
|
247
166
|
|
248
167
|
it "returns an empty Hash" do
|
@@ -253,10 +172,7 @@ describe "Commit" do
|
|
253
172
|
context "when the commit has defined custom attributes" do
|
254
173
|
before(:each) do
|
255
174
|
commit_content = single_commit(:include_custom_attributes => true)
|
256
|
-
|
257
|
-
:get, "http://www.codefumes.com:80/api/v1/xml/projects/#{@project_public_key}/commits/latest",
|
258
|
-
:status => ["200", "Ok"],
|
259
|
-
:string => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n#{commit_content}")
|
175
|
+
stub_codefumes_uri("projects/#{@project_public_key}/commits/latest", ["200", "Ok"], commit_content)
|
260
176
|
end
|
261
177
|
|
262
178
|
it "returns a Hash of key-value pairs (attribute_name -> attribute_value)" do
|
@@ -1,14 +1,24 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
|
+
def raise_if_users_config_file
|
4
|
+
if ConfigFile.path == File.expand_path('~/.codefumes_config')
|
5
|
+
raise "Set a custom config file path"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def delete_config_file
|
10
|
+
unless ConfigFile.path == File.expand_path('~/.codefumes_config')
|
11
|
+
File.delete(ConfigFile.path) if File.exist?(ConfigFile.path)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
3
15
|
describe "ConfigFile" do
|
4
16
|
before(:each) do
|
5
17
|
@project = Project.new(:public_key => 'public_key_value', :private_key => 'private_key_value')
|
6
18
|
end
|
7
19
|
|
8
20
|
after(:all) do
|
9
|
-
|
10
|
-
File.delete(ConfigFile.path) if File.exist?(ConfigFile.path)
|
11
|
-
end
|
21
|
+
delete_config_file
|
12
22
|
end
|
13
23
|
|
14
24
|
describe "calling 'path'" do
|
@@ -27,10 +37,6 @@ describe "ConfigFile" do
|
|
27
37
|
end
|
28
38
|
|
29
39
|
describe "calling 'save_project'" do
|
30
|
-
after(:all) do
|
31
|
-
File.delete(ConfigFile.path) if File.exist?(ConfigFile.path)
|
32
|
-
end
|
33
|
-
|
34
40
|
context "when passed a new project" do
|
35
41
|
it "creates the config file if it did not exist already" do
|
36
42
|
File.exist?(ConfigFile.path).should be_false
|
@@ -131,12 +137,93 @@ describe "ConfigFile" do
|
|
131
137
|
|
132
138
|
context "via path=" do
|
133
139
|
it "updates the value returned from 'path'" do
|
134
|
-
new_path = File.expand_path('
|
140
|
+
new_path = File.expand_path(File.dirname(__FILE__) + '/../new_config')
|
135
141
|
ConfigFile.path.should == File.expand_path('~/.codefumes_config')
|
136
142
|
ConfigFile.path = new_path
|
137
143
|
ConfigFile.path.should == new_path
|
138
144
|
end
|
139
145
|
end
|
140
146
|
end
|
147
|
+
|
148
|
+
describe "calling 'save_credentials'" do
|
149
|
+
before(:each) do
|
150
|
+
@api_key = "API_KEY"
|
151
|
+
end
|
152
|
+
|
153
|
+
context "when no credentials exist" do
|
154
|
+
before(:each) do
|
155
|
+
raise_if_users_config_file
|
156
|
+
end
|
157
|
+
|
158
|
+
it "adds a :credentials key" do
|
159
|
+
ConfigFile.save_credentials(@api_key)
|
160
|
+
ConfigFile.serialized.keys.should include(:credentials)
|
161
|
+
end
|
162
|
+
|
163
|
+
it "adds the supplied api_key under the credentials key" do
|
164
|
+
ConfigFile.save_credentials(@api_key)
|
165
|
+
ConfigFile.serialized[:credentials][:api_key].should == @api_key
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
context "when credentials already exist" do
|
170
|
+
before(:each) do
|
171
|
+
@existing_api_key = "EXISTING_API_KEY"
|
172
|
+
ConfigFile.save_credentials(@existing_api_key)
|
173
|
+
end
|
141
174
|
|
175
|
+
it "replaces the existing credentials with the supplied api_key" do
|
176
|
+
# sanity check
|
177
|
+
ConfigFile.serialized[:credentials][:api_key].should == @existing_api_key
|
178
|
+
ConfigFile.save_credentials(@api_key)
|
179
|
+
ConfigFile.serialized[:credentials][:api_key].should == @api_key
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
it "does not affect existing project content" do
|
184
|
+
public_key = "pub_value"
|
185
|
+
project = Project.new(:public_key => public_key, :private_key => "private_key")
|
186
|
+
ConfigFile.save_project(project)
|
187
|
+
ConfigFile.save_credentials(@api_key)
|
188
|
+
ConfigFile.serialized[:projects][public_key.to_sym].should_not be_nil
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe "calling 'credentials'" do
|
193
|
+
context "when credentials exist in the file" do
|
194
|
+
it "returns a Hash containing the credentials section of the config file" do
|
195
|
+
api_key_value = "API_KEY"
|
196
|
+
ConfigFile.save_credentials(api_key_value)
|
197
|
+
ConfigFile.credentials.should == {:api_key => api_key_value}
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
context "when no credentials exist in the file" do
|
202
|
+
it "returns an empty Hash" do
|
203
|
+
ConfigFile.credentials.should == {}
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
describe "calling 'public_keys'" do
|
209
|
+
context "when no projects exist in the file" do
|
210
|
+
it "returns an empty array" do
|
211
|
+
delete_config_file
|
212
|
+
ConfigFile.public_keys.should == []
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
context "when projects exist in the file" do
|
217
|
+
before(:each) do
|
218
|
+
create_uniq_project = lambda {|index| Project.new(:public_key => "pub_key_#{index}", :private_key => 'pk')}
|
219
|
+
@projects = 5.times.map {|i| create_uniq_project.call(i)}
|
220
|
+
@projects.each {|project| ConfigFile.save_project(project)}
|
221
|
+
end
|
222
|
+
|
223
|
+
it "returns an array of the keys" do
|
224
|
+
stringified_keys = ConfigFile.public_keys.map {|key| key.to_s}
|
225
|
+
stringified_keys.sort.should == @projects.map {|p| p.public_key}.sort
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
142
229
|
end
|
@@ -17,11 +17,13 @@ describe "Payload" do
|
|
17
17
|
:status => ["201", "Created"],
|
18
18
|
:string => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<payload>\n <created_at>Creation Date</created_at>\n </payload>\n")
|
19
19
|
end
|
20
|
+
|
20
21
|
it "sets basic auth with the public and private key" do
|
21
22
|
payload = Payload.new(:public_key => @project.public_key, :private_key => @project.private_key, :content => {:commits => "data_to_send_up"})
|
22
23
|
Payload.should_receive(:post).with("/projects/#{@project.public_key}/payloads", :query => {:payload => {:commits => "data_to_send_up"}}, :basic_auth => {:username => @project.public_key, :password => @project.private_key}).and_return(mock("response", :code => 401))
|
23
24
|
payload.save
|
24
25
|
end
|
26
|
+
|
25
27
|
context "with Created response" do
|
26
28
|
[:created_at].each do |method_name|
|
27
29
|
it "sets the '#{method_name.to_s}'" do
|
@@ -32,12 +34,14 @@ describe "Payload" do
|
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
37
|
+
|
35
38
|
context "with Unauthorized response" do
|
36
39
|
before(:each) do
|
37
40
|
@project = Project.new(:public_key => "apk")
|
38
41
|
FakeWeb.register_uri( :post, "http://www.codefumes.com:80/api/v1/xml/projects/apk/payloads?payload[commits]=data_to_send_up",
|
39
42
|
:status => ["401", "Unauthorized"])
|
40
43
|
end
|
44
|
+
|
41
45
|
[:created_at].each do |method_name|
|
42
46
|
it "sets the '#{method_name.to_s}'" do
|
43
47
|
payload = Payload.new(:public_key => @project.public_key, :content => {:commits => "data_to_send_up"})
|
@@ -122,6 +126,7 @@ describe "Payload" do
|
|
122
126
|
@prepared.size.should == 1
|
123
127
|
@prepared.first.should be_instance_of(Payload)
|
124
128
|
end
|
129
|
+
|
125
130
|
it "sets the private_key on all payloads" do
|
126
131
|
@prepared.each do |payload|
|
127
132
|
payload.project_private_key.should == 'something_super_secret'
|
@@ -146,15 +151,12 @@ describe "Payload" do
|
|
146
151
|
all_are_payloads = @prepared.all? {|chunk| chunk.instance_of?(Payload)}
|
147
152
|
all_are_payloads.should == true
|
148
153
|
end
|
149
|
-
|
154
|
+
|
150
155
|
it "sets the private_key on all payloads" do
|
151
156
|
@prepared.each do |payload|
|
152
157
|
payload.project_private_key.should == 'something_super_secret'
|
153
158
|
end
|
154
159
|
end
|
155
|
-
|
156
|
-
it "the first payload contains approximately 10,000 characters"
|
157
|
-
it "the second payload contains approximately 5,000 characters"
|
158
160
|
end
|
159
161
|
end
|
160
162
|
end
|
@@ -19,6 +19,7 @@ def register_show_uri(public_key = "public_key_value", project_name = "The Proje
|
|
19
19
|
|
20
20
|
end
|
21
21
|
|
22
|
+
|
22
23
|
describe "Project" do
|
23
24
|
before(:each) do
|
24
25
|
end
|
@@ -119,15 +120,18 @@ describe "Project" do
|
|
119
120
|
:status => ["200", "Successful"],
|
120
121
|
:string => "")
|
121
122
|
end
|
123
|
+
|
122
124
|
it "sets basic auth with the public and private key" do
|
123
125
|
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))
|
124
126
|
@project.delete
|
125
127
|
end
|
128
|
+
|
126
129
|
context "with Sucessful response" do
|
127
130
|
it "returns true" do
|
128
131
|
@project.delete.should be_true
|
129
132
|
end
|
130
133
|
end
|
134
|
+
|
131
135
|
context "with Unauthorized response" do
|
132
136
|
before(:each) do
|
133
137
|
@project = Project.new(:public_key => 'public_key_value')
|
@@ -135,6 +139,7 @@ describe "Project" do
|
|
135
139
|
:status => ["401", "Unauthorized"],
|
136
140
|
:string => "")
|
137
141
|
end
|
142
|
+
|
138
143
|
it "returns false when invalid Unauthorized response is received" do
|
139
144
|
@project.delete.should be_false
|
140
145
|
end
|
@@ -211,6 +216,19 @@ describe "Project" do
|
|
211
216
|
end
|
212
217
|
end
|
213
218
|
|
219
|
+
describe "claim" do
|
220
|
+
before(:each) do
|
221
|
+
@project = Project.new(:public_key => 'public_key_value', :private_key => 'private_key_value')
|
222
|
+
@api_key = "USERS_API_KEY"
|
223
|
+
ConfigFile.stub!(:credentials).and_return({:api_key => @api_key})
|
224
|
+
end
|
225
|
+
|
226
|
+
it "delegates the request to the Claim class" do
|
227
|
+
Claim.should_receive(:create).with(@project, @api_key)
|
228
|
+
@project.claim
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
214
232
|
describe "protected attributes" do
|
215
233
|
[:api_uri, :community_uri, :short_uri].each do |attribute_name|
|
216
234
|
it "values passed in during initiazation for '#{attribute_name.to_s}' are silently ignored" do
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module CodeFumesServiceStubs
|
2
|
+
def single_commit(options = {})
|
3
|
+
commit_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
4
|
+
commit_xml += <<-END_OF_COMMIT
|
5
|
+
<commit>
|
6
|
+
<identifier>f3badd5624dfbcf5176f0471261731e1b92ce957</identifier>
|
7
|
+
<author_name>John Doe</author_name>
|
8
|
+
<author_email>jdoe@example.com</author_email>
|
9
|
+
<committer_name>John Doe</committer_name>
|
10
|
+
<committer_email>jdoe@example.com</committer_email>
|
11
|
+
<short_message>Made command-line option for 'name' actually work</short_message>
|
12
|
+
<message>
|
13
|
+
Made command-line option for 'name' actually work
|
14
|
+
- Commentd out hard-coded 'require' line used for testing
|
15
|
+
</message>
|
16
|
+
<parent_identifiers>9ddj48423jdsjds5176f0471261731e1b92ce957,3ewdjok23jdsjds5176f0471261731e1b92ce957,284djsksjfjsjds5176f0471261731e1b92ce957</parent_identifiers>
|
17
|
+
<committed_at>Wed May 20 09:09:06 -0500 2009</committed_at>
|
18
|
+
<authored_at>Wed May 20 09:09:06 -0500 2009</authored_at>
|
19
|
+
<uploaded_at>2009-06-04 02:43:20 UTC</uploaded_at>
|
20
|
+
<api_uri>http://localhost:3000/api/v1/commits/f3badd5624dfbcf5176f0471261731e1b92ce957.xml</api_uri>
|
21
|
+
<line_additions>20</line_additions>
|
22
|
+
<line_deletions>10</line_deletions>
|
23
|
+
<line_total>30</line_total>
|
24
|
+
<affected_file_count>2</affected_file_count>
|
25
|
+
END_OF_COMMIT
|
26
|
+
|
27
|
+
if options[:include_custom_attributes]
|
28
|
+
commit_xml <<
|
29
|
+
<<-END_OF_COMMIT
|
30
|
+
<custom_attributes>
|
31
|
+
<coverage>83</coverage>
|
32
|
+
<random_attribute>1</random_attribute>
|
33
|
+
</custom_attributes>
|
34
|
+
END_OF_COMMIT
|
35
|
+
end
|
36
|
+
|
37
|
+
commit_xml << "\n</commit>"
|
38
|
+
end
|
39
|
+
|
40
|
+
def register_index_uri
|
41
|
+
FakeWeb.register_uri(
|
42
|
+
:get, "http://www.codefumes.com:80/api/v1/xml/projects/apk/commits",
|
43
|
+
:status => ["200", "Ok"],
|
44
|
+
:string => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<commits>\n#{single_commit}\n#{single_commit}\n#{single_commit}\n</commits>\n")
|
45
|
+
end
|
46
|
+
|
47
|
+
def stub_codefumes_uri(api_uri, status, response_string)
|
48
|
+
FakeWeb.register_uri(
|
49
|
+
:get, "http://www.codefumes.com:80/api/v1/xml/#{api_uri}",
|
50
|
+
:status => status,
|
51
|
+
:string => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n#{response_string}")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
|
-
require '
|
1
|
+
require 'ruby-debug'
|
2
|
+
require 'fakeweb'
|
2
3
|
|
3
4
|
begin
|
4
5
|
require 'spec/autorun'
|
5
6
|
rescue LoadError
|
6
|
-
gem 'rspec'
|
7
7
|
require 'spec'
|
8
8
|
end
|
9
9
|
|
10
|
-
gem 'ruby-debug'
|
11
|
-
require 'ruby-debug'
|
12
|
-
|
13
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
14
10
|
require 'codefumes'
|
15
|
-
|
11
|
+
|
12
|
+
# CodeFumes service 'fixtures'
|
13
|
+
require 'spec/codefumes_service_stubs'
|
16
14
|
|
17
15
|
include CodeFumes
|
18
16
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec/spec_helper'
|
2
|
+
require 'lib/store_codefumes_credentials/cli'
|
3
|
+
|
4
|
+
describe StoreCodefumesCredentials::CLI, "execute" do
|
5
|
+
after(:all) do
|
6
|
+
unless ConfigFile.path == File.expand_path('~/.codefumes_config')
|
7
|
+
File.delete(ConfigFile.path) if File.exist?(ConfigFile.path)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
@api_key_value = "API_KEY"
|
13
|
+
@stdout_io = StringIO.new
|
14
|
+
StoreCodefumesCredentials::CLI.execute(@stdout_io, [@api_key_value])
|
15
|
+
@stdout_io.rewind
|
16
|
+
@stdout = @stdout_io.read
|
17
|
+
end
|
18
|
+
|
19
|
+
it "store the value supplied as an argument in the config file" do
|
20
|
+
ConfigFile.credentials.keys.should include(:api_key)
|
21
|
+
end
|
22
|
+
end
|