Created
June 25, 2015 17:45
-
-
Save mediocretes/61d7998075670c2fad62 to your computer and use it in GitHub Desktop.
How to define a test that will test multiple versions of a thing
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
class ProductionTests < ActiveSupport::TestCase | |
class << self | |
alias :actually_define_test :test | |
def test(name, &block) | |
if name.include? "pdf" | |
VALID_PRINCE_VERSIONS.each do |version| | |
actually_define_test("#{name}_prince_v#{version}") do | |
@prince_version = version | |
@doc_name = "#{@prince_version}-#{name}" | |
instance_eval &block | |
end | |
end | |
else | |
@doc_name = nil | |
actually_define_test name, &block | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment