spec/care_provider_spec.rb in caren-api-0.3.5 vs spec/care_provider_spec.rb in caren-api-0.4.0

- old
+ new

@@ -70,36 +70,38 @@ describe "CareProvider", "REST methods" do before do care_providers = File.read("spec/fixtures/caren_care_providers.xml") care_providers_search = File.read("spec/fixtures/caren_care_providers_search.xml") - FakeWeb.register_uri(:put, Caren::CareProvider.resource_url(1), :signature => Caren::Api.sign ) - FakeWeb.register_uri(:get, Caren::CareProvider.resource_url, :body => care_providers, - :signature => Caren::Api.sign(care_providers) ) - - FakeWeb.register_uri(:get, "#{Caren::CareProvider.resource_url}?key=url-shortcut&value=pantein", - :body => care_providers_search, - :signature => Caren::Api.sign(care_providers_search) ) + care_provider_url = Caren::Api.session.url_for( Caren::CareProvider.resource_url(1) ) + care_providers_url = Caren::Api.session.url_for( Caren::CareProvider.resource_url ) + search_url = Caren::Api.session.url_for( "#{Caren::CareProvider.resource_url}?key=url-shortcut&value=pantein" ) + + timestamp = DateTime.now.to_i + + FakeWeb.register_uri(:put, care_provider_url, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp) ) + FakeWeb.register_uri(:get, care_providers_url, :body => care_providers, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,care_providers) ) + FakeWeb.register_uri(:get, search_url, :body => care_providers_search, :timestamp => timestamp, :signature => Caren::Api.session.sign(timestamp,care_providers_search) ) end it "should be able to update a care provider" do - lambda{ Caren::CareProvider.new( :id => 1, :name => "Test" ).update }.should_not raise_error + lambda{ Caren::CareProvider.new( :id => 1, :name => "Test" ).update( Caren::Api.session ) }.should_not raise_error end it "should be able to update the logo for a care provider" do - lambda{ Caren::CareProvider.new( :id => 1 ).update_logo( "spec/fixtures/bacon.jpg" ) }.should_not raise_error + lambda{ Caren::CareProvider.new( :id => 1 ).update_logo( "spec/fixtures/bacon.jpg", Caren::Api.session ) }.should_not raise_error end it "should be able to search for a specific care provider" do - care_providers = Caren::CareProvider.search :url_shortcut, "pantein" + care_providers = Caren::CareProvider.search :url_shortcut, "pantein", Caren::Api.session care_providers.should have(1).things care_providers.first.name.should == "Pantein" care_providers.first.url_shortcut.should == "pantein" end it "should be able to find all care providers" do - care_providers = Caren::CareProvider.all + care_providers = Caren::CareProvider.all Caren::Api.session care_providers.should have(2).things care_providers.first.name.should == "Demo" care_providers.first.url_shortcut.should == "demo" end \ No newline at end of file