Skip to content

Commit

Permalink
add test case for complex obfuscation strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
nettofarah committed Dec 4, 2015
1 parent b69b915 commit 791d8c0
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions spec/translator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
let(:translator) { Polo::Translator.new([finder], Polo::Configuration.new(obfuscate: obfuscated_fields)) }
let(:netto) { netto = translator.instances.first }

context "with obfuscated field with no specified strategy" do
context "obfuscated field with no specified strategy" do
let(:obfuscated_fields) {{email: nil }}

it "shuffles characters in field" do
Expand All @@ -29,15 +29,25 @@
end
end

context "with obfuscated field with obscuration strategy applied which will result in 42" do
context "obfuscated field with obscuration strategy applied which will result in 42" do
let(:obfuscated_fields) {{email: lambda { |_| 42 } } }

it "replaces contents of field according to the supplied lambda" do
expect(netto.email.to_s).to eq "42"
end
end

context "with no strategy passed in" do
context "complex custom obfuscation strategy" do
let(:obfuscated_fields) do
{ email: lambda { |field| "temp_#{field}" } }
end

it "replaces contents of field according to the supplied lambda" do
expect(netto.email.to_s).to eq "temp_nettofarah@gmail.com"
end
end

context "no strategy passed in" do
let(:obfuscated_fields) { [:email] }

it "shuffles contents" do
Expand Down

0 comments on commit 791d8c0

Please sign in to comment.