[rspec-users] should validate_numericality_of with greater_than_or_equal_to

2011-09-03 Thread slavix
Hello, I have this in my spec it { should validate_numericality_of(:amount).greater_than_or_equal_to(0) } but I get error: Failure/Error: it { should validate_numericality_of(:amount).greater_than_or_equal_to(0) } NoMethodError: undefined method `greater_than_or_equal_to' for # t

Re: [rspec-users] rspec assert inclusion in..

2011-09-03 Thread slavix
Thanks. I wanted to test it as part of model validation like it { should validate_presence_of(:some_attribute).among(['value1', 'value2']) } it { should validate_that(:some_attribute) >= 0 } On Sep 3, 6:42 pm, Nick wrote: > Hey Slavix. How about this: > > it 'has a valid "attribute_x" v

Re: [rspec-users] rspec assert inclusion in..

2011-09-03 Thread slavix
this seems to be the way to do it. it { should_validate_numericality_of :amount, :greater_than_or_equal_to => 0 } it { should_validate_inclusion_of :gender, :in => %w( m f ) On Sep 3, 6:42 pm, Nick wrote: > Hey Slavix. How about this: > > it 'has a valid "attribute_x" value' do >   valid

Re: [rspec-users] rspec assert inclusion in..

2011-09-03 Thread Nick
Hey Slavix. How about this: it 'has a valid "attribute_x" value' do valid_values = %w(some values here) valid_values.should include subject.attribute_x end ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/r

Re: [rspec-users] rspec and shoulda have_indices

2011-09-03 Thread slavix
Yes. Thank you. I changed the code to list indices one at a time and it worked. it { should have_db_index(:currency_id) } it { should have_db_index(:user_id) } On Sep 3, 5:38 am, Michael Guterl wrote: > My guess is that it is checking for an compound index on all of those > fields.  Tr

[rspec-users] rspec assert inclusion in..

2011-09-03 Thread slavix
hello, I would like to assert that an attribute of a model has value among those in an array. How would I do it in rspec? Something like this... describe OptionType do context "shoulda validations" do it { assert_contains :type, ['Type1', 'Type1']} end end

Re: [rspec-users] What causes "undefined method `each_pair'"?

2011-09-03 Thread David Chelimsky
On Sep 3, 2011, at 5:29 AM, Katrina Owen wrote: > Hi, > > On Mon, Aug 29, 2011 at 5:33 PM, Nick wrote: >> Hey folks. I've been running into this problem a lot lately, and haven't >> been able to figure out what's causing it, nor how to fix it: >> Failure/Error: @importer = SpreadsheetImporter.ne

Re: [rspec-users] rspec and shoulda have_indices

2011-09-03 Thread Michael Guterl
My guess is that it is checking for an compound index on all of those fields. Try specifying them individually and not in an array. On Fri, Sep 2, 2011 at 7:07 PM, slavix wrote: > now getting > Failure/Error: it { should > have_db_index([:user, :currency, :tradable]) } >       Expected Balance t