Skip to content

Commit

Permalink
Add standalone generator
Browse files Browse the repository at this point in the history
Add new generator (standalone) with its own helper to be used when
tests are needed outside of Rails.
  • Loading branch information
elskwid committed Jan 26, 2013
1 parent 0844150 commit 2d6a0a7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
@@ -0,0 +1,18 @@
if RUBY_ENGINE == "ruby"
begin
require "simplecov"
SimpleCov.start do
add_filter "test"
add_filter "config"
command_name "MiniTest"
end
rescue LoadError
warn "unable to load SimpleCov"
end
end

require "thincloud-test"

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[File.join("./test/support/**/*.rb")].sort.each { |f| require f }
16 changes: 16 additions & 0 deletions lib/generators/thincloud/test/test_generator.rb
Expand Up @@ -32,6 +32,22 @@ def test
say_status "success", "thincloud-test has finished."
end

# Generates thincloud test infrastructure outside of Rails
def standalone
remove_file "test/test_helper.rb"

copy_file "minitest_helper_standalone.rb", "test/minitest_helper.rb"
copy_file "minitest_reporters.rb", "test/support/minitest_reporters.rb"
copy_file "test.rake", "lib/tasks/test.rake"
copy_file "Guardfile"

create_file ".gitignore" unless File.exist?(".gitignore")
append_file ".gitignore", "coverage"

say_status "", ""
say_status "success", "thincloud-test has finished."
end

end
end
end
2 changes: 1 addition & 1 deletion lib/thincloud/test/generator.rb
Expand Up @@ -6,7 +6,7 @@ module Thincloud
module Test
class Generator
def self.generate
::Thincloud::Generators::TestGenerator.new.test
::Thincloud::Generators::TestGenerator.new.standalone
end
end
end
Expand Down

0 comments on commit 2d6a0a7

Please sign in to comment.