Skip to content

Commit

Permalink
Tests are sorta working.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Jul 18, 2011
1 parent e6ed809 commit d63970d
Show file tree
Hide file tree
Showing 32 changed files with 88 additions and 135 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -67,5 +66,5 @@ group :development, :test do
gem "webmock"
gem "simplecov", "~> 0.4.0", :require => false
gem "launchy"
gem 'minitest-rails'
end

7 changes: 6 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -316,7 +321,7 @@ DEPENDENCIES
i18n
jquery-rails
launchy
minitest
minitest-rails
mocha
mongo_mapper
mongomapper_ext
Expand Down
10 changes: 9 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
8 changes: 0 additions & 8 deletions config/initializers/mongodb.rb

This file was deleted.

18 changes: 18 additions & 0 deletions config/mongo.yml
Original file line number Diff line number Diff line change
@@ -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'] %>

Binary file modified db/development.sqlite3
Binary file not shown.
31 changes: 0 additions & 31 deletions lib/tasks/test.rake

This file was deleted.

52 changes: 0 additions & 52 deletions sinatra/test/test_helper.rb

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed test/fixtures/.gitkeep
Empty file.
Empty file removed test/functional/.gitkeep
Empty file.
Empty file removed test/integration/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 2 additions & 5 deletions sinatra/test/unit/user_test.rb → test/models/user_test.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 0 additions & 12 deletions test/performance/browsing_test.rb

This file was deleted.

54 changes: 46 additions & 8 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -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" => "[email protected]",
"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
Empty file removed test/unit/.gitkeep
Empty file.

0 comments on commit d63970d

Please sign in to comment.