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

[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