Created
May 7, 2011 18:17
-
-
Save chrismcg/960707 to your computer and use it in GitHub Desktop.
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 Name | |
def initialize(first_name, last_name) | |
@first_name, @last_name = first_name, last_name | |
end | |
def to_s | |
"#{first_name} #{last_name}" | |
end | |
end | |
describe Name do | |
subject do | |
Name.new("Chris", "McGrath") | |
end | |
it "returns full name as string" do | |
subject.to_s.should eq("Chris McGrath") | |
end | |
end | |
class Contact < ActiveRecord::Base | |
composed_of :name, :mapping => [:first_name, :last_name] | |
end | |
describe Contact do | |
subject do | |
contact = Contact.new | |
contact.first_name = "Anthony" | |
contact.last_name = "Eden" | |
contact | |
end | |
it "has a name" do | |
subject.name.should be_a_kind_of(Name) | |
end | |
end | |
class Renewable | |
def initialize(domain) | |
@domain = domain | |
end | |
def auto? | |
@domain.registry_domain.auto_renew? | |
rescue e | |
logger.error e | |
false | |
end | |
# and the rest | |
end | |
# some code somewhere | |
renewable = Renewable.new(@domain) | |
if renewable.auto? | |
# ... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment