Created
September 21, 2011 15:28
-
-
Save karthiks/1232368 to your computer and use it in GitHub Desktop.
Can't find first MyFreakingActiveRecordModel....
This file contains hidden or 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
### Terminal Output showing spec failure ### | |
Failures: | |
1) CurrencyConverter#validations | |
Failure/Error: it { should validate_uniqueness_of(:from).scoped_to(:to) } | |
Can't find first CurrencyConverter | |
# ./spec/models/currency_converter_spec.rb:4:in `block (3 levels) in <top (required)>' | |
########################################### | |
### The Solution ### | |
########################################### | |
### currency_converter.rb ### | |
class CurrencyConverter < ActiveRecord::Base | |
validates_uniqueness_of :from, :scope => :to | |
end | |
### currency_converter_spec.rb ### | |
describe CurrencyConverter do | |
describe "#validations" do | |
subject { Factory(:currency_converter) } # Comment this line and you get spec failure shown in the Terminal Output above | |
it { should validate_uniqueness_of(:from).scoped_to(:to) } | |
end | |
end | |
### factories.rb ### | |
Factory.define(:currency_converter) do |cc| | |
cc.rate 100 | |
cc.from "INR" | |
cc.to "SGD" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment