Sha256: aefb386c1d831ee5ab18b1fd665d4deef6634ce320ff84383a346d42333d4caf

Contents?: true

Size: 1.28 KB

Versions: 11

Compression:

Stored size: 1.28 KB

Contents

require 'test_helper'

class CassandraObject::FinderMethodsTest < CassandraObject::TestCase
  test 'find' do
    Issue.create.tap do |issue|
      assert_equal issue, Issue.find(issue.id)
    end

    begin
      Issue.find(nil)
      assert false
    rescue => e
      assert_equal "Couldn't find Issue with key nil", e.message
    end
    
    assert_raise CassandraObject::RecordNotFound do
      Issue.find('what')
    end
  end

  test 'find_by_id' do
    Issue.create.tap do |issue|
      assert_equal issue, Issue.find_by_id(issue.id)
    end

    assert_nil Issue.find_by_id('what')
  end

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

    assert_equal [first_issue, second_issue].to_set, Issue.all.to_set
  end

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

    assert [first_issue, second_issue].include?(Issue.first)
  end

  test 'find_with_ids' do
    first_issue = Issue.create
    second_issue = Issue.create
    third_issue = Issue.create

    assert_equal [], Issue.find_with_ids([])
    assert_equal [first_issue, second_issue].to_set, Issue.find_with_ids(first_issue.id, second_issue.id).to_set
    assert_equal [first_issue, second_issue].to_set, Issue.find_with_ids([first_issue.id, second_issue.id]).to_set
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
gotime-cassandra_object-3.0.3 test/unit/finder_methods_test.rb
gotime-cassandra_object-3.0.2 test/unit/finder_methods_test.rb
gotime-cassandra_object-3.0.1 test/unit/finder_methods_test.rb
gotime-cassandra_object-3.0.0 test/unit/finder_methods_test.rb
gotime-cassandra_object-2.13.0 test/unit/finder_methods_test.rb
gotime-cassandra_object-2.12.5 test/unit/finder_methods_test.rb
gotime-cassandra_object-2.12.4 test/unit/finder_methods_test.rb
gotime-cassandra_object-2.12.3 test/unit/finder_methods_test.rb
gotime-cassandra_object-2.12.2 test/unit/finder_methods_test.rb
gotime-cassandra_object-2.12.1 test/unit/finder_methods_test.rb
gotime-cassandra_object-2.12.0 test/unit/finder_methods_test.rb