Sha256: 06ef782da315a9ac0e0adc9b1876b452d995d4524ba1977e89443adf815c7c3c
Contents?: true
Size: 1.33 KB
Versions: 10
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' describe "Mutations::DuckFilter" do it "allows objects that respond to a single specified method" do f = Mutations::DuckFilter.new(:methods => [:length]) filtered, errors = f.filter("test") assert_equal "test", filtered assert_equal nil, errors filtered, errors = f.filter([1, 2]) assert_equal [1, 2], filtered assert_equal nil, errors end it "doesn't allow objects that respond to a single specified method" do f = Mutations::DuckFilter.new(:methods => [:length]) filtered, errors = f.filter(true) assert_equal true, filtered assert_equal :duck, errors filtered, errors = f.filter(12) assert_equal 12, filtered assert_equal :duck, errors end it "considers nil to be invalid" do f = Mutations::DuckFilter.new(:nils => false) filtered, errors = f.filter(nil) assert_equal nil, filtered assert_equal :nils, errors end it "considers nil to be valid" do f = Mutations::DuckFilter.new(:nils => true) filtered, errors = f.filter(nil) assert_equal nil, filtered assert_equal nil, errors end it "Allows anything if no methods are specified" do f = Mutations::DuckFilter.new [true, "hi", 1, [1, 2, 3]].each do |v| filtered, errors = f.filter(v) assert_equal v, filtered assert_equal nil, errors end end end
Version data entries
10 entries across 10 versions & 1 rubygems