Geminstaller C0 Coverage Information - RCov

/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/matchers.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
/Users/woolley/.rvm/gems/ruby-1.8.7-p174@geminstaller/gems/rspec-1.3.0/lib/spec/matchers.rb 214 31
100.00%
100.00%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 require 'spec/extensions/instance_exec'
2 require 'spec/matchers/pretty'
3 require 'spec/matchers/matcher'
4 require 'spec/matchers/operator_matcher'
5 require 'spec/matchers/be'
6 require 'spec/matchers/be_close'
7 require 'spec/matchers/be_instance_of'
8 require 'spec/matchers/be_kind_of'
9 require 'spec/matchers/change'
10 require 'spec/matchers/eql'
11 require 'spec/matchers/equal'
12 require 'spec/matchers/errors'
13 require 'spec/matchers/exist'
14 require 'spec/matchers/generated_descriptions'
15 require 'spec/matchers/has'
16 require 'spec/matchers/have'
17 require 'spec/matchers/include'
18 require 'spec/matchers/match'
19 require 'spec/matchers/match_array'
20 require 'spec/matchers/method_missing'
21 require 'spec/matchers/raise_exception'
22 require 'spec/matchers/respond_to'
23 require 'spec/matchers/satisfy'
24 require 'spec/matchers/simple_matcher'
25 require 'spec/matchers/throw_symbol'
26 require 'spec/matchers/wrap_expectation'
27 require 'spec/matchers/compatibility'
28 require 'spec/matchers/dsl'
29 
30 module Spec
31 
32   # RSpec ships with a number of useful Expression Matchers. An Expression Matcher
33   # is any object that responds to the following methods:
34   #
35   #   matches?(actual)
36   #   failure_message_for_should
37   #
38   # These methods are also part of the matcher protocol, but are optional:
39   #
40   #   does_not_match?(actual)
41   #   failure_message_for_should_not
42   #   description #optional
43   #
44   # These methods are from older versions of the protocol. They are still supported,
45   # but are not recommended:
46   #
47   #   failure_message          (use failure_message_for_should instead)
48   #   negative_failure_message (use failure_message_for_should_not instead)
49   #
50   # See Spec::Expectations to learn how to use these as Expectation Matchers.
51   #
52   # == Predicates
53   #
54   # In addition to those Expression Matchers that are defined explicitly, RSpec will
55   # create custom Matchers on the fly for any arbitrary predicate, giving your specs
56   # a much more natural language feel. 
57   #
58   # A Ruby predicate is a method that ends with a "?" and returns true or false.
59   # Common examples are +empty?+, +nil?+, and +instance_of?+.
60   #
61   # All you need to do is write +should be_+ followed by the predicate without
62   # the question mark, and RSpec will figure it out from there. For example:
63   #
64   #   [].should be_empty => [].empty? #passes
65   #   [].should_not be_empty => [].empty? #fails
66   #
67   # In addtion to prefixing the predicate matchers with "be_", you can also use "be_a_"
68   # and "be_an_", making your specs read much more naturally:
69   #
70   #   "a string".should be_an_instance_of(String) =>"a string".instance_of?(String) #passes
71   #
72   #   3.should be_a_kind_of(Fixnum) => 3.kind_of?(Numeric) #passes
73   #   3.should be_a_kind_of(Numeric) => 3.kind_of?(Numeric) #passes
74   #   3.should be_an_instance_of(Fixnum) => 3.instance_of?(Fixnum) #passes
75   #   3.should_not be_instance_of(Numeric) => 3.instance_of?(Numeric) #fails
76   #
77   # RSpec will also create custom matchers for predicates like +has_key?+. To
78   # use this feature, just state that the object should have_key(:key) and RSpec will
79   # call has_key?(:key) on the target. For example:
80   #
81   #   {:a => "A"}.should have_key(:a) => {:a => "A"}.has_key?(:a) #passes
82   #   {:a => "A"}.should have_key(:b) => {:a => "A"}.has_key?(:b) #fails
83   #
84   # You can use this feature to invoke any predicate that begins with "has_", whether it is
85   # part of the Ruby libraries (like +Hash#has_key?+) or a method you wrote on your own class.
86   #
87   # == Custom Matchers
88   #
89   # When you find that none of the stock Expectation Matchers provide a natural
90   # feeling expectation, you can very easily write your own using RSpec's matcher
91   # DSL or writing one from scratch.
92   #
93   # === Matcher DSL
94   #
95   # Imagine that you are writing a game in which players can be in various
96   # zones on a virtual board. To specify that bob should be in zone 4, you
97   # could say:
98   #
99   #   bob.current_zone.should eql(Zone.new("4"))
100   #
101   # But you might find it more expressive to say:
102   #
103   #   bob.should be_in_zone("4")
104   #
105   # and/or
106   #
107   #   bob.should_not be_in_zone("3")
108   #
109   # You can create such a matcher like so:
110   #
111   #   Spec::Matchers.define :be_in_zone do |zone|
112   #     match do |player|
113   #       player.in_zone?(zone)
114   #     end
115   #   end
116   #
117   # This will generate a <tt>be_in_zone</tt> method that returns a matcher
118   # with logical default messages for failures. You can override the failure
119   # messages and the generated description as follows:
120   #
121   #   Spec::Matchers.define :be_in_zone do |zone|
122   #     match do |player|
123   #       player.in_zone?(zone)
124   #     end
125   #     failure_message_for_should do |player|
126   #       # generate and return the appropriate string.
127   #     end
128   #     failure_message_for_should_not do |player|
129   #       # generate and return the appropriate string.
130   #     end
131   #     description do
132   #       # generate and return the appropriate string.
133   #     end
134   #   end
135   #
136   # Each of the message-generation methods has access to the block arguments
137   # passed to the <tt>create</tt> method (in this case, <tt>zone</tt>). The
138   # failure message methods (<tt>failure_message_for_should</tt> and
139   # <tt>failure_message_for_should_not</tt>) are passed the actual value (the
140   # receiver of <tt>should</tt> or <tt>should_not</tt>).
141   #
142   # You can also create matchers that obey a fluent interface using the
143   # <tt>chain</tt> method:
144   #
145   #   Spec::Matchers.define :tip do |expected_tip|
146   #     chain :on do |bill|
147   #       @bill = bill
148   #     end
149   #
150   #     match do |person|
151   #       person.tip_for(bill) == expected_tip
152   #     end
153   #   end
154   #
155   # This matcher can be used as follows:
156   #
157   #   describe Customer do
158   #     it { should tip(10).on(50 }
159   #   end
160   #
161   # === Custom Matcher from scratch
162   #
163   # You could also write a custom matcher from scratch, as follows:
164   #
165   #   class BeInZone
166   #     def initialize(expected)
167   #       @expected = expected
168   #     end
169   #     def matches?(target)
170   #       @target = target
171   #       @target.current_zone.eql?(Zone.new(@expected))
172   #     end
173   #     def failure_message_for_should
174   #       "expected #{@target.inspect} to be in Zone #{@expected}"
175   #     end
176   #     def failure_message_for_should_not
177   #       "expected #{@target.inspect} not to be in Zone #{@expected}"
178   #     end
179   #   end
180   #
181   # ... and a method like this:
182   #
183   #   def be_in_zone(expected)
184   #     BeInZone.new(expected)
185   #   end
186   #
187   # And then expose the method to your specs. This is normally done
188   # by including the method and the class in a module, which is then
189   # included in your spec:
190   #
191   #   module CustomGameMatchers
192   #     class BeInZone
193   #       ...
194   #     end
195   #
196   #     def be_in_zone(expected)
197   #       ...
198   #     end
199   #   end
200   #
201   #   describe "Player behaviour" do
202   #     include CustomGameMatchers
203   #     ...
204   #   end
205   #
206   # or you can include in globally in a spec_helper.rb file <tt>require</tt>d
207   # from your spec file(s):
208   #
209   #   Spec::Runner.configure do |config|
210   #     config.include(CustomGameMatchers)
211   #   end
212   #
213   module Matchers; end
214 end

Generated on Mon May 10 23:40:27 -0700 2010 with rcov 0.9.8