CDRH / orchid

Rails Engine for site integration with CDRH API
MIT License
3 stars 0 forks source link

Look into tests for generator #128

Open jduss4 opened 5 years ago

jduss4 commented 5 years ago

https://api.rubyonrails.org/v5.2.3/classes/Rails/Generators/TestCase.html

We can potentially test the setup step internally within orchid instead of always having to fire up a new application each time

jduss4 commented 4 years ago

Just looked into it a little and this was starting to work, although I'm not sure what the destination needs to be or if there's a better way to load the generator class:

require 'test_helper'
require_relative '../lib/generators/setup_generator.rb'

# NOTE can find more specific assertions and methods for generator tests here:
# https://api.rubyonrails.org/classes/Rails/Generators/TestCase.html

class SetupGeneratorTest < Rails::Generators::TestCase

  tests SetupGenerator
  destination File.expand_path("../tmp", __dir__)
  setup :prepare_destination

end
techgique commented 4 years ago

Looks promising. I knew Rails had tests for its own generators, so we can probably look at their tests for reference too