Sha256: 98c082f9fa5c112e2d20cb13e54eebe254962478c12592e963bc900ab1cf6e51

Contents?: true

Size: 1.47 KB

Versions: 31

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

describe Chargify::ProductFamily::Component do
  context 'create' do
    let(:component) { Chargify::ProductFamily::Component }
    let(:connection) { double('connection').as_null_object }
    let(:response) { double('response').as_null_object }

    before :each do
      component.any_instance.stub(:connection).and_return(connection)
      response.stub(:tap)
    end

    it 'should post to the correct url' do
      connection.should_receive(:post) do |path, body, headers|
        path.should == '/product_families/123/quantity_based_components.xml'

        response
      end

      component.create(:product_family_id => 123, :kind => 'quantity_based_component', :name => 'Foo Component')
    end

    it 'should not include the kind attribute in the post' do
      connection.should_receive(:post) do |path, body, headers|
        body.should_not match(/kind/)

        response
      end

      component.create(:product_family_id => 123, :kind => 'quantity_based_component', :name => 'Foo Component')
    end

    it 'should have the component kind as the root' do
      connection.should_receive(:post) do |path, body, headers|
        #The second line in the xml should be the root.  This saves us from using nokogiri for this one example.
        body.split($/)[1].should match(/quantity_based_component/)

        response
      end

      component.create(:product_family_id => 123, :kind => 'quantity_based_component', :name => 'Foo Component')
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
chargify_api_ares-1.4.15 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.4.14 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.4.13 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.4.11 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.4.10 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.4.7 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.4.6 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.4.5 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.4.4 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.4.3 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.4.2 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.4.1 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.4.0 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.3.5 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.3.4 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.3.3 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.3.2 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.3.1 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.3.0 spec/resources/product_family_component_spec.rb
chargify_api_ares-1.2.1 spec/resources/product_family_component_spec.rb