Sha256: 1a3466cb23f123d57f62150a820d9665b61d3f05a8e9de442a762f7ef98abaa5

Contents?: true

Size: 628 Bytes

Versions: 2

Compression:

Stored size: 628 Bytes

Contents

require 'test_helper'

module ActiveResource
  class JsonErrorsTest < Test::Unit::TestCase

    def test_parsing_of_error_json_hash
      @model = SpiffyStoresAPI::Order.new
      @model.errors.from_json({errors: {name: ['missing']}}.to_json)
      assert_equal ['missing'], @model.errors[:name]
    end

    def test_parsing_of_error_json_plain_string
      @model = SpiffyStoresAPI::Order.new
      @model.errors.from_json({errors: 'some generic error'}.to_json)
      assert_equal ['some generic error'], @model.errors[:base]
      assert_equal 'some generic error', @model.errors.full_messages.to_sentence
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spiffy_stores_api-4.11.1 test/active_resource/json_errors_test.rb
spiffy_stores_api-4.11.0 test/active_resource/json_errors_test.rb