Upgraded Rails and RSpec
[monkeycharger.git] / vendor / plugins / rspec / rspec / spec / spec / story / rspec_adapter.rb
blob1f9a13f173ee85489a5c8e6a632d6c4aa08806bf
1 # TODO: get rid of this file. It breaks with the style in the rest of our code. (AH)
3 # add ensure_that(..)
4 module Spec::Expectations::ObjectExpectations
5   def ensure_that(obj, expr)
6     obj.should expr
7   end
8 end
10 def exception_from(&block)
11   exception = nil
12   begin
13     yield
14   rescue StandardError => e
15     exception = e
16   end
17   exception
18 end
20 # simplify matchers
23 # custom matchers
25 def contain(string)
26   return simple_matcher(%[string containing "#{string}"]) do |actual|
27     actual.include? string
28   end
29 end
31 alias :contains :contain
33 def is(expected)
34   return simple_matcher("equal to #{expected}") do |actual| actual == expected end
35 end
37 alias :are :is
39 def is_a(type)
40   return simple_matcher("object of type #{type}") do |actual|
41     actual.is_a? type
42   end
43 end
45 alias :is_an :is_a
47 def matches(pattern)
48   return simple_matcher("string matching #{pattern}") do |actual|
49     actual =~ pattern
50   end
51 end