From 55556c9baabbfc5fb4d748062f1c066cb261c71a Mon Sep 17 00:00:00 2001 From: Jeremy Woertink Date: Sun, 10 Nov 2024 08:12:36 -0800 Subject: [PATCH] Fixing specs on windows. (#1074) * Fixing specs on windows. Fixes #1072 * bump the min crystal version to 1.11 to support EOL for Windows * Reverting all of the changed files. * hack to get windows to pass this spec * I think this hack will allow the spec to remain as it was and still work on Windows --- .gitattributes | 1 + spec/avram/migrator/gen/migration_spec.cr | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..fdd3f45e1 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.cr text eol=lf \ No newline at end of file diff --git a/spec/avram/migrator/gen/migration_spec.cr b/spec/avram/migrator/gen/migration_spec.cr index 6a618af54..7d55217d4 100644 --- a/spec/avram/migrator/gen/migration_spec.cr +++ b/spec/avram/migrator/gen/migration_spec.cr @@ -31,7 +31,15 @@ describe "Generating migrations" do rollback_contents: rollback_contents ).generate(_version: "123") - File.read("./db/migrations/123_create_users.cr").should contain <<-MIGRATION + created_migration_file = File.read("./db/migrations/123_create_users.cr") + + {% if flag?(:windows) %} + # NOTE: Reading from the file on windows returns \r\n, but this spec's line endings are still \n + # due to the .gitattributes file. Also note that `EOL` didn't exist until Crystal 1.11.0 + created_migration_file = created_migration_file.gsub(EOL, "\n") + {% end %} + + created_migration_file.should contain <<-MIGRATION class CreateUsers::V123 < Avram::Migrator::Migration::V1 def migrate create :users do