minitest-spec-rails 3.1.2 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. data/.travis.yml +9 -6
  2. data/Appraisals +17 -0
  3. data/CHANGELOG.md +3 -12
  4. data/Gemfile +1 -3
  5. data/README.md +111 -2
  6. data/Rakefile +8 -0
  7. data/gemfiles/rails30.gemfile +7 -0
  8. data/gemfiles/rails30.gemfile.lock +94 -0
  9. data/gemfiles/rails31.gemfile +7 -0
  10. data/gemfiles/rails31.gemfile.lock +105 -0
  11. data/gemfiles/rails32.gemfile +7 -0
  12. data/gemfiles/rails32.gemfile.lock +104 -0
  13. data/gemfiles/rails40.gemfile +7 -0
  14. data/gemfiles/rails40.gemfile.lock +107 -0
  15. data/lib/minitest-spec-rails.rb +4 -5
  16. data/lib/minitest-spec-rails/init/action_controller.rb +11 -19
  17. data/lib/minitest-spec-rails/init/action_mailer.rb +5 -22
  18. data/lib/minitest-spec-rails/init/action_view.rb +15 -33
  19. data/lib/minitest-spec-rails/init/active_support.rb +11 -19
  20. data/lib/minitest-spec-rails/railtie.rb +17 -0
  21. data/lib/minitest-spec-rails/version.rb +1 -1
  22. data/lib/test/unit.rb +5 -0
  23. data/lib/test/unit/assertions.rb +5 -0
  24. data/lib/test/unit/testcase.rb +31 -0
  25. data/minitest-spec-rails.gemspec +3 -4
  26. data/test/cases/action_dispatch_test.rb +2 -2
  27. data/test/cases/active_support_test.rb +5 -17
  28. data/test/cases/minitest_spec_rails_test.rb +11 -0
  29. data/test/dummy_app/app/controllers/users_controller.rb +0 -4
  30. data/test/dummy_app/app/helpers/application_helper.rb +1 -0
  31. data/test/dummy_app/app/mailers/user_mailer.rb +10 -0
  32. data/test/dummy_app/app/models/user.rb +0 -3
  33. data/test/dummy_app/app/views/users/{index.rhtml → index.html.erb} +0 -0
  34. data/test/dummy_app/config/database.yml +5 -2
  35. data/test/dummy_app/config/routes.rb +3 -5
  36. data/test/dummy_app/init.rb +32 -8
  37. data/test/dummy_app/{db/schema.rb → tmp/.gitkeep} +0 -0
  38. data/test/dummy_tests/application_controller_test.rb +23 -67
  39. data/test/dummy_tests/integration_test.rb +22 -13
  40. data/test/dummy_tests/user_mailer_test.rb +27 -65
  41. data/test/dummy_tests/user_test.rb +14 -50
  42. data/test/dummy_tests/users_controller_test.rb +6 -13
  43. data/test/dummy_tests/users_helper_test.rb +19 -55
  44. data/test/support/shared_test_case_behavior.rb +16 -10
  45. data/test/test_helper.rb +2 -2
  46. data/test/test_helper_dummy.rb +2 -0
  47. metadata +33 -75
  48. data/Guardfile +0 -7
  49. data/lib/minitest-spec-rails/dsl.rb +0 -52
  50. data/lib/minitest-spec-rails/init/action_dispatch.rb +0 -17
  51. data/lib/minitest-spec-rails/init/mini_shoulda.rb +0 -47
  52. data/lib/minitest-spec-rails/rails.rb +0 -7
  53. data/test/cases/mini_shoulda_test.rb +0 -38
  54. data/test/dummy_app/app/helpers/foos_helper.rb +0 -5
  55. data/test/dummy_app/app/models/post.rb +0 -6
  56. data/test/dummy_app/app/models/user_mailer.rb +0 -10
  57. data/test/dummy_app/app/views/user_mailer/welcome.erb +0 -1
  58. data/test/dummy_app/config/boot.rb +0 -126
  59. data/test/dummy_app/config/environment.rb +0 -12
  60. data/test/dummy_app/config/environments/test.rb +0 -28
  61. data/test/dummy_app/config/initializers/new_rails_defaults.rb +0 -15
  62. data/test/dummy_app/lib/library.rb +0 -2
  63. data/test/dummy_app/log/.keep +0 -0
  64. data/test/dummy_app/public/.htaccess +0 -40
  65. data/test/dummy_app/public/404.html +0 -30
  66. data/test/dummy_app/public/422.html +0 -30
  67. data/test/dummy_app/public/500.html +0 -30
  68. data/test/dummy_app/script/console +0 -3
  69. data/test/dummy_app/script/generate +0 -3
  70. data/test/dummy_tests/foo_helper_test.rb +0 -12
  71. data/test/dummy_tests/library_test.rb +0 -16
@@ -1,17 +0,0 @@
1
- module MiniTestSpecRails
2
- module Init
3
- module ActionDispatchBehavior
4
-
5
- def self.included(klass)
6
- klass.class_eval do
7
- register_spec_type(/(Acceptance|Integration) ?Test\z/i, self)
8
- register_spec_type(self) { |desc| Class === desc && desc < self }
9
- register_rails_test_case self
10
- end
11
- end
12
-
13
- end
14
- end
15
- end
16
-
17
- ActionController::IntegrationTest.send :include, MiniTestSpecRails::Init::ActionDispatchBehavior
@@ -1,47 +0,0 @@
1
- module MiniTestSpecRails
2
- module Init
3
- module MiniShouldaBehavior
4
-
5
- def self.included(klass)
6
- klass.class_eval do
7
- class << self
8
-
9
- alias :context :describe
10
- alias :should :it
11
-
12
- def setup_with_minitest(*args, &block)
13
- if args.first.is_a?(Symbol) && !block_given?
14
- setup_without_minitest(args.first)
15
- else
16
- setup_without_minitest { |o| o.instance_eval(&block) }
17
- end
18
- end
19
- alias_method_chain :setup, :minitest
20
-
21
- def teardown_with_minitest(*args, &block)
22
- if args.first.is_a?(Symbol) && !block_given?
23
- teardown_without_minitest(args.first)
24
- else
25
- teardown_without_minitest { |o| o.instance_eval(&block) }
26
- end
27
- end
28
- alias_method_chain :teardown, :minitest
29
-
30
- end
31
- extend ClassMethods
32
- end
33
- end
34
-
35
- module ClassMethods
36
-
37
- def should_eventually(desc)
38
- it("should eventually #{desc}") { skip("Should eventually #{desc}") }
39
- end
40
-
41
- end
42
-
43
- end
44
- end
45
- end
46
-
47
- ActiveSupport::TestCase.send :include, MiniTestSpecRails::Init::MiniShouldaBehavior
@@ -1,7 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'minitest-spec-rails/init/active_support'
3
- require 'minitest-spec-rails/init/mini_shoulda'
4
- require 'minitest-spec-rails/init/action_view'
5
- require 'minitest-spec-rails/init/action_controller'
6
- require 'minitest-spec-rails/init/action_dispatch'
7
- require 'minitest-spec-rails/init/action_mailer'
@@ -1,38 +0,0 @@
1
- require 'test_helper_dummy'
2
-
3
- class PostTests < ActiveSupport::TestCase
4
-
5
- i_suck_and_my_tests_are_order_dependent!
6
-
7
- $teardown_ran = false
8
-
9
- setup do
10
- @post = user_post
11
- end
12
-
13
- teardown do
14
- $teardown_ran = true
15
- end
16
-
17
- should 'setup correctly and $teardown_ran should still be false since this is the first test' do
18
- @post.must_be_instance_of Post
19
- $teardown_ran.must_equal false
20
- end
21
-
22
- should 'teardown correctly' do
23
- $teardown_ran.must_equal true
24
- end
25
-
26
- should_eventually 'will be skipped' do
27
- assert false
28
- end
29
-
30
- context 'level 1' do
31
-
32
- should 'work' do
33
- @post.must_be_instance_of Post
34
- end
35
-
36
- end
37
-
38
- end
@@ -1,5 +0,0 @@
1
- module FoosHelper
2
- def passes
3
- true
4
- end
5
- end
@@ -1,6 +0,0 @@
1
- class Post < ActiveRecord::Base
2
-
3
- belongs_to :user
4
-
5
-
6
- end
@@ -1,10 +0,0 @@
1
- class UserMailer < ActionMailer::Base
2
-
3
- def welcome(user)
4
- recipients user.email
5
- from 'rails@minitest.spec'
6
- subject 'Welcome'
7
- body :user => user
8
- end
9
-
10
- end
@@ -1 +0,0 @@
1
- Welcome to MiniTest::Spec <%= @user.email %>!
@@ -1,126 +0,0 @@
1
- # Don't change this file!
2
- # Configure your app in config/environment.rb and config/environments/*.rb
3
-
4
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
-
6
- module Rails
7
- class << self
8
- def boot!
9
- unless booted?
10
- preinitialize
11
- pick_boot.run
12
- end
13
- end
14
-
15
- def booted?
16
- defined? Rails::Initializer
17
- end
18
-
19
- def pick_boot
20
- (vendor_rails? ? VendorBoot : GemBoot).new
21
- end
22
-
23
- def vendor_rails?
24
- File.exist?("#{RAILS_ROOT}/vendor/rails")
25
- end
26
-
27
- def preinitialize
28
- load(preinitializer_path) if File.exist?(preinitializer_path)
29
- end
30
-
31
- def preinitializer_path
32
- "#{RAILS_ROOT}/config/preinitializer.rb"
33
- end
34
- end
35
-
36
- class Boot
37
- def run
38
- load_initializer
39
- Rails::Initializer.run(:set_load_path)
40
- end
41
- end
42
-
43
- class VendorBoot < Boot
44
- def load_initializer
45
- require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
- Rails::Initializer.run(:install_gem_spec_stubs)
47
- Rails::GemDependency.add_frozen_gem_path
48
- end
49
- end
50
-
51
- class GemBoot < Boot
52
- def load_initializer
53
- self.class.load_rubygems
54
- load_rails_gem
55
- require 'initializer'
56
- end
57
-
58
- def load_rails_gem
59
- if version = self.class.gem_version
60
- gem 'rails', version
61
- else
62
- gem 'rails'
63
- end
64
- rescue Gem::LoadError => load_error
65
- if load_error.message =~ /Could not find RubyGem rails/
66
- STDERR.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
67
- exit 1
68
- else
69
- raise
70
- end
71
- end
72
-
73
- class << self
74
- def rubygems_version
75
- Gem::RubyGemsVersion rescue nil
76
- end
77
-
78
- def gem_version
79
- if defined? RAILS_GEM_VERSION
80
- RAILS_GEM_VERSION
81
- elsif ENV.include?('RAILS_GEM_VERSION')
82
- ENV['RAILS_GEM_VERSION']
83
- else
84
- parse_gem_version(read_environment_rb)
85
- end
86
- end
87
-
88
- def load_rubygems
89
- min_version = '1.3.2'
90
- require 'rubygems'
91
- unless rubygems_version >= min_version
92
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
93
- exit 1
94
- end
95
-
96
- rescue LoadError
97
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
98
- exit 1
99
- end
100
-
101
- def parse_gem_version(text)
102
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
103
- end
104
-
105
- private
106
- def read_environment_rb
107
- File.read("#{RAILS_ROOT}/config/environment.rb")
108
- end
109
- end
110
- end
111
- end
112
-
113
- class Rails::Boot
114
- def run
115
- load_initializer
116
- Rails::Initializer.class_eval do
117
- def load_gems
118
- @bundler_loaded ||= Bundler.require :default, Rails.env
119
- end
120
- end
121
- Rails::Initializer.run(:set_load_path)
122
- end
123
- end
124
-
125
- # All that for this:
126
- Rails.boot!
@@ -1,12 +0,0 @@
1
- require File.join(File.dirname(__FILE__), 'boot')
2
-
3
- Rails::Initializer.run do |config|
4
- config.log_level = :debug
5
- config.cache_classes = false
6
- config.whiny_nils = true
7
- config.action_controller.session = {
8
- :key => 'mtsr_session',
9
- :secret => 'ceae6058a816b1446e09ce90d8372511'
10
- }
11
- end
12
-
@@ -1,28 +0,0 @@
1
- # Settings specified here will take precedence over those in config/environment.rb
2
-
3
- # The test environment is used exclusively to run your application's
4
- # test suite. You never need to work with it otherwise. Remember that
5
- # your test database is "scratch space" for the test suite and is wiped
6
- # and recreated between test runs. Don't rely on the data there!
7
- config.cache_classes = true
8
-
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
11
-
12
- # Show full error reports and disable caching
13
- config.action_controller.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
- config.action_view.cache_template_loading = true
16
-
17
- # Disable request forgery protection in test environment
18
- config.action_controller.allow_forgery_protection = false
19
-
20
- # Tell Action Mailer not to deliver emails to the real world.
21
- # The :test delivery method accumulates sent emails in the
22
- # ActionMailer::Base.deliveries array.
23
- config.action_mailer.delivery_method = :test
24
-
25
- # Use SQL instead of Active Record's schema dumper when creating the test database.
26
- # This is necessary if your schema can't be completely dumped by the schema dumper,
27
- # like if you have constraints or database-specific column types
28
- # config.active_record.schema_format = :sql
@@ -1,15 +0,0 @@
1
- # These settings change the behavior of Rails 2 apps and will be defaults
2
- # for Rails 3. You can remove this initializer when Rails 3 is released.
3
-
4
- # Include Active Record class name as root for JSON serialized output.
5
- ActiveRecord::Base.include_root_in_json = true
6
-
7
- # Store the full class name (including module namespace) in STI type column.
8
- ActiveRecord::Base.store_full_sti_class = true
9
-
10
- # Use ISO 8601 format for JSON serialized times and dates.
11
- ActiveSupport.use_standard_json_time_format = true
12
-
13
- # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
14
- # if you're including raw json in an HTML page.
15
- ActiveSupport.escape_html_entities_in_json = false
@@ -1,2 +0,0 @@
1
- class Library
2
- end
File without changes
@@ -1,40 +0,0 @@
1
- # General Apache options
2
- AddHandler fastcgi-script .fcgi
3
- AddHandler cgi-script .cgi
4
- Options +FollowSymLinks +ExecCGI
5
-
6
- # If you don't want Rails to look in certain directories,
7
- # use the following rewrite rules so that Apache won't rewrite certain requests
8
- #
9
- # Example:
10
- # RewriteCond %{REQUEST_URI} ^/notrails.*
11
- # RewriteRule .* - [L]
12
-
13
- # Redirect all requests not available on the filesystem to Rails
14
- # By default the cgi dispatcher is used which is very slow
15
- #
16
- # For better performance replace the dispatcher with the fastcgi one
17
- #
18
- # Example:
19
- # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
20
- RewriteEngine On
21
-
22
- # If your Rails application is accessed via an Alias directive,
23
- # then you MUST also set the RewriteBase in this htaccess file.
24
- #
25
- # Example:
26
- # Alias /myrailsapp /path/to/myrailsapp/public
27
- # RewriteBase /myrailsapp
28
-
29
- RewriteRule ^$ index.html [QSA]
30
- RewriteRule ^([^.]+)$ $1.html [QSA]
31
- RewriteCond %{REQUEST_FILENAME} !-f
32
- RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
33
-
34
- # In case Rails experiences terminal errors
35
- # Instead of displaying this message you can supply a file here which will be rendered instead
36
- #
37
- # Example:
38
- # ErrorDocument 500 /500.html
39
-
40
- ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
@@ -1,30 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
-
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
-
6
- <head>
7
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
8
- <title>The page you were looking for doesn't exist (404)</title>
9
- <style type="text/css">
10
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
11
- div.dialog {
12
- width: 25em;
13
- padding: 0 4em;
14
- margin: 4em auto 0 auto;
15
- border: 1px solid #ccc;
16
- border-right-color: #999;
17
- border-bottom-color: #999;
18
- }
19
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
20
- </style>
21
- </head>
22
-
23
- <body>
24
- <!-- This file lives in public/404.html -->
25
- <div class="dialog">
26
- <h1>The page you were looking for doesn't exist.</h1>
27
- <p>You may have mistyped the address or the page may have moved.</p>
28
- </div>
29
- </body>
30
- </html>
@@ -1,30 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
-
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
-
6
- <head>
7
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
8
- <title>The change you wanted was rejected (422)</title>
9
- <style type="text/css">
10
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
11
- div.dialog {
12
- width: 25em;
13
- padding: 0 4em;
14
- margin: 4em auto 0 auto;
15
- border: 1px solid #ccc;
16
- border-right-color: #999;
17
- border-bottom-color: #999;
18
- }
19
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
20
- </style>
21
- </head>
22
-
23
- <body>
24
- <!-- This file lives in public/422.html -->
25
- <div class="dialog">
26
- <h1>The change you wanted was rejected.</h1>
27
- <p>Maybe you tried to change something you didn't have access to.</p>
28
- </div>
29
- </body>
30
- </html>
@@ -1,30 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
-
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
-
6
- <head>
7
- <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
8
- <title>We're sorry, but something went wrong (500)</title>
9
- <style type="text/css">
10
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
11
- div.dialog {
12
- width: 25em;
13
- padding: 0 4em;
14
- margin: 4em auto 0 auto;
15
- border: 1px solid #ccc;
16
- border-right-color: #999;
17
- border-bottom-color: #999;
18
- }
19
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
20
- </style>
21
- </head>
22
-
23
- <body>
24
- <!-- This file lives in public/500.html -->
25
- <div class="dialog">
26
- <h1>We're sorry, but something went wrong.</h1>
27
- <p>We've been notified about this issue and we'll take a look at it shortly.</p>
28
- </div>
29
- </body>
30
- </html>