grendel-ruby 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/grendel-ruby.gemspec +2 -2
- data/lib/grendel/client.rb +3 -0
- data/spec/grendel/user_spec.rb +22 -8
- metadata +16 -16
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/grendel-ruby.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{grendel-ruby}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brad Greenlee"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-11}
|
13
13
|
s.description = %q{Grendel is a RESTful web service which allows for the secure storage of users'
|
14
14
|
documents. Grendel-Ruby provides a Ruby API for Grendel.}
|
15
15
|
s.email = %q{brad@wesabe.com}
|
data/lib/grendel/client.rb
CHANGED
@@ -58,7 +58,10 @@ module Grendel
|
|
58
58
|
end
|
59
59
|
|
60
60
|
class HTTPException < Exception
|
61
|
+
attr_reader :response
|
62
|
+
|
61
63
|
def initialize(response)
|
64
|
+
@response = response
|
62
65
|
msg = "#{response.code} #{response.message}"
|
63
66
|
msg << "\n#{response.body}" unless response.body.blank?
|
64
67
|
super(msg)
|
data/spec/grendel/user_spec.rb
CHANGED
@@ -4,43 +4,57 @@ describe "Grendel::User" do
|
|
4
4
|
before do
|
5
5
|
@client = Grendel::Client.new("http://grendel")
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
describe "new" do
|
9
9
|
it "should strip the protocol and host from the uri" do
|
10
10
|
user = Grendel::User.new(@client, :id => "alice", :uri => "http://grendel/users/alice")
|
11
11
|
user.uri.should == "/users/alice"
|
12
12
|
end
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
|
+
describe "find" do
|
16
|
+
context "a non-existent user" do
|
17
|
+
it "raises a HTTPException with response code 404" do
|
18
|
+
stub_json_request(:get, 'http://grendel/users/idontexist', "", :status => [404, "Not Found"])
|
19
|
+
begin
|
20
|
+
@client.users.find('idontexist', 'nordoi')
|
21
|
+
fail "HTTPException should have been raised but wasn't"
|
22
|
+
rescue Grendel::Client::HTTPException => e
|
23
|
+
e.response.code.should == 404
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
15
29
|
describe "change_password" do
|
16
30
|
before do
|
17
31
|
@old_password = "s3kret"
|
18
32
|
@new_password = "newpass"
|
19
33
|
@user = Grendel::User.new(@client, :id => "alice", :password => @old_password)
|
20
34
|
@url = "#{@user.id}:#{@user.password}@grendel/users/#{@user.id}"
|
21
|
-
stub_json_request(:put, @url, "", :status =>
|
35
|
+
stub_json_request(:put, @url, "", :status => [204, "No Content"])
|
22
36
|
end
|
23
|
-
|
37
|
+
|
24
38
|
it "should send a properly-formatted request" do
|
25
39
|
@user.change_password(@new_password)
|
26
40
|
params = { "password" => @new_password }
|
27
41
|
request(:put, @url).with(:body => params.to_json).should have_been_made.once
|
28
42
|
end
|
29
|
-
|
43
|
+
|
30
44
|
it "should return a User with the new password" do
|
31
45
|
lambda {
|
32
46
|
@user.change_password(@new_password)
|
33
47
|
}.should change(@user, :password).from(@old_password).to(@new_password)
|
34
48
|
end
|
35
49
|
end
|
36
|
-
|
50
|
+
|
37
51
|
describe "delete" do
|
38
52
|
before do
|
39
53
|
@user = Grendel::User.new(@client, :id => "alice", :password => "s3kret")
|
40
54
|
@url = "#{@user.id}:#{@user.password}@grendel/users/#{@user.id}"
|
41
|
-
stub_json_request(:delete, @url, "", :status =>
|
55
|
+
stub_json_request(:delete, @url, "", :status => [204, "No Content"])
|
42
56
|
end
|
43
|
-
|
57
|
+
|
44
58
|
it "should send a properly-formatted request" do
|
45
59
|
@user.delete
|
46
60
|
request(:delete, @url).should have_been_made.once
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 5
|
9
|
+
version: 0.1.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Brad Greenlee
|
@@ -14,45 +14,45 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-11 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
|
-
|
21
|
+
prerelease: false
|
22
|
+
type: :runtime
|
23
|
+
name: json
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
25
|
requirements:
|
23
26
|
- - ">="
|
24
27
|
- !ruby/object:Gem::Version
|
25
28
|
segments:
|
26
29
|
- 0
|
27
30
|
version: "0"
|
31
|
+
requirement: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
28
33
|
prerelease: false
|
29
34
|
type: :runtime
|
30
|
-
name:
|
31
|
-
version_requirements:
|
32
|
-
- !ruby/object:Gem::Dependency
|
33
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
35
|
+
name: httparty
|
36
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
34
37
|
requirements:
|
35
38
|
- - ">="
|
36
39
|
- !ruby/object:Gem::Version
|
37
40
|
segments:
|
38
41
|
- 0
|
39
42
|
version: "0"
|
43
|
+
requirement: *id002
|
44
|
+
- !ruby/object:Gem::Dependency
|
40
45
|
prerelease: false
|
41
46
|
type: :runtime
|
42
|
-
name:
|
43
|
-
version_requirements:
|
44
|
-
- !ruby/object:Gem::Dependency
|
45
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
47
|
+
name: mime-types
|
48
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
46
49
|
requirements:
|
47
50
|
- - ">="
|
48
51
|
- !ruby/object:Gem::Version
|
49
52
|
segments:
|
50
53
|
- 0
|
51
54
|
version: "0"
|
52
|
-
|
53
|
-
type: :runtime
|
54
|
-
name: mime-types
|
55
|
-
version_requirements: *id003
|
55
|
+
requirement: *id003
|
56
56
|
description: |-
|
57
57
|
Grendel is a RESTful web service which allows for the secure storage of users'
|
58
58
|
documents. Grendel-Ruby provides a Ruby API for Grendel.
|