minitest-rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG.rdoc +4 -0
  3. data/Manifest.txt +13 -13
  4. data/README.rdoc +17 -0
  5. data/Rakefile +4 -4
  6. data/lib/generators/minitest.rb +3 -2
  7. data/lib/generators/minitest/controller/controller_generator.rb +13 -11
  8. data/lib/generators/minitest/controller/templates/controller_spec.rb +7 -0
  9. data/lib/generators/minitest/controller/templates/controller_test.rb +20 -0
  10. data/lib/generators/minitest/helper/helper_generator.rb +11 -5
  11. data/lib/generators/minitest/helper/templates/helper_spec.rb +7 -0
  12. data/lib/generators/minitest/helper/templates/helper_test.rb +7 -3
  13. data/lib/generators/minitest/install/install_generator.rb +22 -0
  14. data/lib/generators/minitest/install/templates/test/minitest_helper.rb +17 -0
  15. data/lib/generators/minitest/model/model_generator.rb +5 -5
  16. data/lib/generators/minitest/model/templates/model_spec.rb +1 -1
  17. data/lib/generators/minitest/model/templates/model_test.rb +6 -6
  18. data/lib/minitest-rails.rb +5 -33
  19. data/lib/minitest/rails.rb +8 -0
  20. data/lib/minitest/rails/base.rb +13 -0
  21. data/lib/minitest/rails/controller.rb +13 -0
  22. data/lib/minitest/rails/helper.rb +11 -0
  23. data/lib/minitest/rails/model.rb +17 -0
  24. data/test/test_controller_generator.rb +17 -17
  25. data/test/test_helper_generator.rb +39 -0
  26. data/test/test_install_generator.rb +27 -0
  27. data/test/test_model_generator.rb +17 -17
  28. metadata +25 -26
  29. metadata.gz.sig +0 -0
  30. data/lib/generators/minitest/integration/integration_generator.rb +0 -13
  31. data/lib/generators/minitest/integration/templates/integration_test.rb +0 -10
  32. data/lib/generators/minitest/mailer/mailer_generator.rb +0 -14
  33. data/lib/generators/minitest/mailer/templates/functional_test.rb +0 -23
  34. data/lib/generators/minitest/observer/observer_generator.rb +0 -13
  35. data/lib/generators/minitest/observer/templates/unit_test.rb +0 -11
  36. data/lib/generators/minitest/performance/performance_generator.rb +0 -13
  37. data/lib/generators/minitest/performance/templates/performance_test.rb +0 -12
  38. data/lib/generators/minitest/plugin/plugin_generator.rb +0 -13
  39. data/lib/generators/minitest/plugin/templates/%file_name%_test.rb.tt +0 -7
  40. data/lib/generators/minitest/plugin/templates/test_helper.rb +0 -4
  41. data/lib/generators/minitest/scaffold/scaffold_generator.rb +0 -17
  42. data/lib/generators/minitest/scaffold/templates/functional_test.rb +0 -53
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.0.2 / 2011-06-02
2
+
3
+ Incomplete, but no longer in (known) a broken state.
4
+
1
5
  === 0.0.1 / 2011-05-24
2
6
 
3
7
  * 1 major enhancement
data/Manifest.txt CHANGED
@@ -5,26 +5,26 @@ README.rdoc
5
5
  Rakefile
6
6
  lib/generators/minitest.rb
7
7
  lib/generators/minitest/controller/controller_generator.rb
8
+ lib/generators/minitest/controller/templates/controller_spec.rb
9
+ lib/generators/minitest/controller/templates/controller_test.rb
8
10
  lib/generators/minitest/helper/helper_generator.rb
11
+ lib/generators/minitest/helper/templates/helper_spec.rb
9
12
  lib/generators/minitest/helper/templates/helper_test.rb
10
- lib/generators/minitest/integration/integration_generator.rb
11
- lib/generators/minitest/integration/templates/integration_test.rb
12
- lib/generators/minitest/mailer/mailer_generator.rb
13
- lib/generators/minitest/mailer/templates/functional_test.rb
13
+ lib/generators/minitest/install/install_generator.rb
14
+ lib/generators/minitest/install/templates/test/minitest_helper.rb
14
15
  lib/generators/minitest/model/model_generator.rb
15
16
  lib/generators/minitest/model/templates/fixtures.yml
16
17
  lib/generators/minitest/model/templates/model_spec.rb
17
18
  lib/generators/minitest/model/templates/model_test.rb
18
- lib/generators/minitest/observer/observer_generator.rb
19
- lib/generators/minitest/observer/templates/unit_test.rb
20
- lib/generators/minitest/performance/performance_generator.rb
21
- lib/generators/minitest/performance/templates/performance_test.rb
22
- lib/generators/minitest/plugin/plugin_generator.rb
23
- lib/generators/minitest/plugin/templates/%file_name%_test.rb.tt
24
- lib/generators/minitest/plugin/templates/test_helper.rb
25
- lib/generators/minitest/scaffold/scaffold_generator.rb
26
- lib/generators/minitest/scaffold/templates/functional_test.rb
27
19
  lib/minitest-rails.rb
20
+ lib/minitest/rails.rb
21
+ lib/minitest/rails/base.rb
22
+ lib/minitest/rails/controller.rb
23
+ lib/minitest/rails/helper.rb
24
+ lib/minitest/rails/model.rb
28
25
  lib/minitest/rails/tasks/minitest.rake
26
+ test/test_controller_generator.rb
27
+ test/test_helper_generator.rb
28
+ test/test_install_generator.rb
29
29
  test/test_minitest.rb
30
30
  test/test_model_generator.rb
data/README.rdoc CHANGED
@@ -28,7 +28,24 @@ Or, for the unenlightened, add `minitest-rails` to the `:test` and `:development
28
28
  gem 'minitest-rails'
29
29
  end
30
30
 
31
+ Next run the installation generator with the following:
32
+
33
+ rails generate minitest:install
34
+
35
+ This will add the `minitest_helper.rb` file to the `test` directory.
36
+
31
37
  == Usage
32
38
 
33
39
  We aim to expose MiniTest with minimal changes for testing within Rails.
34
40
  You can either create test classes that inherit from MiniTest::Unit::TestCase or you can use the MiniTest::Spec DSL.
41
+ You can generate tests when you use the standard model, controller, scaffold, and other generators:
42
+
43
+ rails generate model User
44
+
45
+ Or, you can use the MiniTest generators directly:
46
+
47
+ rails generate minitest::model User
48
+
49
+ And you can specify generating the tests using the MiniTest::Spec DSL on any of the generators by providing the `--spec` option:
50
+
51
+ rails generate model User --spec
data/Rakefile CHANGED
@@ -17,10 +17,10 @@ Hoe.spec 'minitest-rails' do
17
17
  self.readme_file = "README.rdoc"
18
18
  self.testlib = :minitest
19
19
 
20
- extra_deps << ['minitest', '~> 2.0']
21
- extra_deps << ['railties', '~> 3.0']
22
- extra_deps << ['activesupport', '~> 3.0']
23
- extra_deps << ['actionpack', '~> 3.0']
20
+ extra_deps << ['minitest', '~> 2.2']
21
+ extra_deps << ['railties', '= 3.1.0.rc1']
22
+ extra_deps << ['activesupport', '= 3.1.0.rc1']
23
+ extra_deps << ['actionpack', '= 3.1.0.rc1']
24
24
  end
25
25
 
26
26
  # vim: syntax=ruby
@@ -1,7 +1,8 @@
1
1
  require 'rails/generators/named_base'
2
2
 
3
- # Blatantly stolen from rspec-rails
4
- module MiniTest
3
+ # Ugh, Rails pukes on minitest -> MiniTest
4
+ # So name this "Minitest" to appease the Rails for now
5
+ module Minitest
5
6
  module Generators
6
7
  class Base < ::Rails::Generators::NamedBase #:nodoc:
7
8
  def self.source_root
@@ -1,17 +1,19 @@
1
- require 'generators/minitest'
1
+ require "generators/minitest"
2
2
 
3
- module MiniTest::Generators
4
- class ControllerGenerator < Base
5
- argument :actions, :type => :array, :default => [], :banner => "action action"
6
- class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
3
+ module Minitest
4
+ module Generators
5
+ class ControllerGenerator < Base
6
+ argument :actions, :type => :array, :default => [], :banner => "action action"
7
+ class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
7
8
 
8
- check_class_collision :suffix => "ControllerTest"
9
+ check_class_collision :suffix => "ControllerTest"
9
10
 
10
- def create_test_files
11
- if options[:spec]
12
- template 'controller_spec.rb', File.join('test/controllers', class_path, "#{file_name}_controller_test.rb")
13
- else
14
- template 'controller_test.rb', File.join('test/controllers', class_path, "#{file_name}_controller_test.rb")
11
+ def create_test_files
12
+ if options[:spec]
13
+ template "controller_spec.rb", "test/controllers/#{file_name}_controller_test.rb"
14
+ else
15
+ template "controller_test.rb", "test/controllers/#{file_name}_controller_test.rb"
16
+ end
15
17
  end
16
18
  end
17
19
  end
@@ -0,0 +1,7 @@
1
+ require "minitest_helper"
2
+
3
+ describe <%= class_name %>Controller do
4
+ before do
5
+ @controller = <%= class_name %>Controller.new
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ require "minitest_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>ControllerTest < MiniTest::Rails::ControllerTestCase
5
+
6
+ <% if actions.empty? -%>
7
+ def test_truth
8
+ assert true
9
+ end
10
+ <% else -%>
11
+ <% actions.each do |action| -%>
12
+ def test_<%= action %>
13
+ get :<%= action %>
14
+ assert_response :success
15
+ end
16
+
17
+ <% end -%>
18
+ <% end -%>
19
+ end
20
+ <% end -%>
@@ -1,12 +1,18 @@
1
- require 'generators/minitest'
1
+ require "generators/minitest"
2
2
 
3
- module MiniTest
3
+ module Minitest
4
4
  module Generators
5
- class HelperGenerator < MiniTest::Rails::Generators::Base
5
+ class HelperGenerator < Base
6
+ class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
7
+
6
8
  check_class_collision :suffix => "HelperTest"
7
9
 
8
- def create_helper_files
9
- template 'helper_test.rb', File.join('test/unit/helpers', class_path, "#{file_name}_helper_test.rb")
10
+ def create_test_files
11
+ if options[:spec]
12
+ template "helper_spec.rb", "test/helpers/#{file_name}_helper_test.rb"
13
+ else
14
+ template "helper_test.rb", "test/helpers/#{file_name}_helper_test.rb"
15
+ end
10
16
  end
11
17
  end
12
18
  end
@@ -0,0 +1,7 @@
1
+ require "minitest_helper"
2
+
3
+ describe <%= class_name %>Helper do
4
+ before do
5
+ @helper= <%= class_name %>Helper.new
6
+ end
7
+ end
@@ -1,7 +1,11 @@
1
- require 'test_helper'
1
+ require "minitest_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- class <%= class_name %>HelperTest < MiniTest::Unit::TestCase
5
- # load_code_to_test_helper
4
+ class <%= class_name %>HelperTest < MiniTest::Rails::HelperTestCase
5
+
6
+ def test_truth
7
+ assert true
8
+ end
9
+
6
10
  end
7
11
  <% end -%>
@@ -0,0 +1,22 @@
1
+ require 'rails/generators'
2
+
3
+ module Minitest
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+
7
+ desc <<DESC
8
+ Description:
9
+ Copy minitest files to your application.
10
+ DESC
11
+
12
+ def self.source_root
13
+ @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
14
+ end
15
+
16
+ def copy_minitest_files
17
+ directory 'test'
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ require "minitest/autorun"
2
+ require "minitest/rails"
3
+
4
+ ENV["RAILS_ENV"] = "test"
5
+ require File.expand_path('../../config/environment', __FILE__)
6
+
7
+ class MiniTest::Rails::TestCase
8
+
9
+ # Add methods to be used by all tests here...
10
+
11
+ end
12
+
13
+ class MiniTest::Rails::Spec
14
+
15
+ # Add methods to be used by all specs here...
16
+
17
+ end
@@ -1,6 +1,6 @@
1
- require 'generators/minitest'
1
+ require "generators/minitest"
2
2
 
3
- module MiniTest
3
+ module Minitest
4
4
  module Generators
5
5
  class ModelGenerator < Base
6
6
  argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
@@ -11,12 +11,12 @@ module MiniTest
11
11
 
12
12
  def create_test_files
13
13
  if options[:spec]
14
- template 'model_spec.rb', File.join('test/models', class_path, "#{file_name}_test.rb")
14
+ template "model_spec.rb", "test/models/#{file_name}_test.rb"
15
15
  else
16
- template 'model_test.rb', File.join('test/models', class_path, "#{file_name}_test.rb")
16
+ template "model_test.rb", "test/models/#{file_name}_test.rb"
17
17
  end
18
18
  if options[:fixture]
19
- template 'fixtures.yml', File.join('test/fixtures', class_path, "#{plural_file_name}.yml")
19
+ template "fixtures.yml", "test/fixtures/#{plural_file_name}.yml"
20
20
  end
21
21
  end
22
22
  end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "minitest_helper"
2
2
 
3
3
  describe <%= class_name %> do
4
4
  before do
@@ -1,11 +1,11 @@
1
- require 'test_helper'
1
+ require "minitest_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- class <%= class_name %>Test < MiniTest::Unit::TestCase
5
- load_code_to_test_model
4
+ class <%= class_name %>Test < MiniTest::Rails::ModelTestCase
5
+
6
+ def test_truth
7
+ assert true
8
+ end
6
9
 
7
- # def test_truth
8
- # assert true
9
- # end
10
10
  end
11
11
  <% end -%>
@@ -1,44 +1,16 @@
1
- require 'rails/railtie'
2
- require 'active_support/testing/setup_and_teardown'
3
- require 'active_record/fixtures'
4
- require 'action_controller'
5
-
6
-
7
- require 'minitest/unit'
8
- require 'minitest/spec'
9
- require 'minitest/mock'
1
+ require "rails"
10
2
 
11
3
  module MiniTest
12
4
  module Rails
13
- VERSION = '0.0.1'
5
+ VERSION = "0.0.2"
14
6
  class Railtie < ::Rails::Railtie
15
7
  config.app_generators.integration_tool :minitest
16
- config.app_generators.test_framework :minitest
8
+ config.app_generators.test_framework :minitest, :fixture => true
9
+ config.app_generators.fallbacks[:minitest] = :test_unit
17
10
 
18
11
  rake_tasks do
19
- load 'minitest/rails/tasks/minitest.rake'
12
+ load "minitest/rails/tasks/minitest.rake"
20
13
  end
21
14
  end
22
15
  end
23
16
  end
24
-
25
- # Tip of hat to tenderlove for the following
26
- # https://gist.github.com/821572
27
- class MiniTest::Unit::TestCase
28
- include ActiveSupport::Testing::SetupAndTeardown
29
-
30
- def load_code_to_test_model
31
- include ActiveRecord::TestFixtures
32
- self.fixture_path = File.join(Rails.root, 'test', 'fixtures')
33
- end
34
-
35
- def load_code_to_test_controller
36
- include ActionController::TestCase::Behavior
37
- end
38
-
39
- # Support integration tests by calling ""
40
- end
41
-
42
- class MiniTest::Spec
43
- alias :method_name :__name__ if defined? :__name__
44
- end
@@ -0,0 +1,8 @@
1
+ require "minitest/rails/model"
2
+ require "minitest/rails/helper"
3
+ require "minitest/rails/controller"
4
+
5
+ # The order you register matters
6
+ MiniTest::Spec.register_spec_type(//, MiniTest::Rails::ModelSpec)
7
+ MiniTest::Spec.register_spec_type(/Controller$/, MiniTest::Rails::ControllerSpec)
8
+ MiniTest::Spec.register_spec_type(/Helper$/, MiniTest::Rails::HelperSpec)
@@ -0,0 +1,13 @@
1
+ require "minitest/unit"
2
+ require "minitest/spec"
3
+ require "minitest/mock"
4
+
5
+ module MiniTest
6
+ module Rails
7
+ class TestCase < ::MiniTest::Unit::TestCase
8
+ end
9
+ class Spec < ::MiniTest::Spec
10
+ # alias :method_name :__name__ if defined? :__name__
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require "minitest/rails/base"
2
+ # require "action_controller"
3
+
4
+ module MiniTest
5
+ module Rails
6
+ class ControllerTestCase < TestCase
7
+ # include ActionController::TestCase::Behavior
8
+ end
9
+
10
+ class ControllerSpec < Spec
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ require "minitest/rails/base"
2
+
3
+ module MiniTest
4
+ module Rails
5
+ class HelperTestCase < TestCase
6
+ end
7
+
8
+ class HelperSpec < Spec
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ require "minitest/rails/base"
2
+ # require "active_support/testing/setup_and_teardown"
3
+ # require "active_record/fixtures"
4
+
5
+ module MiniTest
6
+ module Rails
7
+ class ModelTestCase < TestCase
8
+ # include ActiveSupport::Testing::SetupAndTeardown
9
+ # include ActiveRecord::TestFixtures
10
+ #
11
+ # self.fixture_path = File.join(Rails.root, "test", "fixtures")
12
+ end
13
+
14
+ class ModelSpec < Spec
15
+ end
16
+ end
17
+ end
@@ -1,39 +1,39 @@
1
1
  require "minitest/autorun"
2
2
  require "minitest-rails"
3
3
 
4
- require 'rails'
5
- require 'rails/generators'
4
+ require "rails"
5
+ require "rails/generators"
6
6
 
7
- require 'generators/minitest/controller/controller_generator'
7
+ require "generators/minitest/controller/controller_generator"
8
8
 
9
- require 'fileutils'
9
+ require "fileutils"
10
10
 
11
11
  class TestControllerGenerator < MiniTest::Unit::TestCase
12
12
  Rails::Generators.no_color!
13
13
 
14
14
  def test_controller_generator
15
15
  text = capture(:stdout) do
16
- MiniTest::Generators::ControllerGenerator.start ['user']
16
+ Minitest::Generators::ControllerGenerator.start ["user"]
17
17
  end
18
- assert_equal " create test/controllers/user_controller_test.rb\n", text
19
- assert File.exists? 'test/controllers/user_controller_test.rb'
20
- contents = open('test/controllers/user_controller_test.rb').read
21
- assert_match /class UserControllerTest < MiniTest::Unit::TestCase/m, contents
18
+ assert_match(/create test\/controllers\/user_controller_test.rb/m, text)
19
+ assert File.exists? "test/controllers/user_controller_test.rb"
20
+ contents = open("test/controllers/user_controller_test.rb").read
21
+ assert_match(/class UserControllerTest < MiniTest::Rails::ControllerTestCase/m, contents)
22
22
  ensure
23
- # TODO: Don't write the files
23
+ # TODO: Don"t write the files
24
24
  # I agree, it would be better to mock the file getting written
25
- FileUtils.rm_r 'test/controllers'
25
+ FileUtils.rm_r "test/controllers"
26
26
  end
27
27
 
28
28
  def test_controller_generator_spec
29
29
  text = capture(:stdout) do
30
- MiniTest::Generators::ControllerGenerator.start ['user', '--spec']
30
+ Minitest::Generators::ControllerGenerator.start ["user", "--spec"]
31
31
  end
32
- assert_equal " create test/controllers/user_controller_test.rb\n", text
33
- assert File.exists? 'test/controllers/user_controller_test.rb'
34
- contents = open('test/controllers/user_controller_test.rb').read
35
- assert_match /describe UserController do/m, contents
32
+ assert_match(/create test\/controllers\/user_controller_test.rb/m, text)
33
+ assert File.exists? "test/controllers/user_controller_test.rb"
34
+ contents = open("test/controllers/user_controller_test.rb").read
35
+ assert_match(/describe UserController do/m, contents)
36
36
  ensure
37
- FileUtils.rm_r 'test/controllers'
37
+ FileUtils.rm_r "test/controllers"
38
38
  end
39
39
  end
@@ -0,0 +1,39 @@
1
+ require "minitest/autorun"
2
+ require "minitest-rails"
3
+
4
+ require "rails"
5
+ require "rails/generators"
6
+
7
+ require "generators/minitest/helper/helper_generator"
8
+
9
+ require "fileutils"
10
+
11
+ class TestHelperGenerator < MiniTest::Unit::TestCase
12
+ Rails::Generators.no_color!
13
+
14
+ def test_helper_generator
15
+ text = capture(:stdout) do
16
+ Minitest::Generators::HelperGenerator.start ["user"]
17
+ end
18
+ assert_match(/create test\/helpers\/user_helper_test.rb/m, text)
19
+ assert File.exists? "test/helpers/user_helper_test.rb"
20
+ contents = open("test/helpers/user_helper_test.rb").read
21
+ assert_match(/class UserHelperTest < MiniTest::Rails::HelperTestCase/m, contents)
22
+ ensure
23
+ # TODO: Don"t write the files
24
+ # I agree, it would be better to mock the file getting written
25
+ FileUtils.rm_r "test/helpers"
26
+ end
27
+
28
+ def test_helper_generator_spec
29
+ text = capture(:stdout) do
30
+ Minitest::Generators::HelperGenerator.start ["user", "--spec"]
31
+ end
32
+ assert_match(/create test\/helpers\/user_helper_test.rb/m, text)
33
+ assert File.exists? "test/helpers/user_helper_test.rb"
34
+ contents = open("test/helpers/user_helper_test.rb").read
35
+ assert_match(/describe UserHelper do/m, contents)
36
+ ensure
37
+ FileUtils.rm_r "test/helpers"
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ require "minitest/autorun"
2
+ require "minitest-rails"
3
+
4
+ require "rails"
5
+ require "rails/generators"
6
+
7
+ require "generators/minitest/install/install_generator"
8
+
9
+ require "fileutils"
10
+
11
+ class TestInstallGenerator < MiniTest::Unit::TestCase
12
+ Rails::Generators.no_color!
13
+
14
+ def test_install_generator
15
+ text = capture(:stdout) do
16
+ Minitest::Generators::InstallGenerator.start
17
+ end
18
+ assert_match(/create test\/minitest_helper.rb/m, text)
19
+ assert File.exists? "test/minitest_helper.rb"
20
+ contents = open("test/minitest_helper.rb").read
21
+ assert_match(/class MiniTest::Rails::TestCase/m, contents)
22
+ ensure
23
+ # TODO: Don"t write the files
24
+ # I agree, it would be better to mock the file getting written
25
+ FileUtils.rm "test/minitest_helper.rb"
26
+ end
27
+ end
@@ -1,39 +1,39 @@
1
1
  require "minitest/autorun"
2
2
  require "minitest-rails"
3
3
 
4
- require 'rails'
5
- require 'rails/generators'
4
+ require "rails"
5
+ require "rails/generators"
6
6
 
7
- require 'generators/minitest/model/model_generator'
7
+ require "generators/minitest/model/model_generator"
8
8
 
9
- require 'fileutils'
9
+ require "fileutils"
10
10
 
11
11
  class TestModelGenerator < MiniTest::Unit::TestCase
12
12
  Rails::Generators.no_color!
13
13
 
14
14
  def test_model_generator
15
15
  text = capture(:stdout) do
16
- MiniTest::Generators::ModelGenerator.start ['user']
16
+ Minitest::Generators::ModelGenerator.start ["user"]
17
17
  end
18
- assert_equal " create test/models/user_test.rb\n", text
19
- assert File.exists? 'test/models/user_test.rb'
20
- contents = open('test/models/user_test.rb').read
21
- assert_match /class UserTest < MiniTest::Unit::TestCase/m, contents
18
+ assert_match(/create test\/models\/user_test.rb/m, text)
19
+ assert File.exists? "test/models/user_test.rb"
20
+ contents = open("test/models/user_test.rb").read
21
+ assert_match(/class UserTest < MiniTest::Rails::ModelTestCase/m, contents)
22
22
  ensure
23
- # TODO: Don't write the files
23
+ # TODO: Don"t write the files
24
24
  # I agree, it would be better to mock the file getting written
25
- FileUtils.rm_r 'test/models'
25
+ FileUtils.rm_r "test/models"
26
26
  end
27
27
 
28
28
  def test_model_generator_spec
29
29
  text = capture(:stdout) do
30
- MiniTest::Generators::ModelGenerator.start ['user', '--spec']
30
+ Minitest::Generators::ModelGenerator.start ["user", "--spec"]
31
31
  end
32
- assert_equal " create test/models/user_test.rb\n", text
33
- assert File.exists? 'test/models/user_test.rb'
34
- contents = open('test/models/user_test.rb').read
35
- assert_match /describe User do/m, contents
32
+ assert_match(/create test\/models\/user_test.rb/m, text)
33
+ assert File.exists? "test/models/user_test.rb"
34
+ contents = open("test/models/user_test.rb").read
35
+ assert_match(/describe User do/m, contents)
36
36
  ensure
37
- FileUtils.rm_r 'test/models'
37
+ FileUtils.rm_r "test/models"
38
38
  end
39
39
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: minitest-rails
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mike Moore
@@ -31,8 +31,7 @@ cert_chain:
31
31
  sgxAiQ==
32
32
  -----END CERTIFICATE-----
33
33
 
34
- date: 2011-05-25 00:00:00 -06:00
35
- default_executable:
34
+ date: 2011-06-03 00:00:00 Z
36
35
  dependencies:
37
36
  - !ruby/object:Gem::Dependency
38
37
  name: minitest
@@ -42,7 +41,7 @@ dependencies:
42
41
  requirements:
43
42
  - - ~>
44
43
  - !ruby/object:Gem::Version
45
- version: "2.0"
44
+ version: "2.2"
46
45
  type: :runtime
47
46
  version_requirements: *id001
48
47
  - !ruby/object:Gem::Dependency
@@ -51,9 +50,9 @@ dependencies:
51
50
  requirement: &id002 !ruby/object:Gem::Requirement
52
51
  none: false
53
52
  requirements:
54
- - - ~>
53
+ - - "="
55
54
  - !ruby/object:Gem::Version
56
- version: "3.0"
55
+ version: 3.1.0.rc1
57
56
  type: :runtime
58
57
  version_requirements: *id002
59
58
  - !ruby/object:Gem::Dependency
@@ -62,9 +61,9 @@ dependencies:
62
61
  requirement: &id003 !ruby/object:Gem::Requirement
63
62
  none: false
64
63
  requirements:
65
- - - ~>
64
+ - - "="
66
65
  - !ruby/object:Gem::Version
67
- version: "3.0"
66
+ version: 3.1.0.rc1
68
67
  type: :runtime
69
68
  version_requirements: *id003
70
69
  - !ruby/object:Gem::Dependency
@@ -73,9 +72,9 @@ dependencies:
73
72
  requirement: &id004 !ruby/object:Gem::Requirement
74
73
  none: false
75
74
  requirements:
76
- - - ~>
75
+ - - "="
77
76
  - !ruby/object:Gem::Version
78
- version: "3.0"
77
+ version: 3.1.0.rc1
79
78
  type: :runtime
80
79
  version_requirements: *id004
81
80
  - !ruby/object:Gem::Dependency
@@ -106,32 +105,30 @@ files:
106
105
  - Rakefile
107
106
  - lib/generators/minitest.rb
108
107
  - lib/generators/minitest/controller/controller_generator.rb
108
+ - lib/generators/minitest/controller/templates/controller_spec.rb
109
+ - lib/generators/minitest/controller/templates/controller_test.rb
109
110
  - lib/generators/minitest/helper/helper_generator.rb
111
+ - lib/generators/minitest/helper/templates/helper_spec.rb
110
112
  - lib/generators/minitest/helper/templates/helper_test.rb
111
- - lib/generators/minitest/integration/integration_generator.rb
112
- - lib/generators/minitest/integration/templates/integration_test.rb
113
- - lib/generators/minitest/mailer/mailer_generator.rb
114
- - lib/generators/minitest/mailer/templates/functional_test.rb
113
+ - lib/generators/minitest/install/install_generator.rb
114
+ - lib/generators/minitest/install/templates/test/minitest_helper.rb
115
115
  - lib/generators/minitest/model/model_generator.rb
116
116
  - lib/generators/minitest/model/templates/fixtures.yml
117
117
  - lib/generators/minitest/model/templates/model_spec.rb
118
118
  - lib/generators/minitest/model/templates/model_test.rb
119
- - lib/generators/minitest/observer/observer_generator.rb
120
- - lib/generators/minitest/observer/templates/unit_test.rb
121
- - lib/generators/minitest/performance/performance_generator.rb
122
- - lib/generators/minitest/performance/templates/performance_test.rb
123
- - lib/generators/minitest/plugin/plugin_generator.rb
124
- - lib/generators/minitest/plugin/templates/%file_name%_test.rb.tt
125
- - lib/generators/minitest/plugin/templates/test_helper.rb
126
- - lib/generators/minitest/scaffold/scaffold_generator.rb
127
- - lib/generators/minitest/scaffold/templates/functional_test.rb
128
119
  - lib/minitest-rails.rb
120
+ - lib/minitest/rails.rb
121
+ - lib/minitest/rails/base.rb
122
+ - lib/minitest/rails/controller.rb
123
+ - lib/minitest/rails/helper.rb
124
+ - lib/minitest/rails/model.rb
129
125
  - lib/minitest/rails/tasks/minitest.rake
126
+ - test/test_controller_generator.rb
127
+ - test/test_helper_generator.rb
128
+ - test/test_install_generator.rb
130
129
  - test/test_minitest.rb
131
130
  - test/test_model_generator.rb
132
- - test/test_controller_generator.rb
133
131
  - .gemtest
134
- has_rdoc: true
135
132
  homepage: http://blowmage.com/minitest-rails
136
133
  licenses: []
137
134
 
@@ -156,11 +153,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
153
  requirements: []
157
154
 
158
155
  rubyforge_project: minitest-rails
159
- rubygems_version: 1.6.0
156
+ rubygems_version: 1.8.5
160
157
  signing_key:
161
158
  specification_version: 3
162
159
  summary: MiniTest integration for Rails 3.1.
163
160
  test_files:
164
161
  - test/test_controller_generator.rb
162
+ - test/test_helper_generator.rb
163
+ - test/test_install_generator.rb
165
164
  - test/test_minitest.rb
166
165
  - test/test_model_generator.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,13 +0,0 @@
1
- require 'generators/minitest'
2
-
3
- module MiniTest
4
- module Generators
5
- class IntegrationGenerator < MiniTest::Rails::Generators::Base
6
- check_class_collision :suffix => "Test"
7
-
8
- def create_test_files
9
- template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb")
10
- end
11
- end
12
- end
13
- end
@@ -1,10 +0,0 @@
1
- require 'test_helper'
2
-
3
- class <%= class_name %>Test < MiniTest::Unit::TestCase
4
- load_code_to_test_integration
5
- fixtures :all
6
-
7
- # def test_truth
8
- # assert true
9
- # end
10
- end
@@ -1,14 +0,0 @@
1
- require 'generators/minitest'
2
-
3
- module MiniTest
4
- module Generators
5
- class MailerGenerator < MiniTest::Rails::Generators::Base
6
- argument :actions, :type => :array, :default => [], :banner => "method method"
7
- check_class_collision :suffix => "Test"
8
-
9
- def create_test_files
10
- template "functional_test.rb", File.join('test/functional', class_path, "#{file_name}_test.rb")
11
- end
12
- end
13
- end
14
- end
@@ -1,23 +0,0 @@
1
- require 'test_helper'
2
-
3
- <% module_namespacing do -%>
4
- class <%= class_name %>Test < MiniTest::Unit::TestCase
5
- # load_code_to_test_mailer
6
-
7
- <% actions.each do |action| -%>
8
- def test_<%= action %>
9
- mail = <%= class_name %>.<%= action %>
10
- assert_equal <%= action.to_s.humanize.inspect %>, mail.subject
11
- assert_equal ["to@example.org"], mail.to
12
- assert_equal ["from@example.com"], mail.from
13
- assert_match "Hi", mail.body.encoded
14
- end
15
-
16
- <% end -%>
17
- <% if actions.blank? -%>
18
- # def test_truth
19
- # assert true
20
- # end
21
- <% end -%>
22
- end
23
- <% end -%>
@@ -1,13 +0,0 @@
1
- require 'generators/minitest'
2
-
3
- module MiniTest
4
- module Generators
5
- class ObserverGenerator < MiniTest::Rails::Generators::Base
6
- check_class_collision :suffix => "ObserverTest"
7
-
8
- def create_test_files
9
- template 'unit_test.rb', File.join('test/unit', class_path, "#{file_name}_observer_test.rb")
10
- end
11
- end
12
- end
13
- end
@@ -1,11 +0,0 @@
1
- require 'test_helper'
2
-
3
- <% module_namespacing do -%>
4
- class <%= class_name %>ObserverTest < MiniTest::Unit::TestCase
5
- # load_code_to_test_observer
6
-
7
- # def test_truth
8
- # assert true
9
- # end
10
- end
11
- <% end -%>
@@ -1,13 +0,0 @@
1
- require 'generators/minitest'
2
-
3
- module MiniTest
4
- module Generators
5
- class PerformanceGenerator < MiniTest::Rails::Generators::Base
6
- check_class_collision :suffix => "Test"
7
-
8
- def create_test_files
9
- template 'performance_test.rb', File.join('test/performance', class_path, "#{file_name}_test.rb")
10
- end
11
- end
12
- end
13
- end
@@ -1,12 +0,0 @@
1
- require 'test_helper'
2
- require 'rails/performance_test_help'
3
-
4
- class <%= class_name %>Test < ActionDispatch::PerformanceTest
5
- # Refer to the documentation for all available options
6
- # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
7
- # :output => 'tmp/performance', :formats => [:flat] }
8
-
9
- def test_homepage
10
- get '/'
11
- end
12
- end
@@ -1,13 +0,0 @@
1
- require 'generators/minitest'
2
-
3
- module MiniTest
4
- module Generators
5
- class PluginGenerator < MiniTest::Rails::Generators::Base
6
- check_class_collision :suffix => "Test"
7
-
8
- def create_test_files
9
- directory '.', 'test'
10
- end
11
- end
12
- end
13
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class <%= class_name %>Test < MiniTest::Unit::TestCase
4
- # def test_truth
5
- # assert true
6
- # end
7
- end
@@ -1,4 +0,0 @@
1
- require 'rubygems'
2
- require 'minitest'
3
- require 'minitest-rails'
4
- require 'active_support'
@@ -1,17 +0,0 @@
1
- require 'generators/minitest'
2
- require 'rails/generators/resource_helpers'
3
-
4
- module MiniTest
5
- module Generators
6
- class ScaffoldGenerator < MiniTest::Rails::Generators::Base
7
- include Rails::Generators::ResourceHelpers
8
-
9
- check_class_collision :suffix => "ControllerTest"
10
-
11
- def create_test_files
12
- template 'functional_test.rb',
13
- File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb")
14
- end
15
- end
16
- end
17
- end
@@ -1,53 +0,0 @@
1
- require 'test_helper'
2
-
3
- <% module_namespacing do -%>
4
- class <%= controller_class_name %>ControllerTest < MiniTest::Unit::TestCase
5
- load_code_to_test_controller
6
-
7
- setup do
8
- @<%= singular_table_name %> = <%= table_name %>(:one)
9
- end
10
-
11
- def test_index do
12
- get :index
13
- assert_response :success
14
- assert_not_nil assigns(:<%= table_name %>)
15
- end
16
-
17
- def test_new
18
- get :new
19
- assert_response :success
20
- end
21
-
22
- def test_create
23
- assert_difference('<%= class_name %>.count') do
24
- post :create, <%= key_value singular_table_name, "@#{singular_table_name}.attributes" %>
25
- end
26
-
27
- assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
28
- end
29
-
30
- def test_show
31
- get :show, <%= key_value :id, "@#{singular_table_name}.to_param" %>
32
- assert_response :success
33
- end
34
-
35
- def test_edit
36
- get :edit, <%= key_value :id, "@#{singular_table_name}.to_param" %>
37
- assert_response :success
38
- end
39
-
40
- def test_update
41
- put :update, <%= key_value :id, "@#{singular_table_name}.to_param" %>, <%= key_value singular_table_name, "@#{singular_table_name}.attributes" %>
42
- assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
43
- end
44
-
45
- def test_destroy
46
- assert_difference('<%= class_name %>.count', -1) do
47
- delete :destroy, <%= key_value :id, "@#{singular_table_name}.to_param" %>
48
- end
49
-
50
- assert_redirected_to <%= index_helper %>_path
51
- end
52
- end
53
- <% end -%>