spec/lib/ldp/resource_spec.rb in ldp-0.0.5 vs spec/lib/ldp/resource_spec.rb in ldp-0.0.6
- old
+ new
@@ -56,15 +56,54 @@
end
end
end
describe "#create" do
- context "with initial content" do
- let(:path) { '/a_new_resource' }
- it "should post an RDF graph" do
- mock_client.should_receive(:post).with(path, "xyz").and_return(double(headers: {}))
- subject.content = "xyz"
- subject.save
+ let(:path) { '/a_new_resource' }
+ context "with a subject uri" do
+ let(:conn_stubs) do
+ Faraday::Adapter::Test::Stubs.new do |stub|
+ stub.head(path) { [404] }
+ stub.put(path) { [200, {'Last-Modified' => 'Tue, 22 Jul 2014 02:23:32 GMT' }] }
+ end
end
+
+ context "and without a base path" do
+ it "should post an RDF graph" do
+ subject.content = "xyz"
+ subject.save
+ end
+ end
+
+ context "and with a base path" do
+ let(:base_path) { '/foo' }
+
+ subject { Ldp::Resource.new(mock_client, path, nil, base_path) }
+
+ it "should ignore the base path" do
+ subject.content = "xyz"
+ subject.save
+ end
+ end
+ end
+
+ context "without a subject" do
+ context "and with a base path" do
+ let(:base_path) { '/foo' }
+
+ let(:conn_stubs) do
+ Faraday::Adapter::Test::Stubs.new do |stub|
+ stub.post(base_path) { [200, {'Last-Modified' => 'Tue, 22 Jul 2014 02:23:32 GMT' }] }
+ end
+ end
+
+ subject { Ldp::Resource.new(mock_client, nil, nil, base_path) }
+
+ it "should post an RDF graph" do
+ subject.content = "xyz"
+ subject.save
+ end
+ end
+
end
end
end