search for: error_on

Displaying 20 results from an estimated 20 matches for "error_on".

Did you mean: error_or
2009 Mar 23
3
Spec::Rails, "model.should have(1).error_on(:attribute)" passes when?
Spec::Rails people, I''m curious about: - model.should have(1).error_on(:attribute) displayed in the URL below: http://rspec.rubyforge.org/rspec-rails/1.2.2/classes/Spec/Rails/Extensions/ActiveRecord/InstanceMethods.html The Rspec peepcode screencast suggests that model.should have(1).error_on(:attribute) should pass if model.send(:attribute) returns nil For me, I...
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 deprecated, or is it just the old should_have? T...
2009 Mar 23
0
Spec::Rails, "model.should have(1).error_on(:attribute)" passes when?
Spec::Rails people, I''m curious about: - model.should have(1).error_on(:attribute) displayed in the URL below: http://rspec.rubyforge.org/rspec-rails/1.2.2/classes/Spec/Rails/Exten... The Rspec peepcode screencast suggests that model.should have(1).error_on(:attribute) should pass if model.send(:attribute) returns nil For me, I get an exception from the rspec script...
2007 May 03
1
unexpected failures with --reverse
...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" do bill = Bill.create(valid_bill_attributes) bill.uuid = bill.uuid[0..34] bill.should have(1).error_on(:uuid) end it "should have a case-insensitive, unique uuid" do bill = Bill.cr...
2009 Mar 23
5
Rspec weird behaviour
...s Size < ActiveRecord::Base has_many :quantities, :dependent => :destroy validates_presence_of :name validates_uniqueness_of :name, :case_sensitive => false end and this is the faulty spec: it ''new size should have an error on name'' do Size.new.should have(1).error_on(:name) end the red response is: ''new size should have an error on name'' FAILED expected 1 error on :name, got 0 if I change the spec to read like this: Size.new.should have(:no).error_on(:name) I still get a red response: ''new size should have an error on name...
2007 Dec 17
14
Change in isolation behaviour 1.08 - 1.10 ?
...fname => ''bert'', :lname => ''valid'', :jobtitle => "programmer" ) end it "should have a unique email address" do @valid_user.save.should == true @user.email = @valid_user.email @user.should have(1).error_on(:email) end it "should allow two users with the same name" do @valid_user.save.should == true @user.fname = @valid_user.fname @user.lname = @valid_user.lname @user.should have(:no).error_on(:fname) @user.should have(:no).error_on(:lname) end end The second...
2007 Aug 18
0
RSpec and acts_as_attachment
...assert user_file.errors.on(:size) assert user_file.errors.on(:content_type) end end # Converting the above to the following spec it ''should be invalid without file'' do @user_file = create_user_file :uploaded_data => nil @user_file.should have(1).error_on(:filename) @user_file.should have(1).error_on(:size) @user_file.should have(1).error_on(:content_type) end # The spec fails with the following error # ============ should be invalid without file wrong number of arguments (0 for 1) vendor/plugins/acts_as_attachment/lib/technoweenie/ac...
2010 Aug 11
6
rspec2 not working with shoulda
I am using rails edge. I am using gem "rspec-rails", "= 2.0.0.beta. 19" . I have following code at spec/models/user_spec.rb require ''spec_helper'' describe User do it { should validate_presence_of(:email) } it { should validate_presence_of(:name) } end Here is my gemfile group :development, :test do gem ''factory_girl_rails'',
2008 Mar 18
6
Problem with mocking a simple has_many relationship
...dent => :destroy ... protected def validate errors.add(:images, "cannot be empty") if self.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...
2007 Jul 26
3
Spec for validation plugin
...del spec I want something like this (assume @location has been setup as a new Location instance): it "should be invalid if the post code is incorrectly formatted" do @location.post_code => ''Q1 1QQ'' @location.should_not be_valid @location.should have(1).error_on(:post_code) end But there are many examples of invalid post codes and they are already tested in the plugin''s own test cases. I only really want to test my code, rather than retest the plugin. So my question is how should I write the specification so that it doesn''t duplica...
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/.
2008 Jan 23
6
sharing specs in a subclass
Hi I''ve spec''d a class and they pass. Now I''d like to assure that any subclass of this class also passes the same specs. Any suggestions for a clever way to handle this? I''d prefer to keep the existing specs as is (eg instead of moving everything into shared behaviors, or doing something to all the ''describe'' lines) thanks linoj
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 Nov 09
9
fixture_file_upload and edge rspec?
...=> fixture_file_upload(''/textfile.txt'', ''text/plain'')}) @image.should_not be_valid # content_type: is not included in the list @image.should have(1).error_on(:content_type) end which fails with: 2) NoMethodError in ''Image unsaved should be invalid if uploaded file is not an image'' You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.+ ./spec/m...
2008 Aug 25
21
How much test data to use in specs
I''m not sure how much test data I should be using in my specs. I''m writing specs for the Property model in my Rails app. Its "address" attribute is going to be validated with this regex: /\A\d+[a-z]? [-'', a-z]{2,128}\Z/i At the moment, my plan is to spec out the following possibilities. A property is invalid if its address: 1) doesn''t begin with
2006 Feb 13
2
How can I put the error messages generated by the validation routines into it''s own side frame and how can a click on a error message take me right to the error?
Hello, I''m a newbie, coming from Visual FoxPro - a database centric and object orientated scripting language with a rich set of graphical user interface controlls. Lerning ruby on rails means for me to lern html as well. But now to my problem: The validation errors are listed at the top of the page without any order. Depending on the size of the form and the numbers of errors
2007 Sep 20
10
Getting Started with Story Runner
I haven''t found any How To''s to use story runner and I''m not sure how to get started. Should I be looking for resources on how to use rbehave? How do I generate my first Story? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070920/07a80bc7/attachment.html
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
2007 May 31
28
Another attempt for a succinct model validation DSL
...behave when this requirement is violated, and then specify that it > behaves that way. > > Here''s how I might handle this: > > describe User 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 validati...
2007 Jul 24
11
Mock or Stub strategy for validates_uniqueness_of
Hi, I''m a bit stuck with mocking a unit test of a join model with regards to a validates_uniqueness_of clause. I have class Book < AR:B has_many :clippings various validates_presence_of etc end class Clip < AR:B has_many :clippings various validates_presence_of etc end class Clipping < AR:B belongs_to :book belongs_to :clip validates_uniqueness_of :clip_id,