Sha256: b556a9776091c26decf3213cc5b2eaa89f7bb58f5179bd1e7e5d86cc71f6971e

Contents?: true

Size: 776 Bytes

Versions: 3

Compression:

Stored size: 776 Bytes

Contents

require 'test_helper'

class CassandraObject::Types::ArrayTypeTest < CassandraObject::Types::TestCase
  test 'ignore_nil' do
    assert_equal false, coder.ignore_nil?
  end
  
  test 'encode' do
    assert_equal ['1', '2'].to_json, coder.encode(['1', '2'])
    
    assert_raise ArgumentError do
      coder.encode('wtf')
    end
  end

  test 'decode' do
    assert_equal ['1', '2'], coder.decode(['1', '2'].to_json)
  end

  class TestIssue < CassandraObject::Base
    self.column_family = 'Issue'
    array :favorite_colors
  end

  test 'wrap' do
    issue = TestIssue.new
    colors = []
    wrapper = coder.wrap(issue, 'favorite_colors', colors)

    assert_kind_of Array, wrapper
    
    assert !issue.changed?
    wrapper << 'red'
    assert issue.changed?
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gotime-cassandra_object-2.6.3 test/types/array_type_test.rb
gotime-cassandra_object-2.6.1 test/types/array_type_test.rb
gotime-cassandra_object-2.6.0 test/types/array_type_test.rb