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