Sha256: 045d389570cc0357c06ac3ca0291760c55f11702eff340de43204965c32974de

Contents?: true

Size: 872 Bytes

Versions: 1

Compression:

Stored size: 872 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper'

require 'redis_object/ext/sanitization'

module TriggerSpec
	
	class SensitiveObject < RedisObject
		
		include Seabright::Sanitization
		
		date :test
		bool :yay
		json :stuff
		
		named_sanitization :burn, :test, :yay
	end
	
	describe Seabright::Triggers do
		before(:each) do
			SpecHelper.flushdb
		end
		
		let(:secret) do
			SensitiveObject.create(test: Time.now, yay: true, stuff: {test: "1"}, worthless: "yup", sup: "dawg")
		end
		
		it "can sanitize a field or two willy nilly" do
			
			secret.stuff.should be_a(Hash)
			secret.sanitize! :stuff, :sup
			secret.stuff.should eq(nil)
			
		end
		
		it "can sanitize by name" do
			
			secret.test.should_not eq(nil)
			secret.yay.should eq(true)
			secret.sanitize_by_name! :burn
			secret.test.should eq(nil)
			secret.yay.should eq(false)
			
		end
		
	end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis_object-1.5.3 spec/sanitization_spec.rb