Sha256: 4b7c784cec5b66f57547c47f06644dd897bde8c92d6cc177b5cd70fff71e8218
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe 'validate_presence_of' do include ModelBuilder # Defines a model, create a validation and returns a raw matcher def define_and_validate(options={}) @model = define_model :product, :title => :string, :size => :string, :category => :string do validates_presence_of :title, :size, options end validate_presence_of(:title, :size) end describe 'messages' do before(:each){ @matcher = define_and_validate } it 'should contain a description' do @matcher.description.should == 'require title and size to be set' end it 'should set allow_nil? message' do @matcher = validate_presence_of(:category) @matcher.matches?(@model) @matcher.failure_message.should == 'Expected Product to require category to be set' @matcher.negative_failure_message.should == 'Did not expect Product to require category to be set' end end describe 'matchers' do describe 'without options' do before(:each){ define_and_validate } it { should validate_presence_of(:size) } it { should validate_presence_of(:title) } it { should validate_presence_of(:title, :size) } it { should_not validate_presence_of(:category) } end create_message_specs(self) end describe 'macros' do before(:each){ define_and_validate } should_validate_presence_of(:size) should_validate_presence_of(:title) should_validate_presence_of(:size, :title) should_not_validate_presence_of(:category) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
remarkable_activerecord-3.0.0 | spec/validate_presence_of_matcher_spec.rb |
remarkable_activerecord-3.0.1 | spec/validate_presence_of_matcher_spec.rb |