minitest-rails 0.0.2 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG.rdoc +4 -0
  3. data/Manifest.txt +23 -14
  4. data/README.rdoc +6 -6
  5. data/Rakefile +3 -3
  6. data/lib/generators/{minitest.rb → mini_test.rb} +2 -4
  7. data/lib/generators/{minitest → mini_test}/controller/controller_generator.rb +2 -2
  8. data/lib/generators/mini_test/controller/templates/controller_spec.rb +11 -0
  9. data/lib/generators/{minitest → mini_test}/controller/templates/controller_test.rb +3 -3
  10. data/lib/generators/{minitest → mini_test}/helper/helper_generator.rb +2 -2
  11. data/lib/generators/mini_test/helper/templates/helper_spec.rb +11 -0
  12. data/lib/generators/mini_test/helper/templates/helper_test.rb +11 -0
  13. data/lib/generators/{minitest → mini_test}/install/install_generator.rb +2 -2
  14. data/lib/generators/{minitest → mini_test}/install/templates/test/minitest_helper.rb +8 -7
  15. data/lib/generators/mini_test/mailer/mailer_generator.rb +20 -0
  16. data/lib/generators/mini_test/mailer/templates/mailer_spec.rb +19 -0
  17. data/lib/generators/mini_test/mailer/templates/mailer_test.rb +21 -0
  18. data/lib/generators/{minitest → mini_test}/model/model_generator.rb +9 -4
  19. data/lib/generators/{minitest → mini_test}/model/templates/fixtures.yml +0 -0
  20. data/lib/generators/{minitest → mini_test}/model/templates/model_spec.rb +5 -1
  21. data/lib/generators/mini_test/model/templates/model_test.rb +11 -0
  22. data/lib/generators/mini_test/scaffold/scaffold_generator.rb +22 -0
  23. data/lib/generators/mini_test/scaffold/templates/controller_spec.rb +51 -0
  24. data/lib/generators/mini_test/scaffold/templates/controller_test.rb +51 -0
  25. data/lib/minitest-rails.rb +4 -4
  26. data/lib/minitest/rails.rb +2 -6
  27. data/lib/minitest/rails/controller.rb +3 -6
  28. data/lib/minitest/rails/helper.rb +2 -5
  29. data/lib/minitest/rails/mailer.rb +8 -0
  30. data/lib/minitest/rails/model.rb +2 -11
  31. data/lib/minitest/rails/{base.rb → spec.rb} +1 -3
  32. data/lib/minitest/rails/tasks/minitest.rake +1 -1
  33. data/test/test_controller_generator.rb +7 -5
  34. data/test/test_helper_generator.rb +5 -5
  35. data/test/test_install_generator.rb +3 -3
  36. data/test/test_mailer_generator.rb +39 -0
  37. data/test/test_model_generator.rb +5 -5
  38. data/test/test_scaffold_generator.rb +41 -0
  39. metadata +30 -19
  40. metadata.gz.sig +0 -0
  41. data/lib/generators/minitest/controller/templates/controller_spec.rb +0 -7
  42. data/lib/generators/minitest/helper/templates/helper_spec.rb +0 -7
  43. data/lib/generators/minitest/helper/templates/helper_test.rb +0 -11
  44. data/lib/generators/minitest/model/templates/model_test.rb +0 -11
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.0.4 / 2011-06-08
2
+
3
+ Add scaffold, bump to Rails 3.1.0.rc2
4
+
1
5
  === 0.0.2 / 2011-06-02
2
6
 
3
7
  Incomplete, but no longer in (known) a broken state.
data/Manifest.txt CHANGED
@@ -3,28 +3,37 @@ CHANGELOG.rdoc
3
3
  Manifest.txt
4
4
  README.rdoc
5
5
  Rakefile
6
- lib/generators/minitest.rb
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
10
- lib/generators/minitest/helper/helper_generator.rb
11
- lib/generators/minitest/helper/templates/helper_spec.rb
12
- lib/generators/minitest/helper/templates/helper_test.rb
13
- lib/generators/minitest/install/install_generator.rb
14
- lib/generators/minitest/install/templates/test/minitest_helper.rb
15
- lib/generators/minitest/model/model_generator.rb
16
- lib/generators/minitest/model/templates/fixtures.yml
17
- lib/generators/minitest/model/templates/model_spec.rb
18
- lib/generators/minitest/model/templates/model_test.rb
6
+ lib/generators/mini_test.rb
7
+ lib/generators/mini_test/controller/controller_generator.rb
8
+ lib/generators/mini_test/controller/templates/controller_spec.rb
9
+ lib/generators/mini_test/controller/templates/controller_test.rb
10
+ lib/generators/mini_test/helper/helper_generator.rb
11
+ lib/generators/mini_test/helper/templates/helper_spec.rb
12
+ lib/generators/mini_test/helper/templates/helper_test.rb
13
+ lib/generators/mini_test/install/install_generator.rb
14
+ lib/generators/mini_test/install/templates/test/minitest_helper.rb
15
+ lib/generators/mini_test/mailer/mailer_generator.rb
16
+ lib/generators/mini_test/mailer/templates/mailer_spec.rb
17
+ lib/generators/mini_test/mailer/templates/mailer_test.rb
18
+ lib/generators/mini_test/model/model_generator.rb
19
+ lib/generators/mini_test/model/templates/fixtures.yml
20
+ lib/generators/mini_test/model/templates/model_spec.rb
21
+ lib/generators/mini_test/model/templates/model_test.rb
22
+ lib/generators/mini_test/scaffold/scaffold_generator.rb
23
+ lib/generators/mini_test/scaffold/templates/controller_spec.rb
24
+ lib/generators/mini_test/scaffold/templates/controller_test.rb
19
25
  lib/minitest-rails.rb
20
26
  lib/minitest/rails.rb
21
- lib/minitest/rails/base.rb
22
27
  lib/minitest/rails/controller.rb
23
28
  lib/minitest/rails/helper.rb
29
+ lib/minitest/rails/mailer.rb
24
30
  lib/minitest/rails/model.rb
31
+ lib/minitest/rails/spec.rb
25
32
  lib/minitest/rails/tasks/minitest.rake
26
33
  test/test_controller_generator.rb
27
34
  test/test_helper_generator.rb
28
35
  test/test_install_generator.rb
36
+ test/test_mailer_generator.rb
29
37
  test/test_minitest.rb
30
38
  test/test_model_generator.rb
39
+ test/test_scaffold_generator.rb
data/README.rdoc CHANGED
@@ -16,13 +16,13 @@ Create a new rails app without Test::Unit:
16
16
 
17
17
  rails new MyApp --skip-test-unit
18
18
 
19
- Add `minitest-rails` to the `:test` and `:development` groups in Isolate:
19
+ Add <tt>minitest-rails</tt> to the <tt>:test</tt> and <tt>:development</tt> groups in Isolate:
20
20
 
21
21
  env :development, :test do
22
22
  gem 'minitest-rails'
23
23
  end
24
24
 
25
- Or, for the unenlightened, add `minitest-rails` to the `:test` and `:development` groups in Gemfile:
25
+ Or, for the unenlightened, add <tt>minitest-rails</tt> to the <tt>:test</tt> and <tt>:development</tt> groups in Gemfile:
26
26
 
27
27
  group :test, :development do
28
28
  gem 'minitest-rails'
@@ -30,9 +30,9 @@ Or, for the unenlightened, add `minitest-rails` to the `:test` and `:development
30
30
 
31
31
  Next run the installation generator with the following:
32
32
 
33
- rails generate minitest:install
33
+ rails generate mini_test:install
34
34
 
35
- This will add the `minitest_helper.rb` file to the `test` directory.
35
+ This will add the <tt>minitest_helper.rb</tt> file to the <tt>test</tt> directory.
36
36
 
37
37
  == Usage
38
38
 
@@ -44,8 +44,8 @@ You can generate tests when you use the standard model, controller, scaffold, an
44
44
 
45
45
  Or, you can use the MiniTest generators directly:
46
46
 
47
- rails generate minitest::model User
47
+ rails generate mini_test::model User
48
48
 
49
- And you can specify generating the tests using the MiniTest::Spec DSL on any of the generators by providing the `--spec` option:
49
+ And you can specify generating the tests using the MiniTest::Spec DSL on any of the generators by providing the <tt>--spec</tt> option:
50
50
 
51
51
  rails generate model User --spec
data/Rakefile CHANGED
@@ -18,9 +18,9 @@ Hoe.spec 'minitest-rails' do
18
18
  self.testlib = :minitest
19
19
 
20
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']
21
+ extra_deps << ['railties', '= 3.1.0.rc2']
22
+ extra_deps << ['activesupport', '= 3.1.0.rc2']
23
+ extra_deps << ['actionpack', '= 3.1.0.rc2']
24
24
  end
25
25
 
26
26
  # vim: syntax=ruby
@@ -1,12 +1,10 @@
1
1
  require 'rails/generators/named_base'
2
2
 
3
- # Ugh, Rails pukes on minitest -> MiniTest
4
- # So name this "Minitest" to appease the Rails for now
5
- module Minitest
3
+ module MiniTest
6
4
  module Generators
7
5
  class Base < ::Rails::Generators::NamedBase #:nodoc:
8
6
  def self.source_root
9
- @_minitest_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'minitest', generator_name, 'templates'))
7
+ @_minitest_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'mini_test', generator_name, 'templates'))
10
8
  end
11
9
  end
12
10
  end
@@ -1,6 +1,6 @@
1
- require "generators/minitest"
1
+ require "generators/mini_test"
2
2
 
3
- module Minitest
3
+ module MiniTest
4
4
  module Generators
5
5
  class ControllerGenerator < Base
6
6
  argument :actions, :type => :array, :default => [], :banner => "action action"
@@ -0,0 +1,11 @@
1
+ require "minitest_helper"
2
+
3
+ class <%= class_name %>ControllerTest < MiniTest::Rails::Controller
4
+ before do
5
+ @controller = <%= class_name %>Controller.new
6
+ end
7
+
8
+ it "must be a real test" do
9
+ flunk "Need real tests"
10
+ end
11
+ end
@@ -1,11 +1,11 @@
1
1
  require "minitest_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- class <%= class_name %>ControllerTest < MiniTest::Rails::ControllerTestCase
4
+ class <%= class_name %>ControllerTest < MiniTest::Rails::Controller
5
5
 
6
6
  <% if actions.empty? -%>
7
- def test_truth
8
- assert true
7
+ def test_sanity
8
+ flunk "Need real tests"
9
9
  end
10
10
  <% else -%>
11
11
  <% actions.each do |action| -%>
@@ -1,6 +1,6 @@
1
- require "generators/minitest"
1
+ require "generators/mini_test"
2
2
 
3
- module Minitest
3
+ module MiniTest
4
4
  module Generators
5
5
  class HelperGenerator < Base
6
6
  class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
@@ -0,0 +1,11 @@
1
+ require "minitest_helper"
2
+
3
+ class <%= class_name %>HelperTest < MiniTest::Rails::Helper
4
+ before do
5
+ @helper= <%= class_name %>Helper.new
6
+ end
7
+
8
+ it "must be a real test" do
9
+ flunk "Need real tests"
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require "minitest_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>HelperTest < MiniTest::Rails::Helper
5
+
6
+ def test_sanity
7
+ flunk "Need real tests"
8
+ end
9
+
10
+ end
11
+ <% end -%>
@@ -1,8 +1,8 @@
1
1
  require 'rails/generators'
2
2
 
3
- module Minitest
3
+ module MiniTest
4
4
  module Generators
5
- class InstallGenerator < Rails::Generators::Base
5
+ class InstallGenerator < ::Rails::Generators::Base
6
6
 
7
7
  desc <<DESC
8
8
  Description:
@@ -4,14 +4,15 @@ require "minitest/rails"
4
4
  ENV["RAILS_ENV"] = "test"
5
5
  require File.expand_path('../../config/environment', __FILE__)
6
6
 
7
- class MiniTest::Rails::TestCase
8
-
9
- # Add methods to be used by all tests here...
10
-
11
- end
12
-
13
7
  class MiniTest::Rails::Spec
14
8
 
15
9
  # Add methods to be used by all specs here...
16
10
 
17
- end
11
+ end
12
+
13
+ # Uncomment to support fixtures in Model tests...
14
+ # require "active_record/fixtures"
15
+ class MiniTest::Rails::Model
16
+ # include ActiveRecord::TestFixtures
17
+ # self.fixture_path = File.join(Rails.root, "test", "fixtures")
18
+ end
@@ -0,0 +1,20 @@
1
+ require "generators/mini_test"
2
+
3
+ module MiniTest
4
+ module Generators
5
+ class MailerGenerator < Base
6
+ argument :actions, :type => :array, :default => [], :banner => "method method"
7
+ class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
8
+
9
+ check_class_collision :suffix => "MailerTest"
10
+
11
+ def create_test_files
12
+ if options[:spec]
13
+ template "mailer_spec.rb", "test/mailers/#{file_name}_test.rb"
14
+ else
15
+ template "mailer_test.rb", "test/mailers/#{file_name}_test.rb"
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ require "minitest_helper"
2
+
3
+ class <%= class_name %>Test < MiniTest::Rails::Mailer
4
+ <% actions.each do |action| -%>
5
+ it "<%= action %>" do
6
+ mail = <%= class_name %>.<%= action %>
7
+ mail.subject.must_equal <%= action.to_s.humanize.inspect %>
8
+ mail.to.must_equal ["to@example.org"]
9
+ mail.from.must_equal ["from@example.com"]
10
+ mail.body.encoded.must_match "Hi"
11
+ end
12
+
13
+ <% end -%>
14
+ <% if actions.blank? -%>
15
+ it "must be a real test" do
16
+ flunk "Need real tests"
17
+ end
18
+ <% end -%>
19
+ end
@@ -0,0 +1,21 @@
1
+ require "minitest_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>Test < MiniTest::Rails::Mailer
5
+ <% actions.each do |action| -%>
6
+ def test_<%= action %>
7
+ mail = <%= class_name %>.<%= action %>
8
+ assert_equal <%= action.to_s.humanize.inspect %>, mail.subject
9
+ assert_equal ["to@example.org"], mail.to
10
+ assert_equal ["from@example.com"], mail.from
11
+ assert_match "Hi", mail.body.encoded
12
+ end
13
+
14
+ <% end -%>
15
+ <% if actions.blank? -%>
16
+ def test_sanity
17
+ flunk "Need real tests"
18
+ end
19
+ <% end -%>
20
+ end
21
+ <% end -%>
@@ -1,6 +1,6 @@
1
- require "generators/minitest"
1
+ require "generators/mini_test"
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"
@@ -9,13 +9,18 @@ module Minitest
9
9
 
10
10
  check_class_collision :suffix => "Test"
11
11
 
12
- def create_test_files
12
+ def create_test_file
13
13
  if options[:spec]
14
14
  template "model_spec.rb", "test/models/#{file_name}_test.rb"
15
15
  else
16
16
  template "model_test.rb", "test/models/#{file_name}_test.rb"
17
17
  end
18
- if options[:fixture]
18
+ end
19
+
20
+ hook_for :fixture_replacement
21
+
22
+ def create_fixture_file
23
+ if options[:fixture] && options[:fixture_replacement].nil?
19
24
  template "fixtures.yml", "test/fixtures/#{plural_file_name}.yml"
20
25
  end
21
26
  end
@@ -1,6 +1,6 @@
1
1
  require "minitest_helper"
2
2
 
3
- describe <%= class_name %> do
3
+ class <%= class_name %>Test < MiniTest::Rails::Model
4
4
  before do
5
5
  @<%= file_name %> = <%= class_name %>.new
6
6
  end
@@ -9,6 +9,10 @@ describe <%= class_name %> do
9
9
  @<%= file_name %>.valid?.must_equal true
10
10
  end
11
11
 
12
+ it "must be a real test" do
13
+ flunk "Need real tests"
14
+ end
15
+
12
16
  # describe "when doing its thing" do
13
17
  # it "must be interesting" do
14
18
  # @<%= file_name %>.blow_minds!
@@ -0,0 +1,11 @@
1
+ require "minitest_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>Test < MiniTest::Rails::Model
5
+
6
+ def test_sanity
7
+ flunk "Need real tests"
8
+ end
9
+
10
+ end
11
+ <% end -%>
@@ -0,0 +1,22 @@
1
+ require "generators/mini_test"
2
+ require "rails/generators/resource_helpers"
3
+
4
+ module MiniTest
5
+ module Generators
6
+ class ScaffoldGenerator < Base
7
+ include ::Rails::Generators::ResourceHelpers
8
+ argument :actions, :type => :array, :default => [], :banner => "action action"
9
+ class_option :spec, :type => :boolean, :default => false, :desc => "Use MiniTest::Spec DSL"
10
+
11
+ check_class_collision :suffix => "ControllerTest"
12
+
13
+ def create_test_files
14
+ if options[:spec]
15
+ template "controller_spec.rb", "test/controllers/#{file_name}_controller_test.rb"
16
+ else
17
+ template "controller_test.rb", "test/controllers/#{file_name}_controller_test.rb"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,51 @@
1
+ require "minitest_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>ControllerTest < MiniTest::Rails::Controller
5
+ setup do
6
+ @<%= singular_table_name %> = <%= table_name %>(:one)
7
+ end
8
+
9
+ it "must get index" do
10
+ get :index
11
+ assert_response :success
12
+ assert_not_nil assigns(:<%= table_name %>)
13
+ end
14
+
15
+ it "must get new" do
16
+ get :new
17
+ assert_response :success
18
+ end
19
+
20
+ it "must create <%= singular_table_name %>" do
21
+ assert_difference('<%= class_name %>.count') do
22
+ post :create, <%= key_value singular_table_name, "@#{singular_table_name}.attributes" %>
23
+ end
24
+
25
+ assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
26
+ end
27
+
28
+ it "must show <%= singular_table_name %>" do
29
+ get :show, <%= key_value :id, "@#{singular_table_name}.to_param" %>
30
+ assert_response :success
31
+ end
32
+
33
+ it "must get edit" do
34
+ get :edit, <%= key_value :id, "@#{singular_table_name}.to_param" %>
35
+ assert_response :success
36
+ end
37
+
38
+ it "must update <%= singular_table_name %>" do
39
+ put :update, <%= key_value :id, "@#{singular_table_name}.to_param" %>, <%= key_value singular_table_name, "@#{singular_table_name}.attributes" %>
40
+ assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
41
+ end
42
+
43
+ it "must destroy <%= singular_table_name %>" do
44
+ assert_difference('<%= class_name %>.count', -1) do
45
+ delete :destroy, <%= key_value :id, "@#{singular_table_name}.to_param" %>
46
+ end
47
+
48
+ assert_redirected_to <%= index_helper %>_path
49
+ end
50
+ end
51
+ <% end -%>
@@ -0,0 +1,51 @@
1
+ require "minitest_helper"
2
+
3
+ <% module_namespacing do -%>
4
+ class <%= class_name %>ControllerTest < MiniTest::Rails::Controller
5
+ setup do
6
+ @<%= singular_table_name %> = <%= table_name %>(:one)
7
+ end
8
+
9
+ def test_index
10
+ get :index
11
+ assert_response :success
12
+ assert_not_nil assigns(:<%= table_name %>)
13
+ end
14
+
15
+ def test_new
16
+ get :new
17
+ assert_response :success
18
+ end
19
+
20
+ def test_create
21
+ assert_difference('<%= class_name %>.count') do
22
+ post :create, <%= key_value singular_table_name, "@#{singular_table_name}.attributes" %>
23
+ end
24
+
25
+ assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
26
+ end
27
+
28
+ def test_show
29
+ get :show, <%= key_value :id, "@#{singular_table_name}.to_param" %>
30
+ assert_response :success
31
+ end
32
+
33
+ def test_edit
34
+ get :edit, <%= key_value :id, "@#{singular_table_name}.to_param" %>
35
+ assert_response :success
36
+ end
37
+
38
+ def test_update
39
+ put :update, <%= key_value :id, "@#{singular_table_name}.to_param" %>, <%= key_value singular_table_name, "@#{singular_table_name}.attributes" %>
40
+ assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
41
+ end
42
+
43
+ def test_destroy
44
+ assert_difference('<%= class_name %>.count', -1) do
45
+ delete :destroy, <%= key_value :id, "@#{singular_table_name}.to_param" %>
46
+ end
47
+
48
+ assert_redirected_to <%= index_helper %>_path
49
+ end
50
+ end
51
+ <% end -%>
@@ -2,11 +2,11 @@ require "rails"
2
2
 
3
3
  module MiniTest
4
4
  module Rails
5
- VERSION = "0.0.2"
5
+ VERSION = "0.0.4"
6
6
  class Railtie < ::Rails::Railtie
7
- config.app_generators.integration_tool :minitest
8
- config.app_generators.test_framework :minitest, :fixture => true
9
- config.app_generators.fallbacks[:minitest] = :test_unit
7
+ config.app_generators.integration_tool :mini_test
8
+ config.app_generators.test_framework :mini_test, :fixture => false
9
+ config.app_generators.fallbacks[:mini_test] = :test_unit
10
10
 
11
11
  rake_tasks do
12
12
  load "minitest/rails/tasks/minitest.rake"
@@ -1,8 +1,4 @@
1
1
  require "minitest/rails/model"
2
- require "minitest/rails/helper"
3
2
  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)
3
+ require "minitest/rails/helper"
4
+ require "minitest/rails/mailer"
@@ -1,13 +1,10 @@
1
- require "minitest/rails/base"
1
+ require "minitest/rails/spec"
2
2
  # require "action_controller"
3
3
 
4
4
  module MiniTest
5
5
  module Rails
6
- class ControllerTestCase < TestCase
6
+ class Controller < Spec
7
7
  # include ActionController::TestCase::Behavior
8
8
  end
9
-
10
- class ControllerSpec < Spec
11
- end
12
9
  end
13
- end
10
+ end
@@ -1,11 +1,8 @@
1
- require "minitest/rails/base"
1
+ require "minitest/rails/spec"
2
2
 
3
3
  module MiniTest
4
4
  module Rails
5
- class HelperTestCase < TestCase
6
- end
7
-
8
- class HelperSpec < Spec
5
+ class Helper < Spec
9
6
  end
10
7
  end
11
8
  end
@@ -0,0 +1,8 @@
1
+ require "minitest/rails/spec"
2
+
3
+ module MiniTest
4
+ module Rails
5
+ class Mailer < Spec
6
+ end
7
+ end
8
+ end
@@ -1,17 +1,8 @@
1
- require "minitest/rails/base"
2
- # require "active_support/testing/setup_and_teardown"
3
- # require "active_record/fixtures"
1
+ require "minitest/rails/spec"
4
2
 
5
3
  module MiniTest
6
4
  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
5
+ class Model < Spec
15
6
  end
16
7
  end
17
8
  end
@@ -4,10 +4,8 @@ require "minitest/mock"
4
4
 
5
5
  module MiniTest
6
6
  module Rails
7
- class TestCase < ::MiniTest::Unit::TestCase
8
- end
9
7
  class Spec < ::MiniTest::Spec
10
- # alias :method_name :__name__ if defined? :__name__
8
+ alias :method_name :__name__ if defined? :__name__
11
9
  end
12
10
  end
13
11
  end
@@ -1,6 +1,6 @@
1
1
  require 'rake/testtask'
2
2
 
3
- MINITEST_TASKS = %w(models controllers views helpers integration)
3
+ MINITEST_TASKS = %w(models controllers views helpers mailers integration)
4
4
 
5
5
  desc 'Runs all tests'
6
6
  task :test do
@@ -4,7 +4,7 @@ require "minitest-rails"
4
4
  require "rails"
5
5
  require "rails/generators"
6
6
 
7
- require "generators/minitest/controller/controller_generator"
7
+ require "generators/mini_test/controller/controller_generator"
8
8
 
9
9
  require "fileutils"
10
10
 
@@ -13,12 +13,13 @@ class TestControllerGenerator < MiniTest::Unit::TestCase
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
18
  assert_match(/create test\/controllers\/user_controller_test.rb/m, text)
19
19
  assert File.exists? "test/controllers/user_controller_test.rb"
20
20
  contents = open("test/controllers/user_controller_test.rb").read
21
- assert_match(/class UserControllerTest < MiniTest::Rails::ControllerTestCase/m, contents)
21
+ assert_match(/class UserControllerTest < MiniTest::Rails::Controller/m, contents)
22
+ assert_match(/def test_sanity/m, contents)
22
23
  ensure
23
24
  # TODO: Don"t write the files
24
25
  # I agree, it would be better to mock the file getting written
@@ -27,12 +28,13 @@ class TestControllerGenerator < MiniTest::Unit::TestCase
27
28
 
28
29
  def test_controller_generator_spec
29
30
  text = capture(:stdout) do
30
- Minitest::Generators::ControllerGenerator.start ["user", "--spec"]
31
+ MiniTest::Generators::ControllerGenerator.start ["user", "--spec"]
31
32
  end
32
33
  assert_match(/create test\/controllers\/user_controller_test.rb/m, text)
33
34
  assert File.exists? "test/controllers/user_controller_test.rb"
34
35
  contents = open("test/controllers/user_controller_test.rb").read
35
- assert_match(/describe UserController do/m, contents)
36
+ assert_match(/class UserControllerTest < MiniTest::Rails::Controller/m, contents)
37
+ assert_match(/it "must be a real test"/m, contents)
36
38
  ensure
37
39
  FileUtils.rm_r "test/controllers"
38
40
  end
@@ -4,7 +4,7 @@ require "minitest-rails"
4
4
  require "rails"
5
5
  require "rails/generators"
6
6
 
7
- require "generators/minitest/helper/helper_generator"
7
+ require "generators/mini_test/helper/helper_generator"
8
8
 
9
9
  require "fileutils"
10
10
 
@@ -13,12 +13,12 @@ class TestHelperGenerator < MiniTest::Unit::TestCase
13
13
 
14
14
  def test_helper_generator
15
15
  text = capture(:stdout) do
16
- Minitest::Generators::HelperGenerator.start ["user"]
16
+ MiniTest::Generators::HelperGenerator.start ["user"]
17
17
  end
18
18
  assert_match(/create test\/helpers\/user_helper_test.rb/m, text)
19
19
  assert File.exists? "test/helpers/user_helper_test.rb"
20
20
  contents = open("test/helpers/user_helper_test.rb").read
21
- assert_match(/class UserHelperTest < MiniTest::Rails::HelperTestCase/m, contents)
21
+ assert_match(/class UserHelperTest < MiniTest::Rails::Helper/m, contents)
22
22
  ensure
23
23
  # TODO: Don"t write the files
24
24
  # I agree, it would be better to mock the file getting written
@@ -27,12 +27,12 @@ class TestHelperGenerator < MiniTest::Unit::TestCase
27
27
 
28
28
  def test_helper_generator_spec
29
29
  text = capture(:stdout) do
30
- Minitest::Generators::HelperGenerator.start ["user", "--spec"]
30
+ MiniTest::Generators::HelperGenerator.start ["user", "--spec"]
31
31
  end
32
32
  assert_match(/create test\/helpers\/user_helper_test.rb/m, text)
33
33
  assert File.exists? "test/helpers/user_helper_test.rb"
34
34
  contents = open("test/helpers/user_helper_test.rb").read
35
- assert_match(/describe UserHelper do/m, contents)
35
+ assert_match(/class UserHelperTest < MiniTest::Rails::Helper/m, contents)
36
36
  ensure
37
37
  FileUtils.rm_r "test/helpers"
38
38
  end
@@ -4,7 +4,7 @@ require "minitest-rails"
4
4
  require "rails"
5
5
  require "rails/generators"
6
6
 
7
- require "generators/minitest/install/install_generator"
7
+ require "generators/mini_test/install/install_generator"
8
8
 
9
9
  require "fileutils"
10
10
 
@@ -13,12 +13,12 @@ class TestInstallGenerator < MiniTest::Unit::TestCase
13
13
 
14
14
  def test_install_generator
15
15
  text = capture(:stdout) do
16
- Minitest::Generators::InstallGenerator.start
16
+ MiniTest::Generators::InstallGenerator.start
17
17
  end
18
18
  assert_match(/create test\/minitest_helper.rb/m, text)
19
19
  assert File.exists? "test/minitest_helper.rb"
20
20
  contents = open("test/minitest_helper.rb").read
21
- assert_match(/class MiniTest::Rails::TestCase/m, contents)
21
+ assert_match(/class MiniTest::Rails::Spec/m, contents)
22
22
  ensure
23
23
  # TODO: Don"t write the files
24
24
  # I agree, it would be better to mock the file getting written
@@ -0,0 +1,39 @@
1
+ require "minitest/autorun"
2
+ require "minitest-rails"
3
+
4
+ require "rails"
5
+ require "rails/generators"
6
+
7
+ require "generators/mini_test/mailer/mailer_generator"
8
+
9
+ require "fileutils"
10
+
11
+ class TestMailerGenerator < MiniTest::Unit::TestCase
12
+ Rails::Generators.no_color!
13
+
14
+ def test_mailer_generator
15
+ text = capture(:stdout) do
16
+ MiniTest::Generators::MailerGenerator.start ["notification"]
17
+ end
18
+ assert_match(/create test\/mailers\/notification_test.rb/m, text)
19
+ assert File.exists? "test/mailers/notification_test.rb"
20
+ contents = open("test/mailers/notification_test.rb").read
21
+ assert_match(/class NotificationTest < MiniTest::Rails::Mailer/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/mailers"
26
+ end
27
+
28
+ def test_mailer_generator_spec
29
+ text = capture(:stdout) do
30
+ MiniTest::Generators::MailerGenerator.start ["notification", "--spec"]
31
+ end
32
+ assert_match(/create test\/mailers\/notification_test.rb/m, text)
33
+ assert File.exists? "test/mailers/notification_test.rb"
34
+ contents = open("test/mailers/notification_test.rb").read
35
+ assert_match(/class NotificationTest < MiniTest::Rails::Mailer/m, contents)
36
+ ensure
37
+ FileUtils.rm_r "test/mailers"
38
+ end
39
+ end
@@ -4,7 +4,7 @@ require "minitest-rails"
4
4
  require "rails"
5
5
  require "rails/generators"
6
6
 
7
- require "generators/minitest/model/model_generator"
7
+ require "generators/mini_test/model/model_generator"
8
8
 
9
9
  require "fileutils"
10
10
 
@@ -13,12 +13,12 @@ class TestModelGenerator < MiniTest::Unit::TestCase
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
18
  assert_match(/create test\/models\/user_test.rb/m, text)
19
19
  assert File.exists? "test/models/user_test.rb"
20
20
  contents = open("test/models/user_test.rb").read
21
- assert_match(/class UserTest < MiniTest::Rails::ModelTestCase/m, contents)
21
+ assert_match(/class UserTest < MiniTest::Rails::Model/m, contents)
22
22
  ensure
23
23
  # TODO: Don"t write the files
24
24
  # I agree, it would be better to mock the file getting written
@@ -27,12 +27,12 @@ class TestModelGenerator < MiniTest::Unit::TestCase
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
32
  assert_match(/create test\/models\/user_test.rb/m, text)
33
33
  assert File.exists? "test/models/user_test.rb"
34
34
  contents = open("test/models/user_test.rb").read
35
- assert_match(/describe User do/m, contents)
35
+ assert_match(/class UserTest < MiniTest::Rails::Model/m, contents)
36
36
  ensure
37
37
  FileUtils.rm_r "test/models"
38
38
  end
@@ -0,0 +1,41 @@
1
+ require "minitest/autorun"
2
+ require "minitest-rails"
3
+
4
+ require "rails"
5
+ require "rails/generators"
6
+
7
+ require "generators/mini_test/scaffold/scaffold_generator"
8
+
9
+ require "fileutils"
10
+
11
+ class TestScaffoldGenerator < MiniTest::Unit::TestCase
12
+ Rails::Generators.no_color!
13
+
14
+ def test_scaffold_generator
15
+ text = capture(:stdout) do
16
+ MiniTest::Generators::ScaffoldGenerator.start ["user"]
17
+ end
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::Controller/m, contents)
22
+ assert_match(/def test_index/m, contents)
23
+ ensure
24
+ # TODO: Don"t write the files
25
+ # I agree, it would be better to mock the file getting written
26
+ FileUtils.rm_r "test/controllers"
27
+ end
28
+
29
+ def test_scaffold_generator_spec
30
+ text = capture(:stdout) do
31
+ MiniTest::Generators::ScaffoldGenerator.start ["user", "--spec"]
32
+ end
33
+ assert_match(/create test\/controllers\/user_controller_test.rb/m, text)
34
+ assert File.exists? "test/controllers/user_controller_test.rb"
35
+ contents = open("test/controllers/user_controller_test.rb").read
36
+ assert_match(/class UserControllerTest < MiniTest::Rails::Controller/m, contents)
37
+ assert_match(/it "must get index"/m, contents)
38
+ ensure
39
+ FileUtils.rm_r "test/controllers"
40
+ end
41
+ 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.2
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mike Moore
@@ -31,7 +31,7 @@ cert_chain:
31
31
  sgxAiQ==
32
32
  -----END CERTIFICATE-----
33
33
 
34
- date: 2011-06-03 00:00:00 Z
34
+ date: 2011-06-08 00:00:00 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitest
@@ -52,7 +52,7 @@ dependencies:
52
52
  requirements:
53
53
  - - "="
54
54
  - !ruby/object:Gem::Version
55
- version: 3.1.0.rc1
55
+ version: 3.1.0.rc2
56
56
  type: :runtime
57
57
  version_requirements: *id002
58
58
  - !ruby/object:Gem::Dependency
@@ -63,7 +63,7 @@ dependencies:
63
63
  requirements:
64
64
  - - "="
65
65
  - !ruby/object:Gem::Version
66
- version: 3.1.0.rc1
66
+ version: 3.1.0.rc2
67
67
  type: :runtime
68
68
  version_requirements: *id003
69
69
  - !ruby/object:Gem::Dependency
@@ -74,7 +74,7 @@ dependencies:
74
74
  requirements:
75
75
  - - "="
76
76
  - !ruby/object:Gem::Version
77
- version: 3.1.0.rc1
77
+ version: 3.1.0.rc2
78
78
  type: :runtime
79
79
  version_requirements: *id004
80
80
  - !ruby/object:Gem::Dependency
@@ -103,31 +103,40 @@ files:
103
103
  - Manifest.txt
104
104
  - README.rdoc
105
105
  - Rakefile
106
- - lib/generators/minitest.rb
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
110
- - lib/generators/minitest/helper/helper_generator.rb
111
- - lib/generators/minitest/helper/templates/helper_spec.rb
112
- - lib/generators/minitest/helper/templates/helper_test.rb
113
- - lib/generators/minitest/install/install_generator.rb
114
- - lib/generators/minitest/install/templates/test/minitest_helper.rb
115
- - lib/generators/minitest/model/model_generator.rb
116
- - lib/generators/minitest/model/templates/fixtures.yml
117
- - lib/generators/minitest/model/templates/model_spec.rb
118
- - lib/generators/minitest/model/templates/model_test.rb
106
+ - lib/generators/mini_test.rb
107
+ - lib/generators/mini_test/controller/controller_generator.rb
108
+ - lib/generators/mini_test/controller/templates/controller_spec.rb
109
+ - lib/generators/mini_test/controller/templates/controller_test.rb
110
+ - lib/generators/mini_test/helper/helper_generator.rb
111
+ - lib/generators/mini_test/helper/templates/helper_spec.rb
112
+ - lib/generators/mini_test/helper/templates/helper_test.rb
113
+ - lib/generators/mini_test/install/install_generator.rb
114
+ - lib/generators/mini_test/install/templates/test/minitest_helper.rb
115
+ - lib/generators/mini_test/mailer/mailer_generator.rb
116
+ - lib/generators/mini_test/mailer/templates/mailer_spec.rb
117
+ - lib/generators/mini_test/mailer/templates/mailer_test.rb
118
+ - lib/generators/mini_test/model/model_generator.rb
119
+ - lib/generators/mini_test/model/templates/fixtures.yml
120
+ - lib/generators/mini_test/model/templates/model_spec.rb
121
+ - lib/generators/mini_test/model/templates/model_test.rb
122
+ - lib/generators/mini_test/scaffold/scaffold_generator.rb
123
+ - lib/generators/mini_test/scaffold/templates/controller_spec.rb
124
+ - lib/generators/mini_test/scaffold/templates/controller_test.rb
119
125
  - lib/minitest-rails.rb
120
126
  - lib/minitest/rails.rb
121
- - lib/minitest/rails/base.rb
122
127
  - lib/minitest/rails/controller.rb
123
128
  - lib/minitest/rails/helper.rb
129
+ - lib/minitest/rails/mailer.rb
124
130
  - lib/minitest/rails/model.rb
131
+ - lib/minitest/rails/spec.rb
125
132
  - lib/minitest/rails/tasks/minitest.rake
126
133
  - test/test_controller_generator.rb
127
134
  - test/test_helper_generator.rb
128
135
  - test/test_install_generator.rb
136
+ - test/test_mailer_generator.rb
129
137
  - test/test_minitest.rb
130
138
  - test/test_model_generator.rb
139
+ - test/test_scaffold_generator.rb
131
140
  - .gemtest
132
141
  homepage: http://blowmage.com/minitest-rails
133
142
  licenses: []
@@ -161,5 +170,7 @@ test_files:
161
170
  - test/test_controller_generator.rb
162
171
  - test/test_helper_generator.rb
163
172
  - test/test_install_generator.rb
173
+ - test/test_mailer_generator.rb
164
174
  - test/test_minitest.rb
165
175
  - test/test_model_generator.rb
176
+ - test/test_scaffold_generator.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,7 +0,0 @@
1
- require "minitest_helper"
2
-
3
- describe <%= class_name %>Controller do
4
- before do
5
- @controller = <%= class_name %>Controller.new
6
- end
7
- end
@@ -1,7 +0,0 @@
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,11 +0,0 @@
1
- require "minitest_helper"
2
-
3
- <% module_namespacing do -%>
4
- class <%= class_name %>HelperTest < MiniTest::Rails::HelperTestCase
5
-
6
- def test_truth
7
- assert true
8
- end
9
-
10
- end
11
- <% end -%>
@@ -1,11 +0,0 @@
1
- require "minitest_helper"
2
-
3
- <% module_namespacing do -%>
4
- class <%= class_name %>Test < MiniTest::Rails::ModelTestCase
5
-
6
- def test_truth
7
- assert true
8
- end
9
-
10
- end
11
- <% end -%>