ripple 0.5.1 → 0.6.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/CONTRIBUTORS.textile +1 -0
- data/README.textile +6 -4
- data/RELEASE_NOTES.textile +20 -0
- data/VERSION +1 -1
- data/lib/riak/bucket.rb +52 -2
- data/lib/riak/client.rb +2 -2
- data/lib/riak/client/curb_backend.rb +42 -23
- data/lib/riak/link.rb +4 -4
- data/lib/riak/map_reduce.rb +9 -1
- data/lib/riak/robject.rb +30 -7
- data/lib/riak/util/fiber1.8.rb +48 -0
- data/lib/riak/walk_spec.rb +1 -1
- data/lib/ripple.rb +3 -1
- data/lib/ripple/document.rb +4 -3
- data/lib/ripple/document/attribute_methods.rb +1 -1
- data/lib/ripple/document/finders.rb +5 -4
- data/lib/ripple/document/timestamps.rb +22 -0
- data/lib/ripple/embedded_document.rb +1 -0
- data/lib/ripple/locale/en.yml +2 -1
- data/ripple.gemspec +6 -2
- data/spec/fixtures/multipart-with-body.txt +2 -2
- data/spec/riak/bucket_spec.rb +79 -8
- data/spec/riak/client_spec.rb +4 -4
- data/spec/riak/http_backend_spec.rb +8 -8
- data/spec/riak/link_spec.rb +12 -12
- data/spec/riak/map_reduce_spec.rb +5 -0
- data/spec/riak/object_spec.rb +54 -16
- data/spec/riak/walk_spec_spec.rb +1 -1
- data/spec/ripple/finders_spec.rb +19 -19
- data/spec/ripple/persistence_spec.rb +4 -4
- data/spec/ripple/ripple_spec.rb +1 -0
- data/spec/ripple/timestamps_spec.rb +49 -0
- data/spec/support/http_backend_implementation_examples.rb +36 -36
- metadata +6 -2
data/spec/riak/walk_spec_spec.rb
CHANGED
@@ -127,7 +127,7 @@ describe Riak::WalkSpec do
|
|
127
127
|
|
128
128
|
describe "matching links" do
|
129
129
|
before :each do
|
130
|
-
@link = Riak::Link.new("/
|
130
|
+
@link = Riak::Link.new("/riak/foo/bar", "next")
|
131
131
|
end
|
132
132
|
|
133
133
|
it "should match a link when the bucket and tag are not specified" do
|
data/spec/ripple/finders_spec.rb
CHANGED
@@ -37,7 +37,7 @@ describe Ripple::Document::Finders do
|
|
37
37
|
|
38
38
|
describe "finding single documents" do
|
39
39
|
it "should find a single document by key and assign its attributes" do
|
40
|
-
@http.should_receive(:get).with(200, "/
|
40
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "square", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"square"}'})
|
41
41
|
box = Box.find("square")
|
42
42
|
box.should be_kind_of(Box)
|
43
43
|
box.shape.should == "square"
|
@@ -47,21 +47,21 @@ describe Ripple::Document::Finders do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should return nil when no object exists at that key" do
|
50
|
-
@http.should_receive(:get).with(200, "/
|
50
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "square", {}, {}).and_raise(Riak::FailedRequest.new(:get, 200, 404, {}, "404 not found"))
|
51
51
|
box = Box.find("square")
|
52
52
|
box.should be_nil
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should re-raise the failed request exception if not a 404" do
|
56
|
-
@http.should_receive(:get).with(200, "/
|
56
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "square", {}, {}).and_raise(Riak::FailedRequest.new(:get, 200, 500, {}, "500 internal server error"))
|
57
57
|
lambda { Box.find("square") }.should raise_error(Riak::FailedRequest)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
describe "finding multiple documents" do
|
62
62
|
it "should find multiple documents by the keys" do
|
63
|
-
@http.should_receive(:get).with(200, "/
|
64
|
-
@http.should_receive(:get).with(200, "/
|
63
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "square", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"square"}'})
|
64
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "rectangle", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"rectangle"}'})
|
65
65
|
boxes = Box.find("square", "rectangle")
|
66
66
|
boxes.should have(2).items
|
67
67
|
boxes.first.shape.should == "square"
|
@@ -69,8 +69,8 @@ describe Ripple::Document::Finders do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should return nil for documents that no longer exist" do
|
72
|
-
@http.should_receive(:get).with(200, "/
|
73
|
-
@http.should_receive(:get).with(200, "/
|
72
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "square", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"square"}'})
|
73
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "rectangle", {}, {}).and_raise(Riak::FailedRequest.new(:get, 200, 404, {}, "404 not found"))
|
74
74
|
boxes = Box.find("square", "rectangle")
|
75
75
|
boxes.should have(2).items
|
76
76
|
boxes.first.shape.should == "square"
|
@@ -81,8 +81,8 @@ describe Ripple::Document::Finders do
|
|
81
81
|
describe "finding all documents in the bucket" do
|
82
82
|
it "should load all objects in the bucket" do
|
83
83
|
@bucket.should_receive(:keys).and_return(["square", "rectangle"])
|
84
|
-
@http.should_receive(:get).with(200, "/
|
85
|
-
@http.should_receive(:get).with(200, "/
|
84
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "square", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"square"}'})
|
85
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "rectangle", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"rectangle"}'})
|
86
86
|
boxes = Box.all
|
87
87
|
boxes.should have(2).items
|
88
88
|
boxes.first.shape.should == "square"
|
@@ -91,17 +91,17 @@ describe Ripple::Document::Finders do
|
|
91
91
|
|
92
92
|
it "should exclude objects that are not found" do
|
93
93
|
@bucket.should_receive(:keys).and_return(["square", "rectangle"])
|
94
|
-
@http.should_receive(:get).with(200, "/
|
95
|
-
@http.should_receive(:get).with(200, "/
|
94
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "square", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"square"}'})
|
95
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "rectangle", {}, {}).and_raise(Riak::FailedRequest.new(:get, 200, 404, {}, "404 not found"))
|
96
96
|
boxes = Box.all
|
97
97
|
boxes.should have(1).item
|
98
98
|
boxes.first.shape.should == "square"
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should yield found objects to the passed block and return an empty array" do
|
102
|
-
@bucket.should_receive(:keys).and_yield("square").and_yield("rectangle")
|
103
|
-
@http.should_receive(:get).with(200, "/
|
104
|
-
@http.should_receive(:get).with(200, "/
|
102
|
+
@bucket.should_receive(:keys).and_yield(["square"]).and_yield(["rectangle"])
|
103
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "square", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"square"}'})
|
104
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "rectangle", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"rectangle"}'})
|
105
105
|
@block = mock()
|
106
106
|
@block.should_receive(:ping).twice
|
107
107
|
Box.all do |box|
|
@@ -111,9 +111,9 @@ describe Ripple::Document::Finders do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should yield found objects to the passed block, excluding missing objects, and return an empty array" do
|
114
|
-
@bucket.should_receive(:keys).and_yield("square").and_yield("rectangle")
|
115
|
-
@http.should_receive(:get).with(200, "/
|
116
|
-
@http.should_receive(:get).with(200, "/
|
114
|
+
@bucket.should_receive(:keys).and_yield(["square"]).and_yield(["rectangle"])
|
115
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "square", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"square"}'})
|
116
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "rectangle", {}, {}).and_raise(Riak::FailedRequest.new(:get, 200, 404, {}, "404 not found"))
|
117
117
|
@block = mock()
|
118
118
|
@block.should_receive(:ping).once
|
119
119
|
Box.all do |box|
|
@@ -129,8 +129,8 @@ describe Ripple::Document::Finders do
|
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should instantiate as the proper type if defined in the document" do
|
132
|
-
@http.should_receive(:get).with(200, "/
|
133
|
-
@http.should_receive(:get).with(200, "/
|
132
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "square", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"square"}'})
|
133
|
+
@http.should_receive(:get).with(200, "/riak/", "boxes", "rectangle", {}, {}).and_return({:code => 200, :headers => {"content-type" => ["application/json"]}, :body => '{"shape":"rectangle", "_type":"CardboardBox"}'})
|
134
134
|
boxes = Box.find("square", "rectangle")
|
135
135
|
boxes.should have(2).items
|
136
136
|
boxes.first.should_not be_kind_of(CardboardBox)
|
@@ -35,7 +35,7 @@ describe Ripple::Document::Persistence do
|
|
35
35
|
|
36
36
|
it "should save a new object to Riak" do
|
37
37
|
json = @widget.attributes.merge("_type" => "Widget").to_json
|
38
|
-
@http.should_receive(:post).with(201, "/
|
38
|
+
@http.should_receive(:post).with(201, "/riak/", "widgets", an_instance_of(Hash), json, hash_including("Content-Type" => "application/json")).and_return(:code => 201, :headers => {'location' => ["/riak/widgets/new_widget"]})
|
39
39
|
@widget.save
|
40
40
|
@widget.key.should == "new_widget"
|
41
41
|
@widget.should_not be_new_record
|
@@ -44,7 +44,7 @@ describe Ripple::Document::Persistence do
|
|
44
44
|
|
45
45
|
it "should reload a saved object" do
|
46
46
|
json = @widget.attributes.merge("_type" => "Widget").to_json
|
47
|
-
@http.should_receive(:post).with(201, "/
|
47
|
+
@http.should_receive(:post).with(201, "/riak/", "widgets", an_instance_of(Hash), json, hash_including("Content-Type" => "application/json")).and_return(:code => 201, :headers => {'location' => ["/riak/widgets/new_widget"]})
|
48
48
|
@widget.save
|
49
49
|
@http.should_receive(:get).and_return(:code => 200, :headers => {'content-type' => ["application/json"]}, :body => '{"name":"spring","size":10}')
|
50
50
|
@widget.reload
|
@@ -54,7 +54,7 @@ describe Ripple::Document::Persistence do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should destroy a saved object" do
|
57
|
-
@http.should_receive(:post).and_return(:code => 201, :headers => {'location' => ["/
|
57
|
+
@http.should_receive(:post).and_return(:code => 201, :headers => {'location' => ["/riak/widgets/new_widget"]})
|
58
58
|
@widget.save
|
59
59
|
@http.should_receive(:delete).and_return(:code => 204, :headers => {})
|
60
60
|
@widget.destroy.should be_true
|
@@ -78,7 +78,7 @@ describe Ripple::Document::Persistence do
|
|
78
78
|
|
79
79
|
it "should store the _type field as the class name" do
|
80
80
|
json = @cog.attributes.merge("_type" => "Cog").to_json
|
81
|
-
@http.should_receive(:post).and_return(:code => 201, :headers => {'location' => ["/
|
81
|
+
@http.should_receive(:post).and_return(:code => 201, :headers => {'location' => ["/riak/widgets/new_widget"]})
|
82
82
|
@cog.save
|
83
83
|
@cog.should_not be_new_record
|
84
84
|
end
|
data/spec/ripple/ripple_spec.rb
CHANGED
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Ripple::Document::Timestamps do
|
4
|
+
|
5
|
+
before :all do
|
6
|
+
Object.module_eval { class Box; include Ripple::Document; property :shape, String; timestamps! end }
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
response = {:headers => {"content-type" => ["application/json"]}, :body => "{}"}
|
11
|
+
@client = Ripple.client
|
12
|
+
@http = mock("HTTP Backend", :get => response, :put => response, :post => response, :delete => response)
|
13
|
+
@client.stub!(:http).and_return(@http)
|
14
|
+
@box = Box.new
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should add a created_at property" do
|
18
|
+
@box.should respond_to(:created_at)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should add an updated_at property" do
|
22
|
+
@box.should respond_to(:updated_at)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should set the created_at timestamp when the object is initialized" do
|
26
|
+
@box.created_at.should_not be_nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not set the updated_at timestamp when the object is initialized" do
|
30
|
+
@box.updated_at.should be_nil
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should set the updated_at timestamp when the object is created" do
|
34
|
+
@box.save
|
35
|
+
@box.updated_at.should_not be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should update the updated_at timestamp when the object is updated" do
|
39
|
+
@box.save
|
40
|
+
start = @box.updated_at
|
41
|
+
@box.save
|
42
|
+
@box.updated_at.should > start
|
43
|
+
end
|
44
|
+
|
45
|
+
after :all do
|
46
|
+
Object.send(:remove_const, :Box)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -14,52 +14,52 @@
|
|
14
14
|
shared_examples_for "HTTP backend" do
|
15
15
|
describe "HEAD requests" do
|
16
16
|
before :each do
|
17
|
-
setup_http_mock(:head, @backend.path("/
|
17
|
+
setup_http_mock(:head, @backend.path("/riak/","foo").to_s, :body => "")
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should return only the headers when the request succeeds" do
|
21
|
-
response = @backend.head(200, "/
|
21
|
+
response = @backend.head(200, "/riak/","foo")
|
22
22
|
response.should_not have_key(:body)
|
23
23
|
response[:headers].should be_kind_of(Hash)
|
24
24
|
response[:code].should == 200
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should raise a FailedRequest exception when the request fails" do
|
28
|
-
lambda { @backend.head(301, "/
|
28
|
+
lambda { @backend.head(301, "/riak/", "foo") }.should raise_error(Riak::FailedRequest)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should raise an error if an invalid resource path is given" do
|
32
|
-
lambda { @backend.head(200, "/
|
32
|
+
lambda { @backend.head(200, "/riak/") }.should raise_error(ArgumentError)
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should not raise a FailedRequest if one of the expected response codes matches" do
|
36
|
-
lambda { @backend.head([200, 301], "/
|
36
|
+
lambda { @backend.head([200, 301], "/riak/", "foo") }.should_not raise_error(Riak::FailedRequest)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe "GET requests" do
|
41
41
|
before :each do
|
42
|
-
setup_http_mock(:get, @backend.path("/
|
42
|
+
setup_http_mock(:get, @backend.path("/riak/","foo").to_s, :body => "Success!")
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should return the response body and headers when the request succeeds" do
|
46
|
-
response = @backend.get(200, "/
|
46
|
+
response = @backend.get(200, "/riak/","foo")
|
47
47
|
response[:body].should == "Success!"
|
48
48
|
response[:headers].should be_kind_of(Hash)
|
49
49
|
response[:code].should == 200
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should raise a FailedRequest exception when the request fails" do
|
53
|
-
lambda { @backend.get(304, "/
|
53
|
+
lambda { @backend.get(304, "/riak/","foo") }.should raise_error(Riak::FailedRequest)
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should not raise a FailedRequest if one of the expected response codes matches" do
|
57
|
-
lambda { @backend.get([200, 301], "/
|
57
|
+
lambda { @backend.get([200, 301], "/riak/","foo") }.should_not raise_error(Riak::FailedRequest)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should yield successive chunks of the response to the given block but not return the entire body" do
|
61
61
|
chunks = ""
|
62
|
-
response = @backend.get(200, "/
|
62
|
+
response = @backend.get(200, "/riak/","foo") do |chunk|
|
63
63
|
chunks << chunk
|
64
64
|
end
|
65
65
|
chunks.should == "Success!"
|
@@ -69,32 +69,32 @@ shared_examples_for "HTTP backend" do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "should raise an error if an invalid resource path is given" do
|
72
|
-
lambda { @backend.get(200, "/
|
72
|
+
lambda { @backend.get(200, "/riak/") }.should raise_error(ArgumentError)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
76
|
describe "DELETE requests" do
|
77
77
|
before :each do
|
78
|
-
setup_http_mock(:delete, @backend.path("/
|
78
|
+
setup_http_mock(:delete, @backend.path("/riak/","foo").to_s, :body => "Success!")
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should return the response body and headers when the request succeeds" do
|
82
|
-
response = @backend.delete(200, "/
|
82
|
+
response = @backend.delete(200, "/riak/","foo")
|
83
83
|
response[:body].should == "Success!"
|
84
84
|
response[:headers].should be_kind_of(Hash)
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should raise a FailedRequest exception when the request fails" do
|
88
|
-
lambda { @backend.delete(304, "/
|
88
|
+
lambda { @backend.delete(304, "/riak/","foo") }.should raise_error(Riak::FailedRequest)
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should not raise a FailedRequest if one of the expected response codes matches" do
|
92
|
-
lambda { @backend.delete([200, 301], "/
|
92
|
+
lambda { @backend.delete([200, 301], "/riak/","foo") }.should_not raise_error(Riak::FailedRequest)
|
93
93
|
end
|
94
94
|
|
95
95
|
it "should yield successive chunks of the response to the given block but not return the entire body" do
|
96
96
|
chunks = ""
|
97
|
-
response = @backend.delete(200, "/
|
97
|
+
response = @backend.delete(200, "/riak/","foo") do |chunk|
|
98
98
|
chunks << chunk
|
99
99
|
end
|
100
100
|
chunks.should == "Success!"
|
@@ -104,34 +104,34 @@ shared_examples_for "HTTP backend" do
|
|
104
104
|
end
|
105
105
|
|
106
106
|
it "should raise an error if an invalid resource path is given" do
|
107
|
-
lambda { @backend.delete(200, "/
|
107
|
+
lambda { @backend.delete(200, "/riak/") }.should raise_error(ArgumentError)
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
111
|
describe "PUT requests" do
|
112
112
|
before :each do
|
113
|
-
setup_http_mock(:put, @backend.path("/
|
113
|
+
setup_http_mock(:put, @backend.path("/riak/","foo").to_s, :body => "Success!")
|
114
114
|
end
|
115
115
|
|
116
116
|
it "should return the response body, headers, and code when the request succeeds" do
|
117
|
-
response = @backend.put(200, "/
|
117
|
+
response = @backend.put(200, "/riak/","foo", "This is the body.")
|
118
118
|
response[:body].should == "Success!"
|
119
119
|
response[:headers].should be_kind_of(Hash)
|
120
120
|
response[:code].should == 200
|
121
121
|
end
|
122
122
|
|
123
123
|
it "should raise a FailedRequest exception when the request fails" do
|
124
|
-
lambda { @backend.put(204, "/
|
124
|
+
lambda { @backend.put(204, "/riak/","foo", "This is the body.") }.should raise_error(Riak::FailedRequest)
|
125
125
|
end
|
126
126
|
|
127
127
|
it "should not raise a FailedRequest if one of the expected response codes matches" do
|
128
|
-
lambda { @backend.put([200, 204], "/
|
128
|
+
lambda { @backend.put([200, 204], "/riak/","foo", "This is the body.") }.should_not raise_error(Riak::FailedRequest)
|
129
129
|
end
|
130
130
|
|
131
131
|
|
132
132
|
it "should yield successive chunks of the response to the given block but not return the entire body" do
|
133
133
|
chunks = ""
|
134
|
-
response = @backend.put(200, "/
|
134
|
+
response = @backend.put(200, "/riak/","foo", "This is the body.") do |chunk|
|
135
135
|
chunks << chunk
|
136
136
|
end
|
137
137
|
chunks.should == "Success!"
|
@@ -141,41 +141,41 @@ shared_examples_for "HTTP backend" do
|
|
141
141
|
end
|
142
142
|
|
143
143
|
it "should raise an error if an invalid resource path is given" do
|
144
|
-
lambda { @backend.put(200, "/
|
144
|
+
lambda { @backend.put(200, "/riak/") }.should raise_error(ArgumentError)
|
145
145
|
end
|
146
146
|
|
147
147
|
it "should raise an error if no body data is given" do
|
148
|
-
lambda { @backend.put(200, "/
|
148
|
+
lambda { @backend.put(200, "/riak/","foo") }.should raise_error(ArgumentError)
|
149
149
|
end
|
150
150
|
|
151
151
|
it "should raise an error if the body is not a string" do
|
152
|
-
lambda { @backend.put(200, "/
|
152
|
+
lambda { @backend.put(200, "/riak/","foo", 123) }.should raise_error(ArgumentError)
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
156
|
describe "POST requests" do
|
157
157
|
before :each do
|
158
|
-
setup_http_mock(:post, @backend.path("/
|
158
|
+
setup_http_mock(:post, @backend.path("/riak/","foo").to_s, :body => "Success!")
|
159
159
|
end
|
160
160
|
|
161
161
|
it "should return the response body, headers, and code when the request succeeds" do
|
162
|
-
response = @backend.post(200, "/
|
162
|
+
response = @backend.post(200, "/riak/","foo", "This is the body.")
|
163
163
|
response[:body].should == "Success!"
|
164
164
|
response[:headers].should be_kind_of(Hash)
|
165
165
|
response[:code].should == 200
|
166
166
|
end
|
167
167
|
|
168
168
|
it "should raise a FailedRequest exception when the request fails" do
|
169
|
-
lambda { @backend.post(204, "/
|
169
|
+
lambda { @backend.post(204, "/riak/", "foo", "This is the body.") }.should raise_error(Riak::FailedRequest)
|
170
170
|
end
|
171
171
|
|
172
172
|
it "should not raise a FailedRequest if one of the expected response codes matches" do
|
173
|
-
lambda { @backend.post([200, 204], "/
|
173
|
+
lambda { @backend.post([200, 204], "/riak/", "foo", "This is the body.") }.should_not raise_error(Riak::FailedRequest)
|
174
174
|
end
|
175
175
|
|
176
176
|
it "should yield successive chunks of the response to the given block but not return the entire body" do
|
177
177
|
chunks = ""
|
178
|
-
response = @backend.post(200, "/
|
178
|
+
response = @backend.post(200, "/riak/", "foo", "This is the body.") do |chunk|
|
179
179
|
chunks << chunk
|
180
180
|
end
|
181
181
|
chunks.should == "Success!"
|
@@ -185,15 +185,15 @@ shared_examples_for "HTTP backend" do
|
|
185
185
|
end
|
186
186
|
|
187
187
|
it "should raise an error if an invalid resource path is given" do
|
188
|
-
lambda { @backend.post(200, "/
|
188
|
+
lambda { @backend.post(200, "/riak/") }.should raise_error(ArgumentError)
|
189
189
|
end
|
190
190
|
|
191
191
|
it "should raise an error if no body data is given" do
|
192
|
-
lambda { @backend.post(200, "/
|
192
|
+
lambda { @backend.post(200, "/riak/", "foo") }.should raise_error(ArgumentError)
|
193
193
|
end
|
194
194
|
|
195
195
|
it "should raise an error if the body is not a string" do
|
196
|
-
lambda { @backend.post(200, "/
|
196
|
+
lambda { @backend.post(200, "/riak/", "foo", 123) }.should raise_error(ArgumentError)
|
197
197
|
end
|
198
198
|
end
|
199
199
|
|
@@ -201,11 +201,11 @@ shared_examples_for "HTTP backend" do
|
|
201
201
|
[204, 205, 304].each do |code|
|
202
202
|
[:get, :post, :put, :delete].each do |method|
|
203
203
|
it "should not return a body on #{method.to_s.upcase} for #{code}" do
|
204
|
-
setup_http_mock(method, @backend.path("/
|
204
|
+
setup_http_mock(method, @backend.path("/riak/","foo").to_s, :status => code)
|
205
205
|
response = if method == :post || method == :put
|
206
|
-
@backend.send(method, code,"/
|
206
|
+
@backend.send(method, code,"/riak/","foo", "This is the body")
|
207
207
|
else
|
208
|
-
@backend.send(method, code, "/
|
208
|
+
@backend.send(method, code, "/riak/", "foo")
|
209
209
|
end
|
210
210
|
response.should_not have_key(:body)
|
211
211
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ripple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Cribbs
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-03-05 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/riak/map_reduce.rb
|
115
115
|
- lib/riak/map_reduce_error.rb
|
116
116
|
- lib/riak/robject.rb
|
117
|
+
- lib/riak/util/fiber1.8.rb
|
117
118
|
- lib/riak/util/headers.rb
|
118
119
|
- lib/riak/util/multipart.rb
|
119
120
|
- lib/riak/util/translation.rb
|
@@ -131,6 +132,7 @@ files:
|
|
131
132
|
- lib/ripple/document/persistence.rb
|
132
133
|
- lib/ripple/document/persistence/callbacks.rb
|
133
134
|
- lib/ripple/document/properties.rb
|
135
|
+
- lib/ripple/document/timestamps.rb
|
134
136
|
- lib/ripple/document/validations.rb
|
135
137
|
- lib/ripple/embedded_document.rb
|
136
138
|
- lib/ripple/embedded_document/persistence.rb
|
@@ -162,6 +164,7 @@ files:
|
|
162
164
|
- spec/ripple/persistence_spec.rb
|
163
165
|
- spec/ripple/properties_spec.rb
|
164
166
|
- spec/ripple/ripple_spec.rb
|
167
|
+
- spec/ripple/timestamps_spec.rb
|
165
168
|
- spec/ripple/validations_spec.rb
|
166
169
|
- spec/spec.opts
|
167
170
|
- spec/spec_helper.rb
|
@@ -216,6 +219,7 @@ test_files:
|
|
216
219
|
- spec/ripple/persistence_spec.rb
|
217
220
|
- spec/ripple/properties_spec.rb
|
218
221
|
- spec/ripple/ripple_spec.rb
|
222
|
+
- spec/ripple/timestamps_spec.rb
|
219
223
|
- spec/ripple/validations_spec.rb
|
220
224
|
- spec/spec_helper.rb
|
221
225
|
- spec/support/http_backend_implementation_examples.rb
|