changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/spec/spec/matchers/include_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
3describe "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
17end
18
19describe "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
29end
30
31describe "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
45end