Last active
August 29, 2015 14:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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