Closed sha1sum closed 9 years ago
This creates something similar to the following for :unless
conditions (without the comments):
context "with conditions" do
# given "validates :termination_date, presence: true, unless: :third_party?"
before do
allow(subject).to receive(:third_party?).and_return(false)
end
it { is_expected.to validate_presence_of :termination_date }
end
... and the following for :if
conditions:
context "with conditions" do
# given "validates :manager_id, presence: true, if: :third_party?"
before do
allow(subject).to receive(:third_party?).and_return(true)
end
it { is_expected.to validate_presence_of :manager_id }
end
Awesome! I will merge this pull request and ad it to the next version 0.5.9 for rubygems which i plan to release next week. I will play with this a little bit today.
Thanks :)
:if and :unless conditions on ActiveRecord validations now create "context" blocks and mock the boolean response as long as the if condition is a symbol.
Resolves #10