Sha256: 062d2c7f96e80bb4d3461a8257f658c4dfabc75900d636a57b1e0986bc157c2d

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'

describe "Link", "converting to xml" do
    
  before do
    @link_a = Caren::Link.new( :patient_number => "12345" )
    @link_b = Caren::Link.new( :patient_number => "67890" )
  end
  
  it "should be able to convert a link to valid xml" do
    @link_a.should convert_to_valid_caren_xml
  end
  
  it "should be able to convert an array of links to valid xml" do
    [@link_a,@link_b].should convert_to_valid_caren_array_xml
  end
  
end

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 )
  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
  end
  
  it "should be find all links using the API" do
    links = Caren::Link.all
    links.should have(3).things
    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.should have(1).thing
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
caren-api-0.2.0 spec/link_spec.rb
caren-api-0.1.0 spec/link_spec.rb