Joined July 2012
·

Harm-Jan Blok

Netherlands
·
·

What about using shoulda matchers? They have a matcher which does essentially the same (validate an attribute can't be blank).

it { should validate_presence_of(:name) }

You could combine this with a Factory which has all default values and test if this Factory is valid:

FactoryGirl.define do
  factory :my_model do
    name "Foo"
  end
end

let(:my_model) { FactoryGirl.create(:my_model) }
it { my_model.should be_valid }
Achievements
29 Karma
0 Total ProTip Views
Interests & Skills