Created
February 21, 2011 22:48
-
-
Save thejonanshow/837853 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
From the asset model: | |
def alt_text | |
attachments.first.alt_text if attachments.first | |
end | |
My test: | |
require 'spec/spec_helper' | |
describe "Asset" do | |
context "asset methods" do | |
before do | |
attachment = mock_model(Attachment, :alt_text => 'alt text') | |
attachments = [attachment] | |
@asset = Asset.new(:attachments => attachments) | |
end | |
it "should return alt_text from an asset's attachments when asked for alt_text" do | |
@asset.alt_text.should eql('alt text') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What an amazing gist.