How does one do this? Couldn't find any examples online... (using rspec 2.5.0
& rails 3.0.5
)
Found it in shoulda-matchers
: http://rubydoc.info/github/thoughtbot/shoulda-matchers/master/frames
before(:each) do
@attr = { :bar => "foobar" }
end
it "should reject duplicate bar" do
Foo.create!(@attr)
duplicate_bar = Foo.new(@attr)
duplicate_bar.should_not be_valid
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With