diff --git a/spec/spec_helper2.cr b/spec/spec_helper2.cr index aef12e83..3717428d 100644 --- a/spec/spec_helper2.cr +++ b/spec/spec_helper2.cr @@ -5,17 +5,19 @@ require "../src/lucky_cli" include LuckyTemplate::Spec +SPEC_UPDATE_SNAPSHOT = ENV["SPEC_UPDATE_SNAPSHOT"]? == "1" + def generate_snapshot(fixture_name, file = __FILE__, line = __LINE__, &) generator = yield actual_path = Path[Dir.current] expected_path = Path["#{__DIR__}/../fixtures"] / fixture_name / "expected" - # NOTE: Should only be run for initial generation - {% if flag?(:baseline_expected) %} + if SPEC_UPDATE_SNAPSHOT + FileUtils.rm_rf(expected_path) FileUtils.mkdir_p(expected_path) generator.render(expected_path) - {% end %} + end FileUtils.mkdir_p(actual_path) generator.render(actual_path)