Sha256: 1c2103b577253623cbd00243bbfae40000453f031974b4e7850a47b890d758b6

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

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

module Braintree
  describe ClientToken do
    describe "self.generate" do
      it "delegates to ClientTokenGateway#generate" do
        options = {:foo => :bar}
        client_token_gateway = double(:client_token_gateway)
        expect(client_token_gateway).to receive(:generate).with(options).once
        allow(ClientTokenGateway).to receive(:new).and_return(client_token_gateway)
        ClientToken.generate(options)
      end

      it "can't overwrite public_key, or created_at" do
        expect {
          Braintree::ClientToken.generate(
            :public_key => "bad_key",
            :created_at => "bad_time",
          )
        }.to raise_error(ArgumentError, /created_at, public_key/)
      end
    end

    context "adding credit_card options with no customer ID" do
      %w(verify_card fail_on_duplicate_payment_method make_default).each do |option_name|
        it "raises an ArgumentError if #{option_name} is present" do
          expect do
            Braintree::ClientToken.generate(
              option_name.to_sym => true,
            )
          end.to raise_error(ArgumentError, /#{option_name}/)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
braintree-4.22.0 spec/unit/braintree/client_token_spec.rb
braintree-4.21.0 spec/unit/braintree/client_token_spec.rb
braintree-4.20.0 spec/unit/braintree/client_token_spec.rb
braintree-4.19.0 spec/unit/braintree/client_token_spec.rb