changelog shortlog tags changeset manifest revisions annotate raw

vendor/plugins/rspec/spec/spec/matchers/has_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 have_sym(*args)" do
4 it "should pass if #has_sym?(*args) returns true" do
5 {:a => "A"}.should have_key(:a)
6 end
7
8 it "should fail if #has_sym?(*args) returns false" do
9 lambda {
10 {:b => "B"}.should have_key(:a)
11 }.should fail_with("expected #has_key?(:a) to return true, got false")
12 end
13
14 it "should fail if target does not respond to #has_sym?" do
15 lambda {
16 Object.new.should have_key(:a)
17 }.should raise_error(NoMethodError)
18 end
19end
20
21describe "should_not have_sym(*args)" do
22 it "should pass if #has_sym?(*args) returns false" do
23 {:a => "A"}.should_not have_key(:b)
24 end
25
26 it "should fail if #has_sym?(*args) returns true" do
27 lambda {
28 {:a => "A"}.should_not have_key(:a)
29 }.should fail_with("expected #has_key?(:a) to return false, got true")
30 end
31
32 it "should fail if target does not respond to #has_sym?" do
33 lambda {
34 Object.new.should have_key(:a)
35 }.should raise_error(NoMethodError)
36 end
37end