json_errors_test.rb 556 B

12345678910111213141516171819202122
  1. require 'test_helper'
  2. module ActiveResource
  3. class JsonErrorsTest < Test::Unit::TestCase
  4. def test_parsing_of_error_json_hash
  5. errors = some_error.from_json({errors: {name: ['missing']}}.to_json)
  6. assert_equal({"name"=>["missing"]}, errors)
  7. end
  8. def test_parsing_of_error_json_plain_string
  9. errors = some_error.from_json({errors: 'some generic error'}.to_json)
  10. assert_equal(["some generic error"], errors)
  11. end
  12. private
  13. def some_error
  14. ActiveResource::Errors.new(ShopifyAPI::Order.new)
  15. end
  16. end
  17. end