changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/spec/spec/matchers/exist_spec.rb

changeset 15: 64acf98d15f4
author: moriq@moriq.com
date: Mon Mar 10 10:12:58 2008 +0900 (16 years ago)
permissions: -rw-r--r--
description: add plugins rspec
1require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
3class Substance
4 def initialize exists, description
5 @exists = exists
6 @description = description
7 end
8 def exist?
9 @exists
10 end
11 def inspect
12 @description
13 end
14end
15
16class SubstanceTester
17 include Spec::Matchers
18 def initialize substance
19 @substance = substance
20 end
21 def should_exist
22 @substance.should exist
23 end
24end
25
26describe "should exist," do
27
28 before(:each) do
29 @real = Substance.new true, 'something real'
30 @imaginary = Substance.new false, 'something imaginary'
31 end
32
33 describe "within an example group" do
34
35 it "should pass if target exists" do
36 @real.should exist
37 end
38
39 it "should fail if target does not exist" do
40 lambda { @imaginary.should exist }.should fail
41 end
42
43 it "should pass if target doesn't exist" do
44 lambda { @real.should_not exist }.should fail
45 end
46 end
47
48 describe "outside of an example group" do
49
50 it "should pass if target exists" do
51 real_tester = SubstanceTester.new @real
52 real_tester.should_exist
53 end
54
55 end
56
57end