Skip to content

Commit

Permalink
Get test running using appraisal gem.
Browse files Browse the repository at this point in the history
* Remove Dummy::Application isolation namespace.
  • Loading branch information
metaskills committed Jan 16, 2013
1 parent e9605d2 commit 6b2e958
Show file tree
Hide file tree
Showing 42 changed files with 477 additions and 163 deletions.
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,3 @@ rvm:
- jruby-19mode
- rbx-18mode
- rbx-19mode
gemfile:
- gemfiles/rails3.0.x.gemfile
- gemfiles/rails3.1.x.gemfile
- gemfiles/rails3.2.x.gemfile
- gemfiles/rails4.0.x.gemfile
13 changes: 13 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

appraise 'rails30' do
gem 'rails', '~> 3.0.0'
end

appraise 'rails31' do
gem 'rails', '~> 3.1.0'
end

appraise 'rails32' do
gem 'rails', '~> 3.2.0'
end

1 change: 0 additions & 1 deletion Gemfile

This file was deleted.

4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source :rubygems

gemspec

29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,35 @@ MiniTest::Spec Style:
foo.must_equal 100
```

There are a few missing assertions available in Test::Unit that are changed or no longer available in MiniTest.
## Gotchas

* The method `assert_raise` is renamed `assert_raises`.
* There is no method `assert_nothing_raised`. There are good reasons for this on [Ryan's blog entry](http:https://blog.zenspider.com/blog/2012/01/assert_nothing_tested.html).
If you are upgrading from Test::Unit, there are a few missing assertions that are changed or no longer available in MiniTest.

* The method `assert_raise` is renamed `assert_raises`.
* There is no method `assert_nothing_raised`. There are good reasons for this on [Ryan's blog entry](http:https://blog.zenspider.com/blog/2012/01/assert_nothing_tested.html).

If you are using minitest-spec-rails with Rails 3.0, then your controller or mailer tests will need to use the `tests` interface for the test to be setup correct within sub `describe` blocks. I think this is a bug with `class_attribute` within Rails 3.0. Rails 3.1 and higher does not exhibit this problem.


## Testing

After cloning the repository. Running the following commands will install all the dependencies and run tests for each appraisal gemfile and Rails version.

```shell
$ bundle install
$ bundle exec rake appraisal:install
$ bundle exec rake appraisal test
```

If you want to run the tests for a specific Rails version, use `rake -T` for a list. For example, the following command will run the tests for Rails 3.2 only.

```shell
$ bundle exec rake appraisal:rails32 test
```


## Issues

If there are any issues using this in Rails 3 outside the normal few assertions that change from Test::Unit to MiniTest::Unit, please open an issue here on github.
If there are any issues past the gotchas mentioned above, please open an issue here on github.


63 changes: 7 additions & 56 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,59 +1,10 @@
require 'bundler'
require 'rake/testtask'
require 'rubygems'
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'appraisal'

GEMFILES = Dir["gemfiles/*.gemfile"].inject({}) do |memo, gemfile|
if gemfile.include?('common')
memo
else
version = gemfile.match(/rails(\d\.\d)/)[1]
memo[version] = gemfile
memo
end
end

DEFAULT_GEMFILE = GEMFILES['3.2']

desc 'Setup default Gemfile'
task 'setup' do
default_gemfile
end

namespace :test do

Rake::TestTask.new(:default) do |t|
t.libs = ['lib','test']
t.test_files = Dir.glob("test/**/*_test.rb").sort
t.verbose = true
end

GEMFILES.each do |version, gemfile|

desc "Test using Rails v#{version}"
task "rails#{version}" => 'setup' do
with_rails_version(version) { Rake::Task['test:default'].execute }
end

end

end

task :test => 'test:default'
task :default => 'test:default'

def with_rails_version(version)
begin
FileUtils.rm_rf 'Gemfile'
FileUtils.rm_rf 'Gemfile.lock'
FileUtils.ln_s GEMFILES[version], 'Gemfile', :force => true
`bundle install`
yield
ensure
default_gemfile
end
end

def default_gemfile
FileUtils.ln_s DEFAULT_GEMFILE, 'Gemfile', :force => true
FileUtils.rm_rf 'Gemfile.lock'
Rake::TestTask.new do |t|
t.libs = ['lib','test']
t.test_files = Dir.glob("test/**/*_test.rb").sort
t.verbose = true
end
4 changes: 0 additions & 4 deletions gemfiles/common.gemfile

This file was deleted.

3 changes: 0 additions & 3 deletions gemfiles/rails3.0.x.gemfile

This file was deleted.

3 changes: 0 additions & 3 deletions gemfiles/rails3.1.x.gemfile

This file was deleted.

4 changes: 0 additions & 4 deletions gemfiles/rails3.2.x.gemfile

This file was deleted.

7 changes: 7 additions & 0 deletions gemfiles/rails30.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source :rubygems

gem "rails", "~> 3.0.0"

gemspec :path=>"../"
102 changes: 102 additions & 0 deletions gemfiles/rails30.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
PATH
remote: /Users/kencollins/Repositories/minitest-spec-rails
specs:
minitest-spec-rails (4.3.0)
minitest (~> 4.3)
rails (>= 3.0)

GEM
remote: http:https://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.19)
actionpack (= 3.0.19)
mail (~> 2.2.19)
actionpack (3.0.19)
activemodel (= 3.0.19)
activesupport (= 3.0.19)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
rack (~> 1.2.5)
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.19)
activesupport (= 3.0.19)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.19)
activemodel (= 3.0.19)
activesupport (= 3.0.19)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activeresource (3.0.19)
activemodel (= 3.0.19)
activesupport (= 3.0.19)
activesupport (3.0.19)
appraisal (0.5.1)
bundler
rake
arel (2.0.10)
builder (2.1.2)
coderay (1.0.8)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.5.0)
json (1.7.6)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.8.1)
mime-types (1.19)
minitest (4.4.0)
minitest-emoji (1.0.0)
polyglot (0.3.3)
pry (0.9.10)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.3.1)
rack (1.2.7)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.19)
actionmailer (= 3.0.19)
actionpack (= 3.0.19)
activerecord (= 3.0.19)
activeresource (= 3.0.19)
activesupport (= 3.0.19)
bundler (~> 1.0)
railties (= 3.0.19)
railties (3.0.19)
actionpack (= 3.0.19)
activesupport (= 3.0.19)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
slop (3.3.3)
sqlite3 (1.3.7)
thor (0.14.6)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.35)

PLATFORMS
ruby

DEPENDENCIES
appraisal
minitest-emoji
minitest-spec-rails!
pry
rails (~> 3.0.0)
rake
sqlite3
7 changes: 7 additions & 0 deletions gemfiles/rails31.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source :rubygems

gem "rails", "~> 3.1.0"

gemspec :path=>"../"
113 changes: 113 additions & 0 deletions gemfiles/rails31.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
PATH
remote: /Users/kencollins/Repositories/minitest-spec-rails
specs:
minitest-spec-rails (4.3.0)
minitest (~> 4.3)
rails (>= 3.0)

GEM
remote: http:https://rubygems.org/
specs:
actionmailer (3.1.10)
actionpack (= 3.1.10)
mail (~> 2.3.3)
actionpack (3.1.10)
activemodel (= 3.1.10)
activesupport (= 3.1.10)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.6)
rack-cache (~> 1.2)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.4)
activemodel (3.1.10)
activesupport (= 3.1.10)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.10)
activemodel (= 3.1.10)
activesupport (= 3.1.10)
arel (~> 2.2.3)
tzinfo (~> 0.3.29)
activeresource (3.1.10)
activemodel (= 3.1.10)
activesupport (= 3.1.10)
activesupport (3.1.10)
multi_json (>= 1.0, < 1.3)
appraisal (0.5.1)
bundler
rake
arel (2.2.3)
builder (3.0.4)
coderay (1.0.8)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.1)
json (1.7.6)
mail (2.3.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.8.1)
mime-types (1.19)
minitest (4.4.0)
minitest-emoji (1.0.0)
multi_json (1.2.0)
polyglot (0.3.3)
pry (0.9.10)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.3.1)
rack (1.3.9)
rack-cache (1.2)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.1.10)
actionmailer (= 3.1.10)
actionpack (= 3.1.10)
activerecord (= 3.1.10)
activeresource (= 3.1.10)
activesupport (= 3.1.10)
bundler (~> 1.0)
railties (= 3.1.10)
railties (3.1.10)
actionpack (= 3.1.10)
activesupport (= 3.1.10)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
slop (3.3.3)
sprockets (2.0.4)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.7)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.35)

PLATFORMS
ruby

DEPENDENCIES
appraisal
minitest-emoji
minitest-spec-rails!
pry
rails (~> 3.1.0)
rake
sqlite3
Loading

0 comments on commit 6b2e958

Please sign in to comment.