minitest-rails 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -9,18 +9,16 @@ Hoe.plugins.delete :rubyforge
9
9
  Hoe.spec 'minitest-rails' do
10
10
  developer 'Mike Moore', 'mike@blowmage.com'
11
11
 
12
- self.summary = 'MiniTest integration for Rails 3.1.'
13
- self.description = 'Adds MiniTest as the default testing library in Rails.'
12
+ self.summary = 'MiniTest integration for Rails 3.'
13
+ self.description = 'Adds MiniTest as the default testing library in Rails 3.'
14
14
  self.url = 'http://blowmage.com/minitest-rails'
15
15
 
16
16
  self.history_file = "CHANGELOG.rdoc"
17
17
  self.readme_file = "README.rdoc"
18
18
  self.testlib = :minitest
19
19
 
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']
20
+ extra_deps << ['minitest', '~> 2.11']
21
+ extra_deps << ['rails', '~> 3.1']
24
22
  end
25
23
 
26
24
  # vim: syntax=ruby
@@ -1,6 +1,11 @@
1
1
  require "minitest_helper"
2
2
 
3
- class <%= class_name %>ControllerTest < MiniTest::Rails::Controller
3
+ describe <%= class_name %>Controller do
4
+
5
+ subject { <%= class_name %>Controller }
6
+
7
+ # fixtures :all
8
+
4
9
  before do
5
10
  @controller = <%= class_name %>Controller.new
6
11
  end
@@ -8,4 +13,5 @@ class <%= class_name %>ControllerTest < MiniTest::Rails::Controller
8
13
  it "must be a real test" do
9
14
  flunk "Need real tests"
10
15
  end
16
+
11
17
  end
@@ -1,11 +1,9 @@
1
1
  require "minitest_helper"
2
2
 
3
- class <%= class_name %>HelperTest < MiniTest::Rails::Helper
4
- before do
5
- @helper= <%= class_name %>Helper.new
6
- end
3
+ describe <%= class_name %>Helper do
7
4
 
8
5
  it "must be a real test" do
9
6
  flunk "Need real tests"
10
7
  end
8
+
11
9
  end
@@ -1,18 +1,61 @@
1
1
  require "minitest/autorun"
2
2
  require "minitest/rails"
3
3
 
4
+ # Uncomment if you want awesome colorful output
5
+ # require "minitest/pride"
6
+
4
7
  ENV["RAILS_ENV"] = "test"
5
8
  require File.expand_path('../../config/environment', __FILE__)
6
9
 
7
10
  class MiniTest::Rails::Spec
11
+ # Uncomment if you want to support fixtures for all specs
12
+ # or
13
+ # place within spec class you want to support fixtures for
14
+ # include MiniTest::Rails::Fixtures
8
15
 
9
16
  # Add methods to be used by all specs here...
10
17
 
11
18
  end
12
19
 
13
- # Uncomment to support fixtures in Model tests...
14
- # require "active_record/fixtures"
15
20
  class MiniTest::Rails::Model
16
- # include ActiveRecord::TestFixtures
17
- # self.fixture_path = File.join(Rails.root, "test", "fixtures")
21
+
22
+ # Add methods to be used by model specs here...
23
+
24
+ end
25
+
26
+ MiniTest::Spec.register_spec_type(MiniTest::Rails::Model) do |desc|
27
+ desc.superclass == ActiveRecord::Base
28
+ end
29
+
30
+ class MiniTest::Rails::Controller
31
+ include ActionController::TestCase::Behavior
32
+ before do
33
+ @request = ActionController::TestRequest.new
34
+ @response = ActionController::TestResponse.new
35
+ @routes = Rails.application.routes
36
+ end
37
+
38
+ # Add methods to be used by controller specs here...
39
+
40
+ end
41
+
42
+ MiniTest::Spec.register_spec_type(/Controller$/, MiniTest::Rails::Controller)
43
+
44
+ class MiniTest::Rails::Helper
45
+
46
+ # Add methods to be used by helper specs here...
47
+
18
48
  end
49
+
50
+ MiniTest::Spec.register_spec_type(/Helper$/, MiniTest::Rails::Helper)
51
+
52
+ class MiniTest::Rails::Mailer
53
+
54
+ # Add methods to be used by mailer specs here...
55
+
56
+ end
57
+
58
+ MiniTest::Spec.register_spec_type(MiniTest::Rails::Mailer) do |desc|
59
+ desc.superclass == ActionMailer::Base
60
+ end
61
+
@@ -1,6 +1,7 @@
1
1
  require "minitest_helper"
2
2
 
3
- class <%= class_name %>Test < MiniTest::Rails::Mailer
3
+ describe <%= class_name %> do
4
+
4
5
  <% actions.each do |action| -%>
5
6
  it "<%= action %>" do
6
7
  mail = <%= class_name %>.<%= action %>
@@ -9,11 +10,11 @@ class <%= class_name %>Test < MiniTest::Rails::Mailer
9
10
  mail.from.must_equal ["from@example.com"]
10
11
  mail.body.encoded.must_match "Hi"
11
12
  end
12
-
13
13
  <% end -%>
14
14
  <% if actions.blank? -%>
15
15
  it "must be a real test" do
16
16
  flunk "Need real tests"
17
17
  end
18
18
  <% end -%>
19
+
19
20
  end
@@ -1,4 +1,5 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html
1
+ # Read about fixtures at
2
+ # http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
3
 
3
4
  <% unless attributes.empty? -%>
4
5
  one:
@@ -1,6 +1,11 @@
1
1
  require "minitest_helper"
2
2
 
3
- class <%= class_name %>Test < MiniTest::Rails::Model
3
+ describe <%= class_name %> do
4
+
5
+ subject { <%= class_name %>.new }
6
+
7
+ # fixtures :all
8
+
4
9
  before do
5
10
  @<%= file_name %> = <%= class_name %>.new
6
11
  end
@@ -19,4 +24,5 @@ class <%= class_name %>Test < MiniTest::Rails::Model
19
24
  # @<%= file_name %>.interesting?.must_equal true
20
25
  # end
21
26
  # end
22
- end
27
+
28
+ end
@@ -1,8 +1,13 @@
1
1
  require "minitest_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
- class <%= class_name %>ControllerTest < MiniTest::Rails::Controller
5
- setup do
4
+ describe <%= class_name %>Controller do
5
+
6
+ subject { <%= class_name %>Controller }
7
+
8
+ # fixtures :all
9
+
10
+ before do
6
11
  @<%= singular_table_name %> = <%= table_name %>(:one)
7
12
  end
8
13
 
@@ -47,5 +52,6 @@ class <%= class_name %>ControllerTest < MiniTest::Rails::Controller
47
52
 
48
53
  assert_redirected_to <%= index_helper %>_path
49
54
  end
55
+
50
56
  end
51
57
  <% end -%>
@@ -2,7 +2,7 @@ require "minitest_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= class_name %>ControllerTest < MiniTest::Rails::Controller
5
- setup do
5
+ before do
6
6
  @<%= singular_table_name %> = <%= table_name %>(:one)
7
7
  end
8
8
 
@@ -1,8 +1,9 @@
1
1
  require "rails"
2
+ require "minitest/unit"
2
3
 
3
4
  module MiniTest
4
5
  module Rails
5
- VERSION = "0.0.5"
6
+ VERSION = "0.0.6"
6
7
  class Railtie < ::Rails::Railtie
7
8
  # config.app_generators.integration_tool :mini_test
8
9
  config.app_generators.test_framework :mini_test
@@ -2,3 +2,4 @@ require "minitest/rails/model"
2
2
  require "minitest/rails/controller"
3
3
  require "minitest/rails/helper"
4
4
  require "minitest/rails/mailer"
5
+ require "minitest/rails/fixtures"
@@ -1,10 +1,15 @@
1
1
  require "minitest/rails/spec"
2
- # require "action_controller"
2
+ require "active_support/test_case"
3
+ require "action_controller/test_case"
3
4
 
4
5
  module MiniTest
5
6
  module Rails
6
7
  class Controller < Spec
7
- # include ActionController::TestCase::Behavior
8
+ include ActiveSupport::Testing::SetupAndTeardown
9
+ include ActionController::TestCase::Behavior
10
+ before do
11
+ @routes = Rails.application.routes
12
+ end
8
13
  end
9
14
  end
10
15
  end
@@ -6,6 +6,9 @@ module MiniTest
6
6
  module Rails
7
7
  class Spec < ::MiniTest::Spec
8
8
  alias :method_name :__name__ if defined? :__name__
9
+ class << self
10
+ alias :context :describe
11
+ end
9
12
  end
10
13
  end
11
14
  end
@@ -33,7 +33,10 @@ class TestControllerGenerator < MiniTest::Unit::TestCase
33
33
  assert_match(/create test\/controllers\/user_controller_test.rb/m, text)
34
34
  assert File.exists? "test/controllers/user_controller_test.rb"
35
35
  contents = open("test/controllers/user_controller_test.rb").read
36
- assert_match(/class UserControllerTest < MiniTest::Rails::Controller/m, contents)
36
+ assert_match(/describe UserController do/m, contents)
37
+ assert_match(/subject \{ UserController \}/m, contents)
38
+ assert_match(/# fixtures :all/m, contents)
39
+ assert_match(/@controller = UserController.new/m, contents)
37
40
  assert_match(/it "must be a real test"/m, contents)
38
41
  ensure
39
42
  FileUtils.rm_r "test/controllers"
@@ -32,7 +32,7 @@ class TestHelperGenerator < MiniTest::Unit::TestCase
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(/class UserHelperTest < MiniTest::Rails::Helper/m, contents)
35
+ assert_match(/describe UserHelper do/m, contents)
36
36
  ensure
37
37
  FileUtils.rm_r "test/helpers"
38
38
  end
@@ -19,6 +19,15 @@ class TestInstallGenerator < MiniTest::Unit::TestCase
19
19
  assert File.exists? "test/minitest_helper.rb"
20
20
  contents = open("test/minitest_helper.rb").read
21
21
  assert_match(/class MiniTest::Rails::Spec/m, contents)
22
+ assert_match(/# include MiniTest::Rails::Fixtures/m, contents)
23
+ assert_match(/class MiniTest::Rails::Model/m, contents)
24
+ assert_match(/MiniTest::Spec.register_spec_type\(MiniTest::Rails::Model\) do/m, contents)
25
+ assert_match(/class MiniTest::Rails::Controller/m, contents)
26
+ assert_match(/MiniTest::Spec.register_spec_type\(\/Controller\$\/, MiniTest::Rails::Controller\)/m, contents)
27
+ assert_match(/class MiniTest::Rails::Helper/m, contents)
28
+ assert_match(/MiniTest::Spec.register_spec_type\(\/Helper\$\/, MiniTest::Rails::Helper\)/m, contents)
29
+ assert_match(/class MiniTest::Rails::Mailer/m, contents)
30
+ assert_match(/MiniTest::Spec.register_spec_type\(MiniTest::Rails::Mailer\) do/m, contents)
22
31
  ensure
23
32
  # TODO: Don"t write the files
24
33
  # I agree, it would be better to mock the file getting written
@@ -27,12 +27,13 @@ class TestMailerGenerator < MiniTest::Unit::TestCase
27
27
 
28
28
  def test_mailer_generator_spec
29
29
  text = capture(:stdout) do
30
- MiniTest::Generators::MailerGenerator.start ["notification", "--spec"]
30
+ MiniTest::Generators::MailerGenerator.start ["notification", "welcome", "--spec"]
31
31
  end
32
32
  assert_match(/create test\/mailers\/notification_test.rb/m, text)
33
33
  assert File.exists? "test/mailers/notification_test.rb"
34
34
  contents = open("test/mailers/notification_test.rb").read
35
- assert_match(/class NotificationTest < MiniTest::Rails::Mailer/m, contents)
35
+ assert_match(/describe Notification do/m, contents)
36
+ assert_match(/it "welcome" do/m, contents)
36
37
  ensure
37
38
  FileUtils.rm_r "test/mailers"
38
39
  end
@@ -32,7 +32,9 @@ class TestModelGenerator < MiniTest::Unit::TestCase
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(/class UserTest < MiniTest::Rails::Model/m, contents)
35
+ assert_match(/describe User do/m, contents)
36
+ assert_match(/subject \{ User.new \}/, contents)
37
+ assert_match(/# fixtures :all/, contents)
36
38
  ensure
37
39
  FileUtils.rm_r "test/models"
38
40
  end
@@ -33,7 +33,8 @@ class TestScaffoldGenerator < MiniTest::Unit::TestCase
33
33
  assert_match(/create test\/controllers\/user_controller_test.rb/m, text)
34
34
  assert File.exists? "test/controllers/user_controller_test.rb"
35
35
  contents = open("test/controllers/user_controller_test.rb").read
36
- assert_match(/class UserControllerTest < MiniTest::Rails::Controller/m, contents)
36
+ assert_match(/describe UserController do/m, contents)
37
+ assert_match(/subject \{ UserController \}/m, contents)
37
38
  assert_match(/it "must get index"/m, contents)
38
39
  ensure
39
40
  FileUtils.rm_r "test/controllers"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,71 +9,61 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-22 00:00:00.000000000 -06:00
13
- default_executable:
12
+ date: 2012-03-14 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: minitest
17
- requirement: &2156686680 !ruby/object:Gem::Requirement
16
+ requirement: &70095363735960 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ~>
21
20
  - !ruby/object:Gem::Version
22
- version: '2.2'
21
+ version: '2.11'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *2156686680
24
+ version_requirements: *70095363735960
26
25
  - !ruby/object:Gem::Dependency
27
- name: railties
28
- requirement: &2156686020 !ruby/object:Gem::Requirement
26
+ name: rails
27
+ requirement: &70095363735520 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ~>
32
31
  - !ruby/object:Gem::Version
33
- version: 3.1.0.rc1
32
+ version: '3.1'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *2156686020
35
+ version_requirements: *70095363735520
37
36
  - !ruby/object:Gem::Dependency
38
- name: activesupport
39
- requirement: &2156678320 !ruby/object:Gem::Requirement
37
+ name: rdoc
38
+ requirement: &70095363735080 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
41
  - - ~>
43
42
  - !ruby/object:Gem::Version
44
- version: 3.1.0.rc1
45
- type: :runtime
46
- prerelease: false
47
- version_requirements: *2156678320
48
- - !ruby/object:Gem::Dependency
49
- name: actionpack
50
- requirement: &2156677900 !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
53
- - - ~>
54
- - !ruby/object:Gem::Version
55
- version: 3.1.0.rc1
56
- type: :runtime
43
+ version: '3.10'
44
+ type: :development
57
45
  prerelease: false
58
- version_requirements: *2156677900
46
+ version_requirements: *70095363735080
59
47
  - !ruby/object:Gem::Dependency
60
48
  name: hoe
61
- requirement: &2156677420 !ruby/object:Gem::Requirement
49
+ requirement: &70095363734640 !ruby/object:Gem::Requirement
62
50
  none: false
63
51
  requirements:
64
52
  - - ~>
65
53
  - !ruby/object:Gem::Version
66
- version: 2.9.5
54
+ version: '2.16'
67
55
  type: :development
68
56
  prerelease: false
69
- version_requirements: *2156677420
70
- description: Adds MiniTest as the default testing library in Rails.
57
+ version_requirements: *70095363734640
58
+ description: Adds MiniTest as the default testing library in Rails 3.
71
59
  email:
72
60
  - mike@blowmage.com
73
61
  executables: []
74
62
  extensions: []
75
63
  extra_rdoc_files:
64
+ - CHANGELOG.rdoc
76
65
  - Manifest.txt
66
+ - README.rdoc
77
67
  files:
78
68
  - .autotest
79
69
  - CHANGELOG.rdoc
@@ -115,7 +105,6 @@ files:
115
105
  - test/test_model_generator.rb
116
106
  - test/test_scaffold_generator.rb
117
107
  - .gemtest
118
- has_rdoc: true
119
108
  homepage: http://blowmage.com/minitest-rails
120
109
  licenses: []
121
110
  post_install_message:
@@ -138,10 +127,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
127
  version: '0'
139
128
  requirements: []
140
129
  rubyforge_project: minitest-rails
141
- rubygems_version: 1.6.2
130
+ rubygems_version: 1.8.16
142
131
  signing_key:
143
132
  specification_version: 3
144
- summary: MiniTest integration for Rails 3.1.
133
+ summary: MiniTest integration for Rails 3.
145
134
  test_files:
146
135
  - test/test_controller_generator.rb
147
136
  - test/test_helper_generator.rb