oops_test.rb revision d6f4200103ff4fdbb3d9bfb1296a27a366808b0d
1494N/Arequire 'test_helper'
1611N/A
1494N/Aclass OopsTest < ActiveSupport::TestCase
1494N/A
1494N/A context 'doing a oops request' do
1494N/A context 'with invalid url' do
1494N/A should 'raise error' do
1494N/A begin
1494N/A do_request :invalid, "http://example.com/"
1494N/A assert false, "no error was thrown"
1494N/A rescue Oops::Error => e
1494N/A assert_match(/expected XML/, e.message)
1494N/A end
1494N/A end
1494N/A end
1494N/A
1494N/A context 'with valid url' do
1494N/A setup do
1494N/A @result = do_request :valid, "http://sweet.jpl.nasa.gov/1.1/sunrealm.owl"
1494N/A end
1494N/A
1494N/A should 'return a list' do
1494N/A assert_equal 5, @result.count
1494N/A end
1494N/A end
1494N/A end
1494N/A
1494N/A context 'parsing a oops response' do
1494N/A setup do
1494N/A @result = Oops::Response.parse File.read("#{Rails.root}/test/fixtures/oops/sunrealm.xml")
1494N/A end
1494N/A
1494N/A should 'return correct amount of elements' do
1494N/A assert_equal 5, @result.count
1494N/A end
1494N/A
1494N/A context 'first element responded' do
1494N/A setup do
1537N/A @element = @result.first
1494N/A end
1494N/A
1494N/A should 'have correct type' do
1494N/A assert_equal 'Pitfall', @element.type
1494N/A end
1494N/A
1494N/A should 'have correct name' do
1494N/A assert_equal 'Creating unconnected ontology elements', @element.name
1494N/A end
1494N/A
1494N/A should 'have correct code' do
1494N/A assert_equal 'P04', @element.code
1494N/A end
1494N/A
1494N/A should 'have correct affects' do
1494N/A assert_equal ['http://sweet.jpl.nasa.gov/1.1/sunrealm.owl#SunRealm'], @element.affects
1494N/A end
1494N/A end
1494N/A
1494N/A end
1676N/A
1676N/A def do_request(cassette, url)
1676N/A VCR.use_cassette "oops/#{cassette}", match_requests_on: [:body] do
1494N/A Oops::Client.request(url)
1494N/A end
1494N/A end
1494N/A
1494N/Aend
1494N/A