Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Stand alone complex #24

Merged
merged 10 commits into from

2 participants

@elskwid

Add support for use outside of Rails applications in Engines and Railsties. Lots of goodies in here. Please to enjoy an commit.

@phlipper
Owner

:one: :man_with_gua_pi_mao: :yum:

@phlipper phlipper merged commit 5b5dc3b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 26, 2013
  1. @elskwid
  2. @elskwid
  3. @elskwid
  4. @elskwid

    minitest_helper -> minitest_helper_rails

    elskwid authored
    Prepare for standalone helper
  5. @elskwid

    SPAAAAAACE

    elskwid authored
  6. @elskwid

    Add standalone generator

    elskwid authored
    Add new generator (standalone) with its own helper to be used when
    tests are needed outside of Rails.
  7. @elskwid

    Add initial travis support

    elskwid authored
  8. @elskwid

    Refactor generator methods

    elskwid authored
  9. @elskwid

    Prevent standalone run in Rails

    elskwid authored
    Need to wrap #standalone in a no_tasks block to hide
    the method (task) from Thor/Rails.
  10. @elskwid

    Update README

    elskwid authored
This page is out of date. Refresh to see the latest.
View
27 README.md
@@ -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,7 +37,9 @@ $ 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:
@@ -45,6 +47,16 @@ This engine manages testing dependencies and adds a generator to Rails, `thinclo
$ 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
5 bin/thincloud-testify
@@ -0,0 +1,5 @@
+#!/usr/bin/env ruby
+
+require "thincloud/test/generator"
+
+Thincloud::Test::Generator.generate
View
6 lib/generators/thincloud/test/templates/ci/before_script.sh
@@ -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
View
8 lib/generators/thincloud/test/templates/ci/ci_runner.sh
@@ -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
View
12 lib/generators/thincloud/test/templates/ci/travis.yml
@@ -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
View
11 ...ators/thincloud/test/templates/minitest_helper.rb → ...thincloud/test/templates/minitest_helper_rails.rb
@@ -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!
View
18 lib/generators/thincloud/test/templates/minitest_helper_standalone.rb
@@ -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 }
View
0  lib/generators/thincloud/test/templates/capybara.rb → ...tors/thincloud/test/templates/support/capybara.rb
File renamed without changes
View
0  ...tors/thincloud/test/templates/database_cleaner.rb → ...ncloud/test/templates/support/database_cleaner.rb
File renamed without changes
View
0  ...nerators/thincloud/test/templates/factory_girl.rb → .../thincloud/test/templates/support/factory_girl.rb
File renamed without changes
View
5 lib/generators/thincloud/test/templates/minitest.rb → ...hincloud/test/templates/support/minitest_rails.rb
@@ -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
View
4 lib/generators/thincloud/test/templates/support/minitest_reporters.rb
@@ -0,0 +1,4 @@
+unless ENV["CI"]
+ require "minitest/reporters"
+ MiniTest::Reporters.use! MiniTest::Reporters::ProgressReporter.new
+end
View
0  ...nerators/thincloud/test/templates/routing_spec.rb → .../thincloud/test/templates/support/routing_spec.rb
File renamed without changes
View
67 lib/generators/thincloud/test/test_generator.rb
@@ -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
View
13 lib/thincloud/test/generator.rb
@@ -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
Something went wrong with that request. Please try again.