Sha256: 49580e26abbd777ac08b9ba290fb9f868155429012219003a21a5bf61e33fa56

Contents?: true

Size: 1.61 KB

Versions: 22

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'

feature "Creating new resources" do
  
  scenario "Creating a resource in a collection" do
    
    datacenters = Abiquo::Resource("http://abiquo.example.com/api/admin/datacenters", auth)

    stub_auth_request(:options, "http://admin:admin@abiquo.example.com/api/admin/datacenters").
      to_return(:headers => {'Allow' => 'GET, POST, OPTIONS'})

    stub_auth_request(:post, "http://admin:admin@abiquo.example.com/api/admin/datacenters").with do |req|
      # we parse because comparing strings is too fragile because of order changing, different indentations, etc.
      # we're expecting something very close to this:
      # <datacenter>
      #   <name>Wadus</name>
      # </datacenter>
      Nokogiri.parse(req.body).at_xpath("/datacenter/name").text == "Wadus"
    end.to_return(:body => %q{
      <datacenter>
        <name>Wadus</name>
        <link rel="edit" href="http://abiquo.example.com/api/admin/datacenters/1"/>
      </datacenter>
    })
    
    datacenter = datacenters.create(:name => "Wadus")
    
    datacenter.should be_a(Abiquo::Resource)
    datacenter.name.should == "Wadus"

    stub_auth_request(:options, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").
      to_return(:headers => {'Allow' => 'GET, PUT, OPTIONS'})
    
    stub_auth_request(:get, "http://admin:admin@abiquo.example.com/api/admin/datacenters/1").to_return(:body => %q{
      <datacenter>
        <name>Wadus</name>
        <link rel="edit" href="http://abiquo.example.com/api/admin/datacenters/1"/>
      </datacenter>
    })

    datacenter.name == Abiquo::Resource(datacenter.url, auth).name
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
abiquo-etk-0.6.4 vendor/abiquo-0.1.2/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.6.3 vendor/abiquo-0.1.2/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.6.2 vendor/abiquo-0.1.2/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.6.1 vendor/abiquo-0.1.2/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.5.8 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.5.3 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.42 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.33 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.32 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.29 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.25 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.24 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.23 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.22 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.20 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.19 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.18 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.17 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.16 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb
abiquo-etk-0.4.15 vendor/api_ruby_client/spec/acceptance/create_resource_spec.rb