Sha256: 11c8fb610aa9b835004128b7b5a8648a679950c92d8e9cf039efdec893c50a33

Contents?: true

Size: 1008 Bytes

Versions: 15

Compression:

Stored size: 1008 Bytes

Contents

require 'tests/common'

module DeltacloudUnitTest
  class ApiTest < Test::Unit::TestCase
    include Rack::Test::Methods

    def app
      Sinatra::Application
    end

    def test_it_returns_entry_points
      do_xml_request '/api'
      (last_xml_response/'/api/link').map.size.should > 0
    end

    def test_it_has_correct_attributes_set
      do_xml_request '/api'
      (last_xml_response/'/api/link').each do |link|
        link.attributes.keys.sort.should == [ 'href', 'rel' ]
      end
    end

    def test_it_responses_to_html
      do_request '/api', {}, false, { :format => :html }
      last_response.status.should == 200
      Nokogiri::HTML(last_response.body).search('html').first.name.should == 'html'
    end

    def test_it_responses_to_json
      do_request '/api', {}, false, { :format => :json }
      last_response.status.should == 200
      JSON::parse(last_response.body).class.should == Hash
      JSON::parse(last_response.body)['api'].class.should == Hash
    end

  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
steamcannon-deltacloud-core-0.0.7.2 tests/api_test.rb
steamcannon-deltacloud-core-0.0.7.2-java tests/api_test.rb
steamcannon-deltacloud-core-0.0.7.1 tests/api_test.rb
steamcannon-deltacloud-core-0.0.7.1-java tests/api_test.rb
deltacloud-core-0.0.7 tests/api_test.rb
bbrowning-deltacloud-core-0.0.6.1-java tests/api_test.rb
bbrowning-deltacloud-core-0.0.6-java tests/api_test.rb
bbrowning-deltacloud-core-0.0.6 tests/api_test.rb
deltacloud-core-0.0.6 tests/api_test.rb
bbrowning-deltacloud-core-0.0.4 tests/api_test.rb
bbrowning-deltacloud-core-0.0.4-java tests/api_test.rb
deltacloud-core-0.0.5 tests/api_test.rb
deltacloud-core-0.0.4 tests/api_test.rb
bbrowning-deltacloud-core-0.0.3.1 tests/api_test.rb
deltacloud-core-0.0.3 tests/api_test.rb