Sha256: 71db6b98d39090f18aee7960b65f7367ff4ceb2149ad91c01df1e8fa72574d95

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 KB

Contents

require 'test_helper'

module Minglr
  module Extensions
  
    class ArrayTest < Test::Unit::TestCase

      context Array do
    
        context "filter" do
          
          setup do
            class TestObject
              attr_accessor :name
            end
            @test1 = TestObject.new
            @test2 = TestObject.new
            @test1.name = "test1"
            @test2.name = "test2"
            @collection = [@test1, @test2]
            @collection.send(:extend, Minglr::Extensions::Array)
          end
          
          should "include elements matching words in attributes" do
            assert_equal [@test1], @collection.filter([:name], ["1"])
            assert_equal [@test1, @test2], @collection.filter([:name], ["test"])
          end

          should "deal with empty words and attributes" do
            assert_equal [@test1, @test2], @collection.filter([], [])
            assert_equal [@test1, @test2], @collection.filter([:name], [])
            assert_equal [], @collection.filter([], ["1"])
          end
    
        end
    
      end

    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
schubert-minglr-1.2.0 test/extensions/array_test.rb
schubert-minglr-1.3.0 test/extensions/array_test.rb
schubert-minglr-1.3.1 test/extensions/array_test.rb
schubert-minglr-1.3.11 test/extensions/array_test.rb
schubert-minglr-1.3.2 test/extensions/array_test.rb
schubert-minglr-1.3.3 test/extensions/array_test.rb
schubert-minglr-1.3.5 test/extensions/array_test.rb
schubert-minglr-1.3.8 test/extensions/array_test.rb
schubert-minglr-1.3.9 test/extensions/array_test.rb
minglr-1.3.11 test/extensions/array_test.rb