Sha256: eaf47892625c2b58b5446b150c55387637eba90f9d313c54238642ab405f0dca

Contents?: true

Size: 1.22 KB

Versions: 10

Compression:

Stored size: 1.22 KB

Contents

require 'test_helper'

class FindersTest < MiniTest::Unit::TestCase
  def setup
    reload_db
  end

  def test_find_all_female_genders
    girls = Dummy.where(:gender_cd => Dummy.genders[:female]).sort { |a,b| a.name <=> b.name }
    
    assert_equal 2, girls.length
    
    assert_equal 'Anna', girls.first.name
    assert_equal :female, girls.first.gender
    assert_equal true, girls.first.female?
  end
  
  def test_find_all_gamma_words
    gammas = Dummy.where(:word_cd => Dummy.words(:gamma)).all
    
    assert_equal 1, gammas.length
    assert_equal 'Chris', gammas.first.name
    assert_equal true, gammas.first.male?
    assert_equal 'gamma', gammas.first.word_cd
    assert_equal :gamma, gammas.first.word
  end
  
  def test_find_all_with_attribute_didum_equal_to_foo
    skip('Not available in Mongoid') if mongoid?
    
    foos = Dummy.where('other = ?', Dummy.didums(:foo)).all   
    
    assert_equal 1, foos.length
    assert_equal false, foos.first.foobar?
  end
  
  def test_find_using_insecure_inline_string_conditions
    skip('Not available in Mongoid') if mongoid?
    
    men = Dummy.where("gender_cd = #{Dummy.genders(:male)}").all
    
    assert_equal 1, men.length
    assert_equal true, men.first.male?
  end  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
simple_enum-1.6.9 test/finders_test.rb
simple_enum-1.6.8 test/finders_test.rb
simple_enum-1.6.7 test/finders_test.rb
simple_enum-1.6.5 test/finders_test.rb
simple_enum-1.6.4 test/finders_test.rb
simple_enum-1.6.3 test/finders_test.rb
simple_enum-1.6.2 test/finders_test.rb
simple_enum-1.6.1 test/finders_test.rb
simple_enum-1.5.1 test/finders_test.rb
simple_enum-1.5.0 test/finders_test.rb