Skip to content

Commit

Permalink
Test for matcher error text instead
Browse files Browse the repository at this point in the history
  • Loading branch information
tubbo committed Dec 5, 2012
1 parent 5791280 commit 566dc22
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions spec/rspec/rails/matchers/be_valid_spec.rb
Expand Up @@ -10,19 +10,12 @@ class TestModel
validates_presence_of :something
end

let(:matcher) { be_valid }
subject { TestModel.new }

it "passes the matcher when valid" do
subject.something = "something"
it "includes validation errors by default" do
matcher.matches? subject

subject.should be_valid
expect(subject).to be_valid
end

it "fails the matcher when not valid" do
subject.something = nil

subject.should_not be_valid
expect(subject).to_not be_valid
matcher.failure_message_for_should.should =~ /is blank/
end
end

0 comments on commit 566dc22

Please sign in to comment.