Displaying 12 results from an estimated 12 matches for "errors_on".
Did you mean:
error_on
2007 Mar 01
2
error_on is deprecated?
The docs say
DEPRECATED. See Spec::Rails::Expectations
model.should_have(:no).errors_on(:attribute)
model.should_have(1).error_on(:attribute)
model.should_have(3).errors_on(:attribute)
However the rdoc for Spec::Rails::Expectations shows the same code.
The only difference is that it''s "model.should
have(1).error_on(:attribute) instead"
So is error_on itself deprec...
2011 Feb 25
7
Rspec2 for rails 2.3.8?
Hi experts,
I picked up a copy of the rspec book and wrote some tests in spec/lib
and spec/models for my Rails 2.3.8 code.
I was using rspec 2.5.1, rspec-core 2.5.0, rspec-expectations 2.5.0 et.
al.
But I realised that the rspec-rails version I am using is meant for
Rails3.
Which version of rspec-rails should I use for Rails 2.3.8?
Best,
Radhesh
--
Posted via http://www.ruby-forum.com/.
2009 Mar 23
5
Rspec weird behaviour
Hi,
I recently migrated from classic rails testing to Rspec, so I am
pretty new to the framework and still learning. I am getting weird
errors on an ActiveRecord model test, here is the basic class model
definition:
class Size < ActiveRecord::Base
has_many :quantities, :dependent => :destroy
validates_presence_of :name
validates_uniqueness_of :name, :case_sensitive => false
end
2009 Feb 28
7
be_valid (validates_format_of ..., :on => :create)
Greetings,
How to write Example which will check if model''s variable''s
format is valid using :on => :create, like this:
class User < ActiveRecord::Base
...
validates_format_of :email, :with => /.../, :on => :create
...
Using following code is not right:
it "should ..." do
@user = users(:example_user)
@user.email =
2008 Mar 18
6
Problem with mocking a simple has_many relationship
...elf.images.count
end
end
the spec:
describe Item do
before(:each) do
@item = Item.new
end
...
it "should have at least one image" do
@item.should have(1).error_on(:images)
@item.images.should_receive(:count).at_least(:once).and_return(1)
@item.should have(0).errors_on(:images)
end
end
Obviously i''m doing something wrong cause this doesn''t work:
1)
''Item should have at least one image'' FAILED
expected 0 errors on :images, got 1
./spec/models/item_spec.rb:60:
script/spec:4:
Finished in 0.341594 seconds
10 examples, 1 fail...
2007 Dec 28
1
validation of acts_as_list in the model of the base class?
...user and contains a list
of group_ids.
When I build a form to get user input and I want to save it, is there
a way to validate the presence of the child nodes in the model of
"user" so that I can permit the user to be saved only if the child
nodes are validated? I also wanted to use the errors_on etc. which
are accessible only at the model level.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@publ...
2007 May 27
12
Checking for Range
how would you check for a range using rspec?
person.password.range.should == Range.new(5..40) <- this doesn''t work
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070527/4d8cb007/attachment-0001.html
2007 May 03
1
unexpected failures with --reverse
...def valid_bill_attributes
{ :uuid => "ec5e943f-a819-433b-b786-ee847bb144e2",
:date => Date.today,
:amount => Money.new(15000) }
end
it "should have a uuid" do
bill = Bill.create(valid_bill_attributes)
bill.uuid = nil
bill.should have(2).errors_on(:uuid)
end
it "should have a uuid that is no longer than 36 characters" do
bill = Bill.create(valid_bill_attributes)
bill.uuid = bill.uuid + "1"
bill.should have(1).error_on(:uuid)
end
it "should have a uuid that is no shorter than 36 characters"...
2008 May 20
5
How to write a test for validates_uniqueness_of
Hi,
I have a spec
it "should have a unique username "
I have a code:
validates_uniqueness_of :user_name
Now, I don''t know how to test this code. In order to test this, do I
need to run `save`?
For example,
@user = User.create(:username => "mike")
@another = User.create(:username => "mike")
@another.save.should be_false
This messes up test
2007 Jun 24
6
mocking errors
What is the correct way to mock out the errors on a Rails model?
I''m assuming i need to say
@mock_thing = mock_model(Thing)
@mock_thing_errors = mock("errors")
@mock_thing_errors.should_receive(:full_messages).and_return("An error")
@mock_thing.should_receive(:errors).and_return(@mock_thing_errors)
Just wanted to check the best practice on this kind of thing and how
2007 May 31
28
Another attempt for a succinct model validation DSL
...do
> it "should reject a password of length 4" do
> User.create(:password => "1234").should have(1).error_on(:password)
> end
> it "should accept a password of length 5" do
> User.create(:password => "12345").should have(0).errors_on(:password)
> end
...
That''s pretty much exactly the pattern that I''ve been doing for
specing my model validations... I like it; I think it is the
simplest, most useful way of going about validations. But it can get
a bit wordy, and the code duplication starts to become pai...
2007 Nov 25
15
Possible Problem with RSpec and
Sorry to be such a pest but I am trying to learn Ruby, Rails and RSpec all
at one go and it is a bit overwhelming. I have previously completed the
depot tutorial in the Agile Web Dev with rails book and now I am trying do
do it again using RSpec.
What I would like to know now is why I am getting a rake failure error at
the end of every spec:models run. Is this the expected behaviour when a
test