Sha256: 4605781c70cf549a671b26a5e546301bb2967e85ce632ba2cfd3ed9507b81780

Contents?: true

Size: 1.3 KB

Versions: 13

Compression:

Stored size: 1.3 KB

Contents

require 'rspec'
require 'configure-s3-website'

describe ConfigureS3Website::XmlHelper do
  context '#hash_to_api_xml' do
    it 'returns an empty string, if the hash is empty' do
      str = ConfigureS3Website::XmlHelper.send(:hash_to_api_xml,
                                        { })
      str.should eq('')
    end

    it 'capitalises hash keys but not values' do
      str = ConfigureS3Website::XmlHelper.send(:hash_to_api_xml,
                                        { 'key' => 'value' })
      str.should eq("\n<Key>value</Key>")
    end

    it 'removes underscores and capitalises the following letter' do
      str = ConfigureS3Website::XmlHelper.send(:hash_to_api_xml,
                                        { 'hello_key' => 'value' })
      str.should eq("\n<HelloKey>value</HelloKey>")
    end

    it 'can handle hash values as well' do
      str = ConfigureS3Website::XmlHelper.send(:hash_to_api_xml,
                                        { 'key' => { 'subkey' => 'subvalue' } })
      str.should eq("\n<Key>\n  <Subkey>subvalue</Subkey></Key>")
    end

    it 'indents' do
      str = ConfigureS3Website::XmlHelper.send(
        :hash_to_api_xml,
        { 'key' => { 'subkey' => 'subvalue' } },
        indent = 1
      )
      str.should eq("\n  <Key>\n    <Subkey>subvalue</Subkey></Key>")
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
configure-s3-website-1.7.3 spec/xml_helper_spec.rb
configure-s3-website-1.7.2 spec/xml_helper_spec.rb
configure-s3-website-1.7.1 spec/xml_helper_spec.rb
configure-s3-website-1.7.0 spec/xml_helper_spec.rb
configure-s3-website-1.6.0 spec/xml_helper_spec.rb
configure-s3-website-1.5.5 spec/xml_helper_spec.rb
configure-s3-website-1.5.4 spec/xml_helper_spec.rb
configure-s3-website-1.5.3 spec/xml_helper_spec.rb
configure-s3-website-1.5.2 spec/xml_helper_spec.rb
configure-s3-website-1.5.1 spec/xml_helper_spec.rb
configure-s3-website-1.5.0 spec/xml_helper_spec.rb
configure-s3-website-1.4.0 spec/xml_helper_spec.rb
configure-s3-website-1.3.0 spec/xml_helper_spec.rb