Skip to content

Instantly share code, notes, and snippets.

@mediocretes
Created June 25, 2015 17:45
Show Gist options
  • Save mediocretes/61d7998075670c2fad62 to your computer and use it in GitHub Desktop.
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
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