Skip to content

Commit

Permalink
I think this hack will allow the spec to remain as it was and still w…
Browse files Browse the repository at this point in the history
…ork on Windows
  • Loading branch information
jwoertink committed Nov 10, 2024
1 parent 899028b commit 0ca3bcd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions spec/avram/migrator/gen/migration_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,21 @@ describe "Generating migrations" do
).generate(_version: "123")

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
add name : String
end
end
MIGRATION
# HACK: This is broken up because on Windows everything is returning \r\n except for
# the empty line which is just returning \n
created_migration_file.should contain <<-MIGRATION
def rollback
drop :users
end
Expand Down

0 comments on commit 0ca3bcd

Please sign in to comment.