Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
jsonapi-resources / test / helpers / functional_helpers.rb
Size: Mime:
module Helpers
  module FunctionalHelpers
    # from http://jamieonsoftware.com/blog/entry/testing-restful-response-types
    # def assert_response_is(type, message = '')
    #   case type
    #     when :js
    #       check = [
    #         'text/javascript'
    #       ]
    #     when :json
    #       check = [
    #         'application/json',
    #         'text/json',
    #         'application/x-javascript',
    #         'text/x-javascript',
    #         'text/x-json'
    #       ]
    #     when :xml
    #       check = [ 'application/xml', 'text/xml' ]
    #     when :yaml
    #       check = [
    #         'text/yaml',
    #         'text/x-yaml',
    #         'application/yaml',
    #         'application/x-yaml'
    #       ]
    #     else
    #       if methods.include?('assert_response_types')
    #         check = assert_response_types
    #       else
    #         check = []
    #       end
    #   end
    #
    #   if @response.content_type
    #     ct = @response.content_type
    #   elsif methods.include?('assert_response_response')
    #     ct = assert_response_response
    #   else
    #     ct = ''
    #   end
    #
    #   begin
    #     assert check.include?(ct)
    #   rescue Test::Unit::AssertionFailedError
    #     raise Test::Unit::AssertionFailedError.new(build_message(message, "The response type is not ?", type.to_s))
    #   end
    # end

    # def assert_js_redirect_to(path)
    #   assert_response_is :js
    #   assert_match /#{"window.location.href = \"" + path + "\""}/, @response.body
    # end
    #
    def json_response
      JSON.parse(@response.body)
    end
  end
end