Sha256: 34cb1379c18e7c50d5b5cb8ac5c6fcc759eb916d9a16e3434668439342e80282

Contents?: true

Size: 1.74 KB

Versions: 17

Compression:

Stored size: 1.74 KB

Contents

require 'test_helper'

class CassandraObject::CoreTest < CassandraObject::TestCase
  test 'initialiaze' do
    issue = Issue.new

    assert issue.new_record?
    assert !issue.destroyed?
  end

  test 'initialize yields self' do
    issue = Issue.new { |i| i.description = 'bar' }
    assert_equal 'bar', issue.description
  end

  test 'dup' do
    issue = Issue.create description: 'foo'

    dup_issue = issue.dup

    assert dup_issue.new_record?
    assert_not_equal issue.id, dup_issue.id
    assert_nil dup_issue.created_at
    assert_nil dup_issue.updated_at
    assert_equal 'foo', issue.description
  end

  test 'equality of new records' do
    assert_not_equal Issue.new, Issue.new
  end

  test 'equality' do
    first_issue = Issue.create
    second_issue = Issue.create

    assert_equal first_issue, first_issue
    assert_equal first_issue, Issue.find(first_issue.id)
    assert_not_equal first_issue, second_issue
  end

  test 'to_param' do
    issue = Issue.new
    assert_equal issue.id, issue.to_param
  end

  test 'hash' do
    issue = Issue.create
    assert_equal issue.id.hash, issue.hash
  end

  test 'inspect' do
    issue = Issue.create
    assert issue.inspect =~ /^#<Issue id: \"\w+\", created_at: \".+\", updated_at: \".+\", description: \".+\">$/
  end

  test 'inspect schema' do
    issue = IssueSchema.create(title: 'tit', description: 'desc')
    assert issue.inspect =~ /^#<IssueSchema id: \"\w+\", title: \".+\", description: \".+\", created_at: \".+\", updated_at: \".+\">$/
  end

  test 'inspect dynamic' do
    issue = IssueDynamic.create(key: '1', title: 'tit', dynamic_field1: 'one', dynamic_field2: 'two')
    assert issue.inspect =~ /^{:key=>\".+\", :title=>\".+\", :dynamic_field1=>\".+\", :dynamic_field2=>\".+\"}$/
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
extendi-cassandra_object-1.1.1 test/unit/core_test.rb
extendi-cassandra_object-1.1.0 test/unit/core_test.rb
extendi-cassandra_object-1.0.20 test/unit/core_test.rb
extendi-cassandra_object-1.0.19 test/unit/core_test.rb
extendi-cassandra_object-1.0.18 test/unit/core_test.rb
extendi-cassandra_object-1.0.17 test/unit/core_test.rb
extendi-cassandra_object-1.0.16 test/unit/core_test.rb
extendi-cassandra_object-1.0.15 test/unit/core_test.rb
extendi-cassandra_object-1.0.14 test/unit/core_test.rb
extendi-cassandra_object-1.0.13 test/unit/core_test.rb
extendi-cassandra_object-1.0.12 test/unit/core_test.rb
extendi-cassandra_object-1.0.11 test/unit/core_test.rb
extendi-cassandra_object-1.0.10 test/unit/core_test.rb
extendi-cassandra_object-1.0.9 test/unit/core_test.rb
extendi-cassandra_object-1.0.8 test/unit/core_test.rb
extendi-cassandra_object-1.0.7 test/unit/core_test.rb
extendi-cassandra_object-1.0.6 test/unit/core_test.rb