Sha256: eb0902405c5cdb07e0a065df04f207c2b711e8993b92032919ae2f5eba038c02
Contents?: true
Size: 1.48 KB
Versions: 17
Compression:
Stored size: 1.48 KB
Contents
require "spec_helper" describe Shamu::ToBoolExtension do before( :each ) do Shamu::ToBoolExtension.extend! end describe Shamu::ToBoolExtension::Strings do { "1" => true, "0" => false, "true" => true, "false" => false, "" => false, "True" => true, "False" => false, "T" => true, "F" => false, "Yes" => true, "No" => false, "Y" => true, "N" => false, }.each do |candidate, expected| it "converts '#{ candidate }' to #{ expected }" do expect( candidate.to_bool ).to eq expected end end it "uses default for no-match" do expect( "Random".to_bool( :nope ) ).to eq :nope end end describe Shamu::ToBoolExtension::Integers do { 1 => true, 0 => false }.each do |candidate, expected| it "converts '#{ candidate }' to #{ expected }" do expect( candidate.to_bool ).to eq expected end end it "uses default for no-match" do expect( 100.to_bool( :nope ) ).to eq :nope end end describe Shamu::ToBoolExtension::Boolean do { true => true, false => false, }.each do |candidate, expected| it "converts '#{ candidate }' to #{ expected }" do expect( candidate.to_bool ).to eq expected end end end describe Shamu::ToBoolExtension::Nil do it "uses default" do expect( nil.to_bool( :whatever ) ).to eq( :whatever ) end end end
Version data entries
17 entries across 17 versions & 1 rubygems