public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Search Repo:
merb-core / spec / spec_helper.rb
100644 68 lines (53 sloc) 1.392 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
$TESTING=true
require "rubygems"
require "spec"
require File.join(File.dirname(__FILE__), "..", "lib", "merb-core")
 
Merb.start :environment => 'test', :adapter => 'runner'
 
# -- Global custom matchers --
 
# A better +be_kind_of+ with more informative error messages.
#
# The default +be_kind_of+ just says
#
# "expected to return true but got false"
#
# This one says
#
# "expected File but got Tempfile"
 
module Merb
  module Test
    module RspecMatchers
      class BeKindOf
        def initialize(expected) # + args
          @expected = expected
        end
 
        def matches?(target)
          @target = target
          @target.kind_of?(@expected)
        end
 
        def failure_message
          "expected #{@expected} but got #{@target.class}"
        end
 
        def negative_failure_message
          "expected #{@expected} to not be #{@target.class}"
        end
 
        def description
          "be_kind_of #{@target}"
        end
      end
 
      def be_kind_of(expected) # + args
        BeKindOf.new(expected)
      end
    end
 
    module Helper
      def running(&blk) blk; end
 
      def executing(&blk) blk; end
 
      def doing(&blk) blk; end
 
      def calling(&blk) blk; end
    end
  end
end
 
 
Spec::Runner.configure do |config|
  config.include Merb::Test::Helper
  config.include Merb::Test::RspecMatchers
  config.include Merb::Test::RequestHelper
end