Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move error[s]_on to ActiveModel::Validations so it can be used by other
ActiveModel compliant ORMs - Closes ????
- Loading branch information
1 parent
ddd9485
commit ab6dbea
Showing
3 changed files
with
59 additions
and
31 deletions.
There are no files selected for viewing
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
23 changes: 23 additions & 0 deletions
23
spec/rspec/rails/extensions/active_model/errors_on_spec.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require "spec_helper" | ||
|
||
describe "errors_on" do | ||
let(:klass) do | ||
Class.new do | ||
include ActiveModel::Validations | ||
end | ||
end | ||
|
||
it "calls valid?" do | ||
model = klass.new | ||
model.should_receive(:valid?) | ||
model.errors_on(:foo) | ||
end | ||
|
||
it "returns the errors on that attribute" do | ||
model = klass.new | ||
model.stub(:errors) do | ||
{ :foo => ['a', 'b'] } | ||
end | ||
model.errors_on(:foo).should eq(['a','b']) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require 'spec_helper' | ||
|
||
describe "records" do | ||
it "delegates to find(:all)" do | ||
klass = Class.new(ActiveRecord::Base) | ||
klass.should_receive(:find).with(:all) | ||
klass.records | ||
end | ||
end |