Sha256: 87fc00030af3a36e9f69c3773b026d89c65e713a52254f28fc2e70ea57d7ab48
Contents?: true
Size: 1.33 KB
Versions: 9
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' require 'goliath/rack/validation/boolean_value' describe Goliath::Rack::Validation::BooleanValue do before(:each) do @app = mock('app').as_null_object @env = {'params' => {}} end describe 'with middleware' do before(:each) do @bv = Goliath::Rack::Validation::BooleanValue.new(@app, {:key => 'id', :default => true}) end it 'uses the default if the key is not present' do @bv.call(@env) @env['params']['id'].should == true end it 'uses the default if the key is nil' do @env['params']['id'] = nil @bv.call(@env) @env['params']['id'].should == true end it 'uses the default if the key is blank' do @env['params']['id'] = "" @bv.call(@env) @env['params']['id'].should == true end it 'a random value is false' do @env['params']['id'] = 'blarg' @bv.call(@env) @env['params']['id'].should == false end %w(t true TRUE T 1).each do |type| it "considers #{type} true" do @env['params']['id'] = type @bv.call(@env) @env['params']['id'].should == true end end %w(f false FALSE F 0).each do |type| it "considers #{type} false" do @env['params']['id'] = type @bv.call(@env) @env['params']['id'].should == false end end end end
Version data entries
9 entries across 9 versions & 1 rubygems