changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/spec/spec/matchers/respond_to_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 respond_to(:sym)" do
4
5 it "should pass if target responds to :sym" do
6 Object.new.should respond_to(:methods)
7 end
8
9 it "should fail target does not respond to :sym" do
10 lambda {
11 Object.new.should respond_to(:some_method)
12 }.should fail_with("expected target to respond to :some_method")
13 end
14
15end
16
17describe "should respond_to(message1, message2)" do
18
19 it "should pass if target responds to both messages" do
20 Object.new.should respond_to('methods', 'inspect')
21 end
22
23 it "should fail target does not respond to first message" do
24 lambda {
25 Object.new.should respond_to('method_one', 'inspect')
26 }.should fail_with('expected target to respond to "method_one"')
27 end
28
29 it "should fail target does not respond to second message" do
30 lambda {
31 Object.new.should respond_to('inspect', 'method_one')
32 }.should fail_with('expected target to respond to "method_one"')
33 end
34
35 it "should fail target does not respond to either message" do
36 lambda {
37 Object.new.should respond_to('method_one', 'method_two')
38 }.should fail_with('expected target to respond to "method_one", "method_two"')
39 end
40end
41
42describe "should_not respond_to(:sym)" do
43
44 it "should pass if target does not respond to :sym" do
45 Object.new.should_not respond_to(:some_method)
46 end
47
48 it "should fail target responds to :sym" do
49 lambda {
50 Object.new.should_not respond_to(:methods)
51 }.should fail_with("expected target not to respond to :methods")
52 end
53
54end