spec/approvals_spec.rb in approvals-0.0.8 vs spec/approvals_spec.rb in approvals-0.0.9
- old
+ new
@@ -84,6 +84,27 @@
it "passes approved files through ERB" do
$what = 'greatness'
string = "We have, I fear, confused power with greatness."
Approvals.verify string, :namer => namer
end
+
+ describe "supports excluded keys option for json" do
+ let(:hash) { {:object => {:id => rand(100), :created_at => Time.now, :name => 'test', deleted_at: nil}} }
+
+ before do
+ Approvals.configure do |c|
+ c.excluded_json_keys = {
+ :id => /(\A|_)id$/,
+ :date => /_at$/
+ }
+ end
+ end
+
+ it "verifies json with excluded keys" do
+ Approvals.verify JSON.dump(hash), :format => :json, :namer => namer
+ end
+
+ it "also supports an array of hashes" do
+ Approvals.verify JSON.dump([hash]), :format => :json, :namer => namer
+ end
+ end
end