Sha256: 8233842211ecfc8fc1e36e07921f9abb835a2d8f832d2ffefef0583822bbd2d4

Contents?: true

Size: 1.57 KB

Versions: 21

Compression:

Stored size: 1.57 KB

Contents

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe Braintree::DisputeSearch do
  it "overrides previous 'is' with new 'is' for the same field" do
    search = Braintree::DisputeSearch.new
    search.id.is "dispute1"
    search.id.is "dispute2"
    search.to_hash.should == {:id => {:is => "dispute2"}}
  end

  it "overrides previous 'in' with new 'in' for the same field" do
    search = Braintree::DisputeSearch.new
    search.status.in Braintree::Dispute::Status::Open
    search.status.in Braintree::Dispute::Status::Won
    search.to_hash.should == {:status => [Braintree::Dispute::Status::Won]}
  end

  [
    :amount_disputed,
    :amount_won,
    :case_number,
    :customer_id,
    :disbursement_date,
    :effective_date,
    :id,
    :merchant_account_id,
    :reason_code,
    :received_date,
    :reference_number,
    :reply_by_date,
    :transaction_id,
    :transaction_source,
  ].each do |field|
    it "allows searching on #{field}" do
      search = Braintree::DisputeSearch.new

      expect do
        search.send(field).is "hello"
      end.not_to raise_error
    end
  end

  [
    :kind,
    :reason,
    :status,
  ].each do |field|
    it "raises if provided an unknown #{field} value" do
      search = Braintree::DisputeSearch.new
      expect do
        search.send(field).is "unknown value"
      end.to raise_error(/Invalid argument/)
    end
  end

  it "raises if no operator is provided" do
    search = Braintree::DisputeSearch.new
    expect do
      search.id "one"
    end.to raise_error(RuntimeError, "An operator is required")
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
braintree-3.4.0 spec/unit/braintree/dispute_search_spec.rb
braintree-3.3.0 spec/unit/braintree/dispute_search_spec.rb
braintree-3.2.0 spec/unit/braintree/dispute_search_spec.rb
braintree-3.1.0 spec/unit/braintree/dispute_search_spec.rb
braintree-3.0.1 spec/unit/braintree/dispute_search_spec.rb
braintree-2.104.1 spec/unit/braintree/dispute_search_spec.rb
braintree-2.104.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.103.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.102.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.101.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.100.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.99.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.98.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.97.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.96.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.95.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.94.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.93.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.92.0 spec/unit/braintree/dispute_search_spec.rb
braintree-2.91.0 spec/unit/braintree/dispute_search_spec.rb