Sha256: 99d0bb86dac428ae4e0eb3c150c3f64cbdfc40854f1f2cc071e37a75e4d91da0

Contents?: true

Size: 671 Bytes

Versions: 7

Compression:

Stored size: 671 Bytes

Contents

# frozen_string_literal: true

require 'gecko'

class Gecko::Helpers::ValidationHelperTest < Minitest::Test
  def setup
    @klass = Class.new(Gecko::Record::Base) do
      attribute :name,   String
    end
    @client = Gecko::Client.new('ABC', 'DEF')
  end

  def test_initially_valid?
    record = @klass.new(@client, name: "Gecko")
    assert(record.valid?)
    assert(record.errors.empty?)
    assert(record.errors.messages.empty?)
  end

  def test_from_response
    record = @klass.new(@client, name: "Gecko")
    record.errors.from_response({ name: ["is not shiny"] })
    assert(!record.valid?)
    assert_equal(record.errors[:name], ["is not shiny"])
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gecko-ruby-0.12.3 test/helpers/validation_helper_test.rb
gecko-ruby-0.12.2 test/helpers/validation_helper_test.rb
gecko-ruby-0.12.1 test/helpers/validation_helper_test.rb
gecko-ruby-0.12.0 test/helpers/validation_helper_test.rb
gecko-ruby-0.11.1 test/helpers/validation_helper_test.rb
gecko-ruby-0.11.0 test/helpers/validation_helper_test.rb
gecko-ruby-0.10.0 test/helpers/validation_helper_test.rb