spec/key_spec.rb in slosilo-2.0.0 vs spec/key_spec.rb in slosilo-2.0.1

- old
+ new

@@ -143,9 +143,22 @@ it "signs it" do allow(key).to receive_messages shake_salt: 'a pinch of salt' expect(key.sign("this sentence is not this sentence")).to eq(expected_signature) end end + + context "when given a Hash containing non-ascii characters" do + let(:unicode){ "adèle.dupuis" } + let(:encoded){ + unicode.dup.tap{|s| s.force_encoding Encoding::ASCII_8BIT} + } + let(:hash){ {"data" => unicode} } + + it "converts the value to raw bytes before signing it" do + expect(key).to receive(:sign_string).with("[[\"data\",\"#{encoded}\"]]").and_call_original + key.sign hash + end + end end describe "#signed_token" do let(:time) { Time.new(2012,1,1,1,1,1,0) } let(:data) { { "foo" => :bar } }