Skip to content

Instantly share code, notes, and snippets.

@wikimatze
Created July 22, 2017 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wikimatze/df9b94edb36bc520958294b80541f7b9 to your computer and use it in GitHub Desktop.
Save wikimatze/df9b94edb36bc520958294b80541f7b9 to your computer and use it in GitHub Desktop.
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