Permalink
Browse files

Merge pull request #24 from elskwid/stand-alone-complex

Stand alone complex
  • Loading branch information...
2 parents 29f299d + 2f5f045 commit 5b5dc3b5de03a88d6984c18946b880031805573c @phlipper phlipper committed Jan 26, 2013
View
@@ -2,13 +2,13 @@
## Description
-Rails testing engine and configuration generator for Thincloud apps.
+Testing framework configuration generator for Thincloud apps with support for Rails applications and Rails Engines/Railties.
## Requirements
-This gem requires Rails 3.2.8+ and has been tested on the following versions:
+This gem requires Rails 3.2.11+ and has been tested on the following versions:
-* 3.2.8
+* 3.2.11
This gem has been tested against the following Ruby versions:
@@ -37,14 +37,26 @@ $ gem install thincloud-test
## Usage
-This engine manages testing dependencies and adds a generator to Rails, `thincloud:test`. Running the generator will run the `minitest-rails` generator and add application configuration files:
+### Rails
+
+This railtie manages testing dependencies and adds a generator to Rails, `thincloud:test`. Running the generator will run the `minitest-rails` generator and add application configuration files:
* Invoke the generator:
```
$ rails generate thincloud:test
```
+### Rails Engine / Railtie
+
+The gem manages the test framework dependencies for you and provides a command to bootstrap a test environment. Running the command will add `minitest` support and application configuration files:
+
+* Invoke the generator:
+
+```
+$ thincloud-testify
+```
+
## Contributing
1. [Fork it](https://github.com/newleaders/thincloud-test/fork_select)
@@ -56,7 +68,6 @@ $ rails generate thincloud:test
## License
-* Freely distributable and licensed under the MIT-style license. See LICENSE file for details.
-* Copyright (c) 2012 New Leaders
-* https://newleaders.com
-
+* Freely distributable and licensed under the [MIT license](http://newleaders.mit-license.org/2012-2013/license.html).
+* Copyright (c) 2012-2013 New Leaders ([opensource@newleaders.com](opensource@newleaders.com))
+* [https://newleaders.com](https://newleaders.com)
View
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+
+require "thincloud/test/generator"
+
+Thincloud::Test::Generator.generate
@@ -0,0 +1,6 @@
+# Add instructions to execute before your CI run here.
+#
+# The following is used for testing a Rails Engine with a dummy test app.
+#
+# cd test/dummy
+# RAILS_ENV=test bundle exec rake db:setup
@@ -0,0 +1,8 @@
+engine=$(ruby -e 'puts RUBY_ENGINE')
+
+case $engine in
+ "ruby" )
+ bundle exec rake test && bundle exec cane;;
+ * )
+ bundle exec rake test;;
+esac
@@ -0,0 +1,12 @@
+language: ruby
+rvm:
+ - 1.9.2
+ - 1.9.3
+ - jruby-19mode
+ - rbx-19mode
+env:
+ - CI=true RAILS_ENV=test JRUBY_OPTS=--1.9 RBXOPT=-X19
+before_script: "./test/ci/before_script.sh"
+script: "./test/ci/ci_runner.sh"
+notifications:
+ flowdock: 1ec5c0efa5a264c67c6ba3b2e6574a70
@@ -1,10 +1,11 @@
if RUBY_ENGINE == "ruby"
begin
require "simplecov"
- SimpleCov.add_filter "test"
- SimpleCov.add_filter "config"
- SimpleCov.command_name "MiniTest"
- SimpleCov.start "rails"
+ SimpleCov.start "rails" do
+ add_filter "test"
+ add_filter "config"
+ command_name "MiniTest"
+ end
rescue LoadError
warn "unable to load SimpleCov"
end
@@ -18,5 +19,3 @@
# 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 }
-
-MiniTest::Rails.override_testunit!
@@ -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 }
@@ -4,8 +4,3 @@ class MiniTest::Rails::ActiveSupport::TestCase
desc.respond_to?(:validate)
end
end
-
-unless ENV["CI"]
- require "minitest/reporters"
- MiniTest::Reporters.use! MiniTest::Reporters::ProgressReporter.new
-end
@@ -0,0 +1,4 @@
+unless ENV["CI"]
+ require "minitest/reporters"
+ MiniTest::Reporters.use! MiniTest::Reporters::ProgressReporter.new
+end
@@ -7,30 +7,71 @@ class TestGenerator < ::Rails::Generators::Base
desc "Generates thincloud test infrastructure."
def test
- generate "mini_test:install"
-
- empty_directory "test/factories"
- create_file "test/factories/.gitkeep"
+ setup_minitest_rails
- remove_file "test/minitest_helper.rb"
- copy_file "minitest_helper.rb", "test/minitest_helper.rb"
+ directory "support", "test/support"
- copy_file "capybara.rb", "test/support/capybara.rb"
- copy_file "factory_girl.rb", "test/support/factory_girl.rb"
- copy_file "database_cleaner.rb", "test/support/database_cleaner.rb"
- copy_file "minitest.rb", "test/support/minitest.rb"
- copy_file "routing_spec.rb", "test/support/routing_spec.rb"
copy_file "test.rake", "lib/tasks/test.rake"
copy_file "Guardfile"
- create_file ".gitignore" unless File.exist?(".gitignore")
- append_file ".gitignore", "coverage"
+ update_gitignore
say_status "", ""
say_status "success", "thincloud-test has finished."
end
+ # Generates thincloud test infrastructure outside of Rails
+ no_tasks do
+ def standalone
+ setup_minitest
+
+ copy_file "support/minitest_reporters.rb",
+ "test/support/minitest_reporters.rb"
+
+ copy_file "test.rake", "lib/tasks/test.rake"
+
+ copy_file "Guardfile"
+
+ setup_ci
+
+ update_gitignore
+
+ say_status "", ""
+ say_status "success", "thincloud-test standalone has finished."
+ say_status "", "Customize .travis.yml and test/ci/* for your project."
+ end
+ end
+
+ private
+
+ def update_gitignore
+ create_file ".gitignore" unless File.exist?(".gitignore")
+ append_file ".gitignore", "coverage"
+ end
+
+ def setup_ci
+ empty_directory "test/ci"
+ copy_file "ci/before_script.sh", "test/ci/before_script.sh"
+ copy_file "ci/ci_runner.sh", "test/ci/ci_runner.sh"
+ copy_file "ci/travis.yml", ".travis.yml"
+ end
+
+ def setup_minitest_rails
+ generate "mini_test:install"
+ remove_file "test/minitest_helper.rb"
+
+ copy_file "minitest_helper_rails.rb", "test/minitest_helper.rb"
+
+ empty_directory "test/factories"
+ create_file "test/factories/.gitkeep"
+ end
+
+ def setup_minitest
+ remove_file "test/test_helper.rb"
+ copy_file "minitest_helper_standalone.rb", "test/minitest_helper.rb"
+ end
+
end
end
end
@@ -0,0 +1,13 @@
+require "rails/all" # Oh yeah!
+require "rails/generators"
+require "generators/thincloud/test/test_generator"
+
+module Thincloud
+ module Test
+ class Generator
+ def self.generate
+ ::Thincloud::Generators::TestGenerator.new.standalone
+ end
+ end
+ end
+end

0 comments on commit 5b5dc3b

Please sign in to comment.