]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/spec/spec/matchers/exist_spec.rb
Show whether a trace is public or private in the trace list, so that a user can easil...
[rails.git] / vendor / gems / rspec-1.1.2 / spec / spec / matchers / exist_spec.rb
1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
3 class 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
14 end
15   
16 class SubstanceTester
17   include Spec::Matchers
18   def initialize substance
19     @substance = substance
20   end
21   def should_exist
22     @substance.should exist
23   end
24 end
25
26 describe "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
57 end