]> git.openstreetmap.org Git - rails.git/blob - vendor/gems/rspec-1.1.2/spec/spec/matchers/has_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 / has_spec.rb
1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
2
3 describe "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
19 end
20
21 describe "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
37 end