Sha256: b400be7c20165dea93ac2217cbe0120a5d8c5e9c212426dd4452264acc609895

Contents?: true

Size: 901 Bytes

Versions: 1

Compression:

Stored size: 901 Bytes

Contents

CONNECTION = {
    :site => "http://demo.salesking.local:3000/api/",
    :password => "demo",
    :user => "demo@salesking.eu"
} unless defined?(CONNECTION)

# create all classes and set their connection
%w[Client Address CreditNote Invoice Product LineItem User].each do |model|
  eval "class #{model} < SK::SDK::Base;end" unless Object.const_defined?(model)
end
SK::SDK::Base.set_connection CONNECTION

# check if a SalesKing instance is available by calling /users/current.json
def sk_available?
  begin
    User.get(:current)
  rescue Errno::ECONNREFUSED #ActiveResource::ResourceNotFound => e
    return false
  end

end


def delete_test_data(doc, client)
  doc.destroy
  client.destroy
  lambda {
    doc = Invoice.find(doc.id)
  }.should raise_error(ActiveResource::ResourceNotFound)
  lambda {
    client = Client.find(client.id)
  }.should raise_error(ActiveResource::ResourceNotFound)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sk_sdk-0.0.7 spec/resources_spec_helper.rb