spec/link_spec.rb in caren-api-0.3.5 vs spec/link_spec.rb in caren-api-0.4.0
- old
+ new
@@ -20,30 +20,36 @@
describe "Link", "REST methods" do
before do
links = File.read("spec/fixtures/caren_links.xml")
search = File.read("spec/fixtures/caren_links_search.xml")
- FakeWeb.register_uri(:get, Caren::Link.resource_url, :body => links, :signature => Caren::Api.sign(links) )
- FakeWeb.register_uri(:get, "#{Caren::Link.resource_url}?key=external-id&value=1", :body => search, :signature => Caren::Api.sign(search) )
- FakeWeb.register_uri(:post, Caren::Link.resource_url, :status => 201, :signature => Caren::Api.sign )
+
+ links_url = Caren::Api.session.url_for(Caren::Link.resource_url)
+ search_url = Caren::Api.session.url_for("#{Caren::Link.resource_url}?key=external-id&value=1")
+
+ timestamp = DateTime.now.to_i
+
+ FakeWeb.register_uri(:get, links_url, :body => links, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,links) )
+ FakeWeb.register_uri(:get, search_url, :body => search, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,search) )
+ FakeWeb.register_uri(:post, links_url, :status => 201, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp) )
end
it "should be able to create a new link using the API" do
- lambda{ Caren::Link.new( :patient_number => "12345" ).create }.should_not raise_error
+ lambda{ Caren::Link.new( :patient_number => "12345" ).create(Caren::Api.session) }.should_not raise_error
end
it "should be find all links using the API" do
- links = Caren::Link.all
+ links = Caren::Link.all(Caren::Api.session)
links.should have(3).things
links.first.id.should == 1
links.first.status.should == "confirmed"
links.first.external_id.should == "1"
links.first.person_name.should == "Andre Foeken"
links.first.person_id.should == 3
end
it "should be find a specific link using the API" do
- links = Caren::Link.search(:external_id, 1)
+ links = Caren::Link.search(:external_id, 1, Caren::Api.session)
links.should have(1).thing
end
end
\ No newline at end of file