Skip to content

Commit c0acfec

Browse files
lulalalaJonRowe
authored andcommitted
Fix errors#blank? when save is stubbed to false
Sync with empty?
1 parent 92c4b4f commit c0acfec

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

lib/rspec/active_model/mocks/mocks.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def self.param_delimiter; "-"; end
147147
[:save, :update_attributes, :update].each do |key|
148148
if stubs[key] == false
149149
RSpec::Mocks.allow_message(m.errors, :empty?).and_return(false)
150+
RSpec::Mocks.allow_message(m.errors, :blank?).and_return(false)
150151
end
151152
end
152153
end

spec/rspec/active_model/mocks/mock_model_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,23 @@
8181
it "is empty" do
8282
model = mock_model(MockableModel)
8383
expect(model.errors).to be_empty
84+
expect(model.errors).to be_blank
8485
end
8586
end
8687

8788
context "with :save => false" do
8889
it "is not empty" do
8990
model = mock_model(MockableModel, :save => false)
9091
expect(model.errors).not_to be_empty
92+
expect(model.errors).not_to be_blank
9193
end
9294
end
9395

9496
context "with :update_attributes => false" do
9597
it "is not empty" do
9698
model = mock_model(MockableModel, :save => false)
9799
expect(model.errors).not_to be_empty
100+
expect(model.errors).not_to be_blank
98101
end
99102
end
100103
end

0 commit comments

Comments
 (0)