Permalink
Browse files

Tests are sorta working.

  • Loading branch information...
1 parent e6ed809 commit d63970d7c840e69cfbeb3262fa1f8cb9997d2aa8 @steveklabnik steveklabnik committed Jul 18, 2011
View
@@ -55,7 +55,6 @@ gem "delayed_job_mongo_mapper", :git => "git://github.com/earbits/delayed_job_mo
gem "whenever"
group :development, :test do
- gem "minitest"
gem 'rack-test'
gem "database_cleaner"
gem "factory_girl"
@@ -67,5 +66,5 @@ group :development, :test do
gem "webmock"
gem "simplecov", "~> 0.4.0", :require => false
gem "launchy"
+ gem 'minitest-rails'
end
-
View
@@ -124,6 +124,11 @@ GEM
treetop (~> 1.4.8)
mime-types (1.16)
minitest (2.3.1)
+ minitest-rails (0.0.5)
+ actionpack (~> 3.1.0.rc1)
+ activesupport (~> 3.1.0.rc1)
+ minitest (~> 2.2)
+ railties (~> 3.1.0.rc1)
mocha (0.9.12)
mongo (1.3.1)
bson (>= 1.3.1)
@@ -316,7 +321,7 @@ DEPENDENCIES
i18n
jquery-rails
launchy
- minitest
+ minitest-rails
mocha
mongo_mapper
mongomapper_ext
View
@@ -1,6 +1,12 @@
require File.expand_path('../boot', __FILE__)
-require 'rails/all'
+# We don't want activerecord, so we commented out
+# require 'rails/all'
+require "action_controller/railtie"
+require "action_mailer/railtie"
+require "active_resource/railtie"
+require "rails/test_unit/railtie"
+
# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
@@ -41,6 +47,8 @@ class Application < Rails::Application
config.generators do |g|
g.template_engine :haml
+ g.test_framework :mini_test, :spec => true
+ g.orm :mongo_mapper
end
end
end
@@ -1,8 +0,0 @@
-if ENV['MONGOHQ_URL']
- MongoMapper.config = {ENV['RACK_ENV'] => {'uri' => ENV['MONGOHQ_URL']}}
- MongoMapper.database = ENV['MONGOHQ_DATABASE']
- MongoMapper.connect("production")
-else
- MongoMapper.connection = Mongo::Connection.new('localhost')
- MongoMapper.database = "rstatus-#{Rails.env}"
-end
View
@@ -0,0 +1,18 @@
+defaults: &defaults
+ host: 127.0.0.1
+ port: 27017
+
+development:
+ <<: *defaults
+ database: rstatus-development
+
+test:
+ <<: *defaults
+ database: rstatus-test
+
+# set these environment variables on your prod server
+production:
+ <<: *defaults
+ database: <%= ENV['MONGOHQ_DATABASE'] %>
+ uri: <%= ENV['MONGOHQ_URL'] %>
+
View
Binary file not shown.
View
@@ -1,31 +0,0 @@
-desc "Run unit tests"
-task :test, :file do |task, args|
- puts args.file
- test_task = Rake::TestTask.new("unittests") do |t|
- if args.file
- t.pattern = args.file
- else
- t.pattern = "test/unit/*_test.rb"
- end
- end
- task("unittests").execute
-end
-
-namespace :test do
-
- desc "Run all tests"
- task :all do
- test_task = Rake::TestTask.new("all") do |t|
- t.pattern = "test/*/*_test.rb"
- end
- task("all").execute
- end
-
- desc "Run acceptance tests"
- task :acceptance do
- test_task = Rake::TestTask.new("acceptance") do |t|
- t.pattern = "test/acceptance/*_test.rb"
- end
- task("acceptance").execute
- end
-end
@@ -1,52 +0,0 @@
-require 'simplecov'
-SimpleCov.start do
- add_filter "/models/all.rb"
- add_filter "/config.rb"
- add_filter "/test/"
- add_group "Models", "/models"
- add_group "Controllers", "/controllers"
- coverage_dir "/test/coverage"
-end
-
-require 'minitest/autorun'
-ENV['RACK_ENV'] = 'test'
-require 'bundler'
-Bundler.setup
-Bundler.require(:default, :test)
-
-require_relative 'factories'
-require_relative '../rstatus'
-
-module TestHelper
- def app() Rstatus end
-
- def setup
- DatabaseCleaner.strategy = :truncation
- DatabaseCleaner.clean_with(:truncation)
- DatabaseCleaner.start
- end
-
- def teardown
- DatabaseCleaner.clean
- end
-
- def auth_response(username, options={})
- hsh = {
- "provider" => options[:provider] || "twitter",
- "uid" => options[:uid] || 12345,
- "user_info" => {
- "name" => "Joe Public",
- "email" => "joe@public.com",
- "nickname" => username,
- "urls" => { "Website" => "http://rstat.us" },
- "description" => "A description",
- "image" => "/images/something.png"
- },
- "credentials" => {
- "token" => options[:token] || "1234",
- "secret" => options[:secret] || "4567"
- }
- }
- return hsh
- end
-end
File renamed without changes.
File renamed without changes.
View
No changes.
View
No changes.
No changes.
@@ -1,9 +1,6 @@
-require 'require_relative' if RUBY_VERSION[0,3] == '1.8'
-require_relative '../test_helper'
+require 'test_helper'
-describe Author do
-
- include TestHelper
+class AuthorTest < MiniTest::Rails::Model
before do
@author = Factory.build :author, :username => "james", :email => nil, :image_url => nil
@@ -1,9 +1,6 @@
-require 'require_relative' if RUBY_VERSION[0,3] == '1.8'
-require_relative '../test_helper'
+require "test_helper"
-describe Authorization do
-
- include TestHelper
+class AuthorizationTest < MiniTest::Rails::Model
before do
@u = Factory(:user)
@@ -1,9 +1,6 @@
-require 'require_relative' if RUBY_VERSION[0,3] == '1.8'
-require_relative '../test_helper'
+require "test_helper"
-describe Update do
-
- include TestHelper
+class UpdateTest < MiniTest::Rails::Model
describe "text length" do
it "is not valid without any text" do
@@ -1,10 +1,7 @@
# encoding: UTF-8
-require 'require_relative' if RUBY_VERSION[0,3] == '1.8'
-require_relative '../test_helper'
+require "test_helper"
-describe User do
-
- include TestHelper
+class UserTest < MiniTest::Rails::Model
describe "#at_replies" do
it "returns all at_replies for this user" do
@@ -1,12 +0,0 @@
-require 'test_helper'
-require 'rails/performance_test_help'
-
-class BrowsingTest < ActionDispatch::PerformanceTest
- # Refer to the documentation for all available options
- # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
- # :output => 'tmp/performance', :formats => [:flat] }
-
- def test_homepage
- get '/'
- end
-end
View
@@ -1,13 +1,51 @@
+require "minitest/autorun"
+require "minitest/rails"
+
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
-require 'rails/test_help'
-class ActiveSupport::TestCase
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
- #
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
- # -- they do not yet inherit this setting
- fixtures :all
+MongoMapper.connection = Mongo::Connection.new('localhost')
+MongoMapper.database = "rstatus-test"
+
+require_relative "factories"
+
+class MiniTest::Rails::Spec
+
+ def setup
+ DatabaseCleaner.strategy = :truncation
+ DatabaseCleaner.clean_with(:truncation)
+ DatabaseCleaner.start
+ end
+
+ def teardown
+ DatabaseCleaner.clean
+ end
+
+ def auth_response(username, options={})
+ hsh = {
+ "provider" => options[:provider] || "twitter",
+ "uid" => options[:uid] || 12345,
+ "user_info" => {
+ "name" => "Joe Public",
+ "email" => "joe@public.com",
+ "nickname" => username,
+ "urls" => { "Website" => "http://rstat.us" },
+ "description" => "A description",
+ "image" => "/images/something.png"
+ },
+ "credentials" => {
+ "token" => options[:token] || "1234",
+ "secret" => options[:secret] || "4567"
+ }
+ }
+ return hsh
+ end
+
+end
- # Add more helper methods to be used by all tests here...
+# Uncomment to support fixtures in Model tests...
+# require "active_record/fixtures"
+class MiniTest::Rails::Model
+ # include ActiveRecord::TestFixtures
+ # self.fixture_path = File.join(Rails.root, "test", "fixtures")
end
View
No changes.

0 comments on commit d63970d

Please sign in to comment.