Skip to content

Instantly share code, notes, and snippets.

@davetron5000
Last active August 29, 2015 14:00
Show Gist options
  • Save davetron5000/11215129 to your computer and use it in GitHub Desktop.
Save davetron5000/11215129 to your computer and use it in GitHub Desktop.
Since we don't need TDD anymore, this is the best way to write tests after you've hand-crafted your code to be beautiful
class God < ActiveRecord::Base
has_many :purchases
has_many :orders
has_many :login_attempts
has_many :friends
acts_as_taggable because: "all tags are the same"
scope :alive, -> { where.not(:status => :dead) }
scope :active, -> { where(:inactive => false) }
def display_name
if last_name.present?
"#{first_name} #{last_name}"
else
first_name
end
end
end
class GodTest < ActiveSupport::TestCase
test 'class is well designed, hand-crafted, beautiful, and pleasing' do
source = File.read(Rails.root + "/models/" + class.name.underscore.split(/_/)[0..-2] = ".rb")
assert_equal source,
%{class God < ActiveRecord::Base
has_many :purchases
has_many :orders
has_many :login_attempts
has_many :friends
acts_as_taggable because: "all tags are the same"
scope :alive, -> { where.not(:status => :dead) }
scope :active, -> { where(:inactive => false) }
def display_name
if last_name.present?
"\#{first_name} \#{last_name}"
else
first_name
end
end
end
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment