Created
July 22, 2017 09:31
-
-
Save wikimatze/df9b94edb36bc520958294b80541f7b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest' | |
require "minitest/autorun" | |
require "minitest/focus" | |
require 'rake' | |
require 'mocha/mini_test' | |
class Test | |
def up | |
version = ENV["MIGRATION_VERSION"] | |
if version.nil? && ENV["VERSION"] | |
deprecated = true | |
warn "Environment variable VERSION is deprecated, use MIGRATION_VERSION" | |
version = ENV["VERSION"] | |
end | |
version ? Integer(version) : nil | |
rescue ArgumentError | |
warn "Environment variable #{deprecated ? '' : 'MIGRATION_'}VERSION=#{version} should be non-existant or Integer" | |
puts "hillo" | |
nil | |
end | |
end | |
describe Test do | |
it "has no MIGRATIN_VERSION and only VERSION in the ENV" do | |
ENV["MIGRATION_VERSION"] = nil | |
ENV["VERSION"] = '1' | |
assert_equal 1, Test.new.up | |
end | |
it "has no MIGRATION_VERSION and only VERSION in the ENV" do | |
ENV["MIGRATION_VERSION"] = 'a' | |
assert_output(nil, /Environment variable MIGRATION_VERSION=a should be non-existant or Integer/) { Test.new.up } | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment