lib/attestor/rspec.rb in attestor-2.1.0 vs lib/attestor/rspec.rb in attestor-2.2.0
- old
+ new
@@ -6,18 +6,24 @@
# Helpers for validations
module RSpec
include ::RSpec::Mocks::ExampleMethods
# Mocks a valid object
+ #
+ # @return [RSpec::Mocks::Double]
def valid_spy
object = spy
allow(object).to receive(:validate!)
allow(object).to receive(:validate) { Report.new(object) }
object
end
- # Mocks an invalid object
+ # Mocks an invalid object with given error messages
+ #
+ # @param [String, Array<String>] messages
+ #
+ # @return [RSpec::Mocks::Double]
def invalid_spy(messages = "invalid")
object = spy
error = InvalidError.new(object, messages)
allow(object).to receive(:validate!) { fail error }
allow(object).to receive(:validate) { Report.new(object, error) }