Sha256: cc0e4dacd83e23707c1ec298a39609435a0334553646a8fed764d28592329475

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe Chargify::Base do

  it 'parses element names' do
    Chargify::Base.stub!(:name).and_return("Test::Namespace::ElementName")
    Chargify::Base.element_name.should eql('element_name')
  end

  context 'configuration changes' do
    before do
      @original_subdomain = Chargify.subdomain
    end

    # TODO: Because ActiveResource overloads the word "site"
    # It is difficult to support setting either the site or subdomain
    # after the class has already been configured and loaded
    # it "honors changes made after the first configuration" do
    #   expect do
    #     Chargify.configure do |c|
    #       c.subdomain = "something-new"
    #     end
    #   end.to change { Chargify::Base.site.to_s }.to("https://something-new.chargify.com")
    # end

    it "honors the site over the subdomain if it is specified" do
      expect do
        Chargify.configure do |c|
          c.subdomain = "crazy-train"
          c.site = "http://test-site.chargify-test.com"
          c.api_key = "abc123"
        end
      end.to change { Chargify::Base.site.to_s }.to("http://test-site.chargify-test.com")
    end

    it "allows the subdomain and site to be reconfigured" do
      Chargify.configure do |c|
        c.subdomain = "first"
      end

      expect(Chargify::Base.site.to_s).to eql("https://first.chargify.dev")

      expect do
        Chargify.configure do |c|
          c.subdomain = "second"
        end
      end.to change { Chargify::Base.site.to_s }.to("https://second.chargify.dev")

    end

    after do
      Chargify.configure do |c|
        c.subdomain = @original_subdomain
      end
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chargify_api_ares-1.3.3 spec/resources/base_spec.rb