]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/spec/spec/matchers/include_spec.rb
f1057f3fddd50e18c5a48ca230e48f5b1ff7dcd1
[rails.git] / vendor / gems / rspec-1.1.2 / spec / spec / matchers / include_spec.rb
1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
3 describe "should include(expected)" do
4   it "should pass if target includes expected" do
5     [1,2,3].should include(3)
6     "abc".should include("a")
7   end
8
9   it "should fail if target does not include expected" do
10     lambda {
11       [1,2,3].should include(4)
12     }.should fail_with("expected [1, 2, 3] to include 4")
13     lambda {
14       "abc".should include("d")
15     }.should fail_with("expected \"abc\" to include \"d\"")
16   end
17 end
18
19 describe "should include(with, multiple, args)" do
20   it "should pass if target includes all items" do
21     [1,2,3].should include(1,2,3)
22   end
23
24   it "should fail if target does not include any one of the items" do
25     lambda {
26       [1,2,3].should include(1,2,4)
27     }.should fail_with("expected [1, 2, 3] to include 1, 2 and 4")
28   end
29 end
30
31 describe "should_not include(expected)" do
32   it "should pass if target does not include expected" do
33     [1,2,3].should_not include(4)
34     "abc".should_not include("d")
35   end
36
37   it "should fail if target includes expected" do
38     lambda {
39       [1,2,3].should_not include(3)
40     }.should fail_with("expected [1, 2, 3] not to include 3")
41     lambda {
42       "abc".should_not include("c")
43     }.should fail_with("expected \"abc\" not to include \"c\"")
44   end
45 end