Sha256: f3cda9c5b66b9486ab66e7e8911b073548846e7374f15e6bd7a1b4371fe056e6
Contents?: true
Size: 1.33 KB
Versions: 2
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 = double('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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
goliath-1.0.5 | spec/unit/rack/validation/boolean_value_spec.rb |
goliath-1.0.4 | spec/unit/rack/validation/boolean_value_spec.rb |