mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-10 11:18:51 +01:00
56 lines
1.3 KiB
Ruby
56 lines
1.3 KiB
Ruby
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
|
|
|
|
# Add more helper methods to be used by all tests here...
|
|
end
|
|
|
|
module Tracks
|
|
class Config
|
|
def self.salt
|
|
"change-me"
|
|
end
|
|
def self.auth_schemes
|
|
return ["database","open_id"]
|
|
end
|
|
end
|
|
end
|
|
|
|
class ActiveSupport::TestCase
|
|
|
|
# Generates a random string of ascii characters (a-z, "1 0")
|
|
# of a given length for testing assignment to fields
|
|
# for validation purposes
|
|
#
|
|
def generate_random_string(length)
|
|
string = ""
|
|
characters = %w(a b c d e f g h i j k l m n o p q r s t u v w z y z 1\ 0)
|
|
length.times do
|
|
pick = characters[rand(26)]
|
|
string << pick
|
|
end
|
|
return string
|
|
end
|
|
|
|
def assert_equal_dmy(date1, date2)
|
|
assert_equal date1.strftime("%d-%m-%y"), date2.strftime("%d-%m-%y")
|
|
end
|
|
|
|
end
|
|
|
|
class Test::Unit::TestCase
|
|
|
|
def assert_value_changed(object, method = nil)
|
|
initial_value = object.send(method)
|
|
yield
|
|
assert_not_equal initial_value, object.send(method), "#{object}##{method}"
|
|
end
|
|
|
|
end
|