summaryrefslogtreecommitdiff
path: root/spec/mspec/lib/mspec/expectations/expectations.rb
blob: cfdc2b63a3d63c211d4fc17b78a7ceeed8dfa7ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class SpecExpectationNotMetError < StandardError
end

class SpecExpectationNotFoundError < StandardError
  def message
    "No behavior expectation was found in the example"
  end
end

class SpecExpectation
  def self.fail_with(expected, actual)
    expected_to_s = expected.to_s
    actual_to_s = actual.to_s
    if expected_to_s.size + actual_to_s.size > 80
      message = "#{expected_to_s.chomp}\n#{actual_to_s}"
    else
      message = "#{expected_to_s} #{actual_to_s}"
    end
    Kernel.raise SpecExpectationNotMetError, message
  end
end