Sha256: e309ad91c2bf35b0cd980774a1fdfb8ea188a18b87d1275d1b4959eddc8d2a5b
Contents?: true
Size: 1.43 KB
Versions: 2
Compression:
Stored size: 1.43 KB
Contents
require 'spec_helper' describe "Mutations::SymbolFilter" do it "allows strings" do sf = Mutations::SymbolFilter.new filtered, errors = sf.filter("hello") assert_equal :hello, filtered assert_equal nil, errors end it "allows symbols" do sf = Mutations::SymbolFilter.new filtered, errors = sf.filter(:hello) assert_equal :hello, filtered assert_equal nil, errors end it "doesn't allow non-symbols" do sf = Mutations::SymbolFilter.new [["foo"], {:a => "1"}, Object.new].each do |thing| _filtered, errors = sf.filter(thing) assert_equal :symbol, errors end end it "considers nil to be invalid" do sf = Mutations::SymbolFilter.new(:nils => false) filtered, errors = sf.filter(nil) assert_equal nil, filtered assert_equal :nils, errors end it "considers nil to be valid" do sf = Mutations::SymbolFilter.new(:nils => true) filtered, errors = sf.filter(nil) assert_equal nil, filtered assert_equal nil, errors end it "considers non-inclusion to be invalid" do sf = Mutations::SymbolFilter.new(:in => [:red, :blue, :green]) filtered, errors = sf.filter(:orange) assert_equal :orange, filtered assert_equal :in, errors end it "considers inclusion to be valid" do sf = Mutations::SymbolFilter.new(:in => [:red, :blue, :green]) filtered, errors = sf.filter(:red) assert_equal :red, filtered assert_equal nil, errors end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mutations-0.9.1 | spec/symbol_filter_spec.rb |
mutations-0.9.0 | spec/symbol_filter_spec.rb |