Skip to content

Commit

Permalink
Handle indended snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
rzane committed Jul 7, 2019
1 parent 815f13c commit 6c92c1b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/snapshot_testing/snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module SnapshotTesting
module Snapshot
TEMPLATE = "snapshots[%s] = <<~SNAP\n%s\nSNAP\n".freeze
TEMPLATE = "snapshots[%s] = <<-SNAP\n%s\nSNAP\n".freeze

@@serializers = [SnapshotTesting::Serializer.new]

Expand Down
20 changes: 14 additions & 6 deletions spec/snapshot_testing/snapshot_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,26 @@ def dump(jawn)
end

let(:data) {
{ "hello" => "world", "foo" => "bar\nbaz" }
{
"simple" => "foo",
"multiline" => "foo\nbar",
"indented" => " foo"
}
}

let(:snapshot) {
<<~EOS
snapshots["hello"] = <<~SNAP
world
snapshots["simple"] = <<-SNAP
foo
SNAP
snapshots["foo"] = <<~SNAP
snapshots["multiline"] = <<-SNAP
foo
bar
baz
SNAP
snapshots["indented"] = <<-SNAP
foo
SNAP
EOS
}
Expand All @@ -47,7 +55,7 @@ def dump(jawn)
snapshot = SnapshotTesting::Snapshot.dump("jawn" => Jawn.new("jint"))

expect(snapshot).to eq(<<~EOS)
snapshots["jawn"] = <<~SNAP
snapshots["jawn"] = <<-SNAP
jint
SNAP
EOS
Expand Down

0 comments on commit 6c92c1b

Please sign in to comment.