Sha256: e4875b700c252dde671b736dcb7bd574718f5c14b864f9e20eda07ddbd32ec2d

Contents?: true

Size: 1.49 KB

Versions: 7

Compression:

Stored size: 1.49 KB

Contents

require File.dirname(__FILE__) + '/../test_helper.rb'

module HasFilter
  class ScopesTest < ActiveSupport::TestCase
    def setup
      @first  = HasFilterArticle.find_by_title 'first'
      @second = HasFilterArticle.find_by_title 'second'
      @third  = HasFilterArticle.find_by_title 'third'
      @upcase = HasFilterArticle.find_by_title 'UPCASE'
    end
  
    test 'scope :is' do
      assert_equal [@first], HasFilterArticle.is(:title, 'first')
    end
  
    test 'scope :is_not' do
      assert_equal [@second, @third, @upcase], HasFilterArticle.is_not(:title, 'first')
    end
  
    test 'scope :contains' do
      assert_equal [@first, @third], HasFilterArticle.contains(:title, 'ir')
    end
      
    test 'scope :does_not_contain' do
      assert_equal [@second, @upcase], HasFilterArticle.does_not_contain(:title, 'ir')
    end
      
    test 'scope :starts_with' do
      assert_equal [@first], HasFilterArticle.starts_with(:title, 'fi')
    end
      
    test 'scope :does_not_start_with' do
      assert_equal [@second, @third, @upcase], HasFilterArticle.does_not_start_with(:title, 'fi')
    end
      
    test 'scope :ends_with' do
      assert_equal [@first], HasFilterArticle.ends_with(:title, 'st')
    end
      
    test 'scope :does_not_end_with' do
      assert_equal [@second, @third, @upcase], HasFilterArticle.does_not_end_with(:title, 'st')
    end
      
    test 'scope :contains_all' do
      assert_equal [@first], HasFilterArticle.contains_all(:title, %w(i r s))
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
adva-0.1.4 vendor/gems/has_filter/test/has_filter/scopes_test.rb
adva-0.1.3 vendor/gems/has_filter/test/has_filter/scopes_test.rb
adva-0.1.2 vendor/gems/has_filter/test/has_filter/scopes_test.rb
adva-0.1.1 vendor/gems/has_filter/test/has_filter/scopes_test.rb
adva-0.1.0 vendor/gems/has_filter/test/has_filter/scopes_test.rb
adva_cms-0.0.1 vendor/gems/has_filter/test/has_filter/scopes_test.rb
adva-0.0.1 adva_cms/vendor/gems/has_filter/test/has_filter/scopes_test.rb