Skip to content
Browse files

Cleanup test helpers

  • Loading branch information...
1 parent 76ea70f commit 4b7c60f4edd2b7c63d3a60cfdfe3e8ac732bb042 @sferik sferik committed Jul 16, 2011
Showing with 18 additions and 20 deletions.
  1. +1 −0 features/support/env.rb
  2. +0 −10 features/support/gemcutter.rb
  3. +14 −3 features/support/paths.rb
  4. +3 −7 test/test_helper.rb
View
1 features/support/env.rb
@@ -48,6 +48,7 @@
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
begin
DatabaseCleaner.strategy = :transaction
+ DatabaseCleaner.clean_with :truncation
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
View
10 features/support/gemcutter.rb
@@ -1,25 +1,15 @@
-WebMock.disable_net_connect!
-
Hostess.local = true
TEST_DIR = File.join('/', 'tmp', 'gemcutter')
-DatabaseCleaner.clean_with :truncation
-DatabaseCleaner.strategy = :transaction
-
Before do
WebMock.reset!
- DatabaseCleaner.start
-
FileUtils.mkdir(TEST_DIR)
Dir.chdir(TEST_DIR)
-
$fog.directories.create(:key => $rubygems_config[:s3_bucket], :public => true)
end
After do
- DatabaseCleaner.clean
-
FileUtils.rm_rf(TEST_DIR)
$redis.flushdb
end
View
17 features/support/paths.rb
@@ -7,9 +7,20 @@ module NavigationHelpers
#
def path_to(page_name)
case page_name
-
- when /^the home\s?page$/
- '/'
+ when /the homepage/
+ root_path
+ when /the sign up page/
+ new_user_path
+ when /the sign in page/
+ new_session_path
+ when /the password reset request page/
+ new_password_path
+ when /the dashboard/
+ dashboard_path
+ when /my edit profile page/
+ edit_profile_path
+ when /"([^\"]+)" profile page/
+ profile_path(User.find_by_email!($1))
# Add more mappings here.
# Here is an example that pulls values out of the Regexp:
View
10 test/test_helper.rb
@@ -1,10 +1,7 @@
ENV["RAILS_ENV"] = "test"
-require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
+require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
-
-set :environment, :test
-WebMock.disable_net_connect!
-
+require 'webmock/test_unit'
require 'clearance/shoulda_macros'
class ActiveSupport::TestCase
@@ -59,7 +56,6 @@ def gem_specification_from_gem_fixture(name)
end
def stub_uploaded_token(gem_name, token, status = [200, "Success"])
- WebMock.stub_request(:get,
- "http://#{gem_name}.rubyforge.org/migrate-#{gem_name}.html").
+ WebMock.stub_request(:get, "http://#{gem_name}.rubyforge.org/migrate-#{gem_name}.html").
to_return(:body => token + "\n", :status => status)
end

0 comments on commit 4b7c60f

Please sign in to comment.
Something went wrong with that request. Please try again.