Permalink
Browse files

extract rails-specific dependencies into a new gem

๐Ÿ‘Š โœจ
  • Loading branch information...
1 parent 5b5dc3b commit cc2726f5649f800baa86089db3860095395bd16a @phlipper phlipper committed Jan 27, 2013
Showing with 114 additions and 1,104 deletions.
  1. +1 โˆ’2 Gemfile
  2. +1 โˆ’1 LICENSE
  3. +24 โˆ’15 README.md
  4. +8 โˆ’27 Rakefile
  5. +2 โˆ’2 bin/thincloud-testify
  6. +0 โˆ’21 lib/generators/thincloud/test/templates/minitest_helper_rails.rb
  7. +0 โˆ’10 lib/generators/thincloud/test/templates/support/capybara.rb
  8. +0 โˆ’12 lib/generators/thincloud/test/templates/support/database_cleaner.rb
  9. +0 โˆ’4 lib/generators/thincloud/test/templates/support/factory_girl.rb
  10. +0 โˆ’6 lib/generators/thincloud/test/templates/support/minitest_rails.rb
  11. +0 โˆ’12 lib/generators/thincloud/test/templates/support/routing_spec.rb
  12. +0 โˆ’77 lib/generators/thincloud/test/test_generator.rb
  13. +0 โˆ’4 lib/tasks/thincloud-test_tasks.rake
  14. +1 โˆ’9 lib/thincloud-test.rb
  15. +2 โˆ’2 lib/thincloud/test.rb
  16. +0 โˆ’13 lib/thincloud/test/generator.rb
  17. +0 โˆ’13 lib/thincloud/test/railtie.rb
  18. 0 lib/{generators โ†’ }/thincloud/test/templates/Guardfile
  19. 0 lib/{generators โ†’ }/thincloud/test/templates/ci/before_script.sh
  20. 0 lib/{generators โ†’ }/thincloud/test/templates/ci/ci_runner.sh
  21. 0 lib/{generators โ†’ }/thincloud/test/templates/ci/travis.yml
  22. 0 ...cloud/test/templates/minitest_helper_standalone.rb โ†’ thincloud/test/templates/minitest_helper.rb}
  23. 0 lib/{generators โ†’ }/thincloud/test/templates/support/minitest_reporters.rb
  24. +1 โˆ’0 lib/thincloud/test/templates/support/mocha.rb
  25. 0 lib/{generators โ†’ }/thincloud/test/templates/test.rake
  26. +54 โˆ’0 lib/thincloud/test/test_generator.rb
  27. +1 โˆ’1 lib/thincloud/test/version.rb
  28. +0 โˆ’1 test/dummy/.gitignore
  29. +0 โˆ’17 test/dummy/Guardfile
  30. +0 โˆ’261 test/dummy/README.rdoc
  31. +0 โˆ’7 test/dummy/Rakefile
  32. +0 โˆ’15 test/dummy/app/assets/javascripts/application.js
  33. +0 โˆ’13 test/dummy/app/assets/stylesheets/application.css
  34. +0 โˆ’3 test/dummy/app/controllers/application_controller.rb
  35. +0 โˆ’2 test/dummy/app/helpers/application_helper.rb
  36. 0 test/dummy/app/mailers/.gitkeep
  37. 0 test/dummy/app/models/.gitkeep
  38. +0 โˆ’14 test/dummy/app/views/layouts/application.html.erb
  39. +0 โˆ’4 test/dummy/config.ru
  40. +0 โˆ’59 test/dummy/config/application.rb
  41. +0 โˆ’10 test/dummy/config/boot.rb
  42. +0 โˆ’25 test/dummy/config/database.yml
  43. +0 โˆ’5 test/dummy/config/environment.rb
  44. +0 โˆ’37 test/dummy/config/environments/development.rb
  45. +0 โˆ’67 test/dummy/config/environments/production.rb
  46. +0 โˆ’37 test/dummy/config/environments/test.rb
  47. +0 โˆ’7 test/dummy/config/initializers/backtrace_silencers.rb
  48. +0 โˆ’15 test/dummy/config/initializers/inflections.rb
  49. +0 โˆ’5 test/dummy/config/initializers/mime_types.rb
  50. +0 โˆ’7 test/dummy/config/initializers/secret_token.rb
  51. +0 โˆ’8 test/dummy/config/initializers/session_store.rb
  52. +0 โˆ’14 test/dummy/config/initializers/wrap_parameters.rb
  53. +0 โˆ’5 test/dummy/config/locales/en.yml
  54. +0 โˆ’58 test/dummy/config/routes.rb
  55. 0 test/dummy/lib/assets/.gitkeep
  56. +0 โˆ’10 test/dummy/lib/tasks/test.rake
  57. 0 test/dummy/log/.gitkeep
  58. +0 โˆ’26 test/dummy/public/404.html
  59. +0 โˆ’26 test/dummy/public/422.html
  60. +0 โˆ’25 test/dummy/public/500.html
  61. 0 test/dummy/public/favicon.ico
  62. +0 โˆ’6 test/dummy/script/rails
  63. 0 test/dummy/test/factories/.gitkeep
  64. +0 โˆ’36 test/dummy/test/minitest_helper.rb
  65. +0 โˆ’10 test/integration/navigation_test.rb
  66. +2 โˆ’15 test/test_helper.rb
  67. +3 โˆ’5 test/thincloud-test_test.rb
  68. +14 โˆ’18 thincloud-test.gemspec
View
@@ -1,4 +1,3 @@
-source :rubygems
+source "https://rubygems.org"
-# Specify your gem's dependencies in thincloud-test.gemspec
gemspec
View
@@ -1,4 +1,4 @@
-Copyright (c) 2012 New Leaders
+Copyright (c) 2012-2013 New Leaders
MIT License
View
@@ -1,14 +1,24 @@
-# Thincloud::Test
+# thincloud-test [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/newleaders/thincloud-test)
## Description
-Testing framework configuration generator for Thincloud apps with support for Rails applications and Rails Engines/Railties.
+Opinionated testing framework dependencies and configuration for Ruby applications.
-## Requirements
+[New Leaders](https://newleaders.com) uses this gem to manage the following dependencies:
+
+* [cane](https://github.com/square/cane)
+* [guard](https://github.com/guard/guard)
+* [guard-minitest](https://github.com/guard/guard-minitest)
+* [minitest](https://github.com/seattlerb/minitest)
+* [minitest-reporters](https://github.com/CapnKernul/minitest-reporters)
+* [mocha](https://github.com/visionmedia/mocha)
+* [rb-fsevent](https://github.com/thibaudgg/rb-fsevent)
+* [simplecov](https://github.com/colszowka/simplecov)
+* [terminal-notifier-guard](https://github.com/Springest/terminal-notifier-guard)
+* [thor](https://github.com/wycats/thor)
-This gem requires Rails 3.2.11+ and has been tested on the following versions:
-* 3.2.11
+## Requirements
This gem has been tested against the following Ruby versions:
@@ -37,26 +47,25 @@ $ gem install thincloud-test
## Usage
-### Rails
+The gem manages the test framework dependencies for you and provides a command to bootstrap a test environment.
-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:
+The goal of `thincloud-test` is to be minimal by default but provide additional capabilities by following simple conventions.
-* Invoke the generator:
+If you just want to get started using `minitest`:
-```
-$ rails generate thincloud:test
+```ruby
+require "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:
+To enable the default New Leaders conventions, run the following command:
```
$ thincloud-testify
```
+This will bootstrap your project with a `test/` directory, a `minitest_helper.rb` with some default configuration, a `test/support/` directory with configuration for `mocha`, custom minitest formatters, a `Guardfile`, a default Travis CI configuration, and more! :tada: :balloon:
+
+
## Contributing
1. [Fork it](https://github.com/newleaders/thincloud-test/fork_select)
View
@@ -1,40 +1,21 @@
#!/usr/bin/env rake
begin
- require 'bundler/setup'
+ require "bundler/setup"
rescue LoadError
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
end
-begin
- require 'rdoc/task'
-rescue LoadError
- require 'rdoc/rdoc'
- require 'rake/rdoctask'
- RDoc::Task = Rake::RDocTask
-end
-
-RDoc::Task.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'Thincloud::Test'
- rdoc.options << '--line-numbers'
- rdoc.rdoc_files.include('README.rdoc')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
-
-APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
-load 'rails/tasks/engine.rake'
-
-
+require "bundler/gem_helper"
Bundler::GemHelper.install_tasks
-require 'rake/testtask'
+require "rake/testtask"
Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.libs << 'test'
- t.pattern = 'test/**/*_test.rb'
+ t.libs << "lib"
+ t.libs << "test"
+ t.pattern = "test/**/*_test.rb"
t.verbose = false
end
-task :default => :test
+task default: :test
View
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby
-require "thincloud/test/generator"
+require "thincloud/test/test_generator"
-Thincloud::Test::Generator.generate
+Thincloud::Test::TestGenerator.new.testify!
@@ -1,21 +0,0 @@
-if RUBY_ENGINE == "ruby"
- begin
- require "simplecov"
- SimpleCov.start "rails" do
- add_filter "test"
- add_filter "config"
- command_name "MiniTest"
- end
- rescue LoadError
- warn "unable to load SimpleCov"
- end
-end
-
-ENV["RAILS_ENV"] = "test"
-require File.expand_path("../../config/environment", __FILE__)
-
-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 }
@@ -1,10 +0,0 @@
-require "minitest/rails/capybara"
-
-class MiniTest::Rails::ActionDispatch::IntegrationTest
-
- # Public: Reset the Capybara session after every run.
- teardown do
- Capybara.reset_sessions!
- end
-
-end
@@ -1,12 +0,0 @@
-DatabaseCleaner.strategy = :transaction
-DatabaseCleaner.clean_with :truncation
-
-class MiniTest::Spec
- before :each do
- DatabaseCleaner.start
- end
-
- after :each do
- DatabaseCleaner.clean
- end
-end
@@ -1,4 +0,0 @@
-class MiniTest::Spec
- include FactoryGirl::Syntax::Methods
-end
-FactoryGirl.find_definitions
@@ -1,6 +0,0 @@
-class MiniTest::Rails::ActiveSupport::TestCase
- # Register any classes that respond to validate to a specific test class
- Minitest::Spec.register_spec_type(self) do |desc|
- desc.respond_to?(:validate)
- end
-end
@@ -1,12 +0,0 @@
-class RoutingSpec < MiniTest::Rails::ActiveSupport::TestCase
- include ::ActionDispatch::Assertions::RoutingAssertions
- include ::Rails.application.routes.url_helpers
-
- # Test subjects containing 'Routes' are treated as Routing tests
- # e.g. describe "Product Routes" do ...
- register_spec_type /Routes/, self
-
- before do
- @routes = ::Rails.application.routes
- end
-end
@@ -1,77 +0,0 @@
-require "rails"
-
-module Thincloud
- module Generators
- class TestGenerator < ::Rails::Generators::Base
- source_root File.expand_path("../templates", __FILE__)
-
- desc "Generates thincloud test infrastructure."
- def test
- setup_minitest_rails
-
- directory "support", "test/support"
-
- copy_file "test.rake", "lib/tasks/test.rake"
-
- copy_file "Guardfile"
-
- 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
@@ -1,4 +0,0 @@
-# desc "Explaining what the task does"
-# task :thincloud-test do
-# # Task goes here
-# end
View
@@ -1,12 +1,4 @@
-require "database_cleaner" # reset database on each test run
-require "minitest/autorun"
-require "minitest/rails"
-require "minitest/pride" # Provides awesome colorful output
-require "minitest-rails-shoulda"
-
-require "thincloud/test"
-require "mocha/setup"
-require "factory_girl"
+require "thincloud/test/version"
module Thincloud
module Test
View
@@ -1,2 +1,2 @@
-require "thincloud/test/version"
-require "thincloud/test/railtie"
+require "minitest/autorun"
+require "minitest/pride" # Provides awesome colorful output
@@ -1,13 +0,0 @@
-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
@@ -1,13 +0,0 @@
-module Thincloud
- module Test
- class Railtie < ::Rails::Railtie
-
- initializer "thincloud.test.generators" do |app|
- app.config.generators do |g|
- g.test_framework :mini_test, spec: true, fixture: false
- end
- end
-
- end
- end
-end
@@ -0,0 +1 @@
+require "mocha/setup"
@@ -0,0 +1,54 @@
+require "thor"
+
+module Thincloud
+ module Test
+ class TestGenerator < ::Thor::Group
+ include ::Thor::Actions
+
+ source_root File.expand_path("../templates", __FILE__)
+
+ desc "Generates thincloud test infrastructure outside of Rails"
+ def testify!(opts = {})
+ setup_minitest if opts.fetch(:minitest, true)
+
+ copy_file "support/minitest_reporters.rb",
+ "test/support/minitest_reporters.rb"
+
+ copy_file "support/mocha.rb", "test/support/mocha.rb"
+
+ copy_file "test.rake", "lib/tasks/test.rake"
+
+ copy_file "Guardfile"
+
+ setup_ci
+
+ update_gitignore
+
+ say_status "", ""
+ say_status "success", "thincloud-test has finished."
+ say_status "", "Customize .travis.yml and test/ci/* for your project."
+ 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
+ remove_file "test/test_helper.rb"
+ copy_file "minitest_helper.rb", "test/minitest_helper.rb"
+ end
+
+ end
+ end
+end
@@ -1,5 +1,5 @@
module Thincloud
module Test
- VERSION = "0.8.0"
+ VERSION = "1.0.0.pre"
end
end
Oops, something went wrong.

0 comments on commit cc2726f

Please sign in to comment.