Sha256: 13309c6f570f4b9504a1b5a7f5da3d7cf07c6e4c099f8934eba6b684f1623ff4

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

RSpec::Matchers.define :be_listable_resource do |expected|
  match do |actual|
    client = authorized_civicrm_client
    subject = actual.class
    test_response_hash = send(:"test_#{subject.name.demodulize.underscore}_array")

    client.expects(:get).once.returns(test_response(test_response_hash))
    c = subject.all

    c.should be_a_kind_of(Array)
  end
end
RSpec::Matchers.define :be_updatable_resource do |expected|
  match do |actual|
    client = authorized_civicrm_client
    subject = actual.class

    client.expects(:get).once.returns(test_response(test_contact({name: "foo"})))
    client.expects(:put).once.returns(test_response(test_contact({name: "bar"})))
    c = subject.find("resource_id")
    c.name.should == "foo"
    c.name = "bar"
    c.save
    c.name.should == "bar"
  end
end
RSpec::Matchers.define :be_deleteable_resource do |expected|
  match do |actual|
    client = authorized_civicrm_client
    subject = actual.class

    client.expects(:get).once.returns(test_response(test_contact({name: "foo"})))
    client.expects(:delete).once.returns(test_response(test_contact({name: "bar"})))
    c = subject.find("resource_id")
    c.delete
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
civicrm-1.0.5 spec/support/test_matchers.rb
civicrm-1.0.4 spec/support/test_matchers.rb
civicrm-1.0.2 spec/support/test_matchers.rb
civicrm-1.0.1 spec/support/test_matchers.rb