search for: uniqueness_of

Displaying 5 results from an estimated 5 matches for "uniqueness_of".

2005 Aug 19
2
data validation
...t;''company_id'' has_and_belongs_to_many :categories, :join_table => ''company_to_category'', :foreign_key => ''company_id'', :association_foreign_key => ''category_id'' validates_presence_of :name validates_uniqueness_of :name validates_lenght_of :name, :maximum => "20" ,:message => "too long" end The presence_of and the uniqueness_of work fine, but it doesn''t throw any error when the name atribute is longer than 20.. Is there any problem with it? Can I combine va...
2008 Mar 02
0
Models are not initialised correctly with ''rake test'' in Merb 0.9.1
I''m using Sequel as my ORM and Test::Unit as my testing framework and have the following model: class Item < Sequel::Model validates do presence_of( :name, :uuid, :vendor_id, :vendor_reference, :amount, :currency_code ) uniqueness_of( :uuid ) end def initialize( *args ) super( *args ) self.uuid = UUID.random_create.to_s end end As you can see I overwrite initialize to set up the UUID when the model is instantiated. In my tests I have the following method which sets up an Item: def generate_valid_new_item it...
2008 Mar 14
5
Branching scenarios, GivenScenario and database
I''m trying to use stories to drive some high-level design. I''ve got some branching scenarios where I want to follow a scenario, to establish a base situation, and then have different scenarios which ''branch'' out from that state, possibly several levels deep. I asked a bit about this a few days ago, and David pointed out the rather undocumented GivenScenario
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, :scope =>...
2007 May 05
10
have_one and have_present
>Comment By: Luis Lavena (luislavena) > Date: 2007-05-04 23:37 > describe "An Asset" do > before(:each) do > @asset = Asset.new > end > > it { @asset.should have_one(:attachment) } > it { @asset.should have_present(:something) } > end Food for thought on these. I like have_one a lot. It speaks to me as a Rails developer and I think it speaks to