22543_257969437362_629277362_4448314_4184252_n_normaleladmeidar

http://twitter.com/eladmeidar

boot.rb

require "#{File.dirname(__FILE__)}/../vendor/bundler_gems/environment"
 
class Rails::Boot
  def run
    load_initializer
    extend_environment
    Rails::Initializer.run(:set_load_path)
  end
 
  def extend_environment
    Rails::Initializer.class_eval do
      old_load = instance_method(:load_environment)
      define_method(:load_environment) do
        Bundler.require_env RAILS_ENV
        old_load.bind(self).call
      end
    end
  end
end
Reveal More
Added over 2 years ago

indexer_test.rb

require 'test_helper'

puts "loaded!"
class IndexerTest < ActiveSupport::TestCase
  # Replace this with your real tests.
  
  def setup
    puts "clarck!!!"
    @model_originated_indexes = check_for_indexes
  end
  
  test "the truth" do
    puts @model_originated_indexes
    assert true
  end
end
Reveal More
Added over 2 years ago

test_helper.rb

require 'rubygems'
require 'activerecord'
require 'active_record/fixtures'
require 'active_support'
require 'active_support/test_case'
require 'action_controller'

require 'indexer'

ActiveRecord::Base.establish_connection(
  :adapter  => "sqlite3",
  :database => ":memory:"
)

load 'test/fixtures/schema.rb'

# Load models
Dir['test/fixtures/app/models/**/*.rb'].each { |f| require f }

# load controllers
Dir['test/fixtures/app/controllers/**/*.rb'].each { |f| require f }

puts "Done!"
Reveal More
Added over 2 years ago

Failing test

require 'test_helper'

class VendorTest < ActiveSupport::TestCase

  should_belong_to :company
  should_validate_presence_of :name
  
  context "a new free account vendor factory" do
    setup do
      @vendor = Factory.create(:vendor)
    end
    
    should "have a free account set" do
      assert @vendor.account.present? 
    end
  end
end
Reveal More
Added over 2 years ago

Factory_Girl suckage

Factory.define :free_account, :class => 'Account' do |a|
  a.free true
end

Factory.define :vendor do |v|
  v.company_name 'Vendor!'
  v.association :account, :factory => :free_account
end


# Now in the actual tests where is specify for ex: @vender = Factory.create(:vendor)... vendor.account == nil :/
Reveal More
Added over 2 years ago

Timezone awareness

>> Time.zone = "EST"
=> "EST"
>> Part.first.created_at
=> Mon, 24 Aug 2009 09:26:05 EST -05:00
>> Time.zone = "Sydney"
=> "Sydney"
>> Part.first.created_at
=> Tue, 25 Aug 2009 00:26:05 EST +10:00
Reveal More
Added over 2 years ago
Post Code