<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html lang=‘en’ xml:lang=‘en’ xmlns=‘www.w3.org/1999/xhtml’>
<head> <title>rcov/ruby/1.8/gems/rspec-expectations-2.5.0/lib/rspec/matchers/operator_matcher.rb</title> <link href="screen.css" media="all" rel="stylesheet" type="text/css" /> <link href="print.css" media="print" rel="stylesheet" type="text/css" /> <meta http-equiv="Content-type" content="text/html;charset=UTF-8" /> <script type="text/javascript" src="rcov.js"></script> </head> <body> <h1>Rspec Steps C0 Coverage Information - RCov</h1> <h2>rcov/ruby/1.8/gems/rspec-expectations-2.5.0/lib/rspec/matchers/operator_matcher.rb</h2> <div class="report_table_wrapper"> <table class='report' id='report_table'> <thead> <tr> <th class="left_align">Name</th> <th class="right_align">Total Lines</th> <th class="right_align">Lines of Code</th> <th class="left_align">Total Coverage</th> <th class="left_align">Code Coverage</th> </tr> </thead> <tbody> <tr> <td class="left_align"><a href="rcov-ruby-1_8-gems-rspec-expectations-2_5_0-lib-rspec-matchers-operator_matcher_rb.html">rcov/ruby/1.8/gems/rspec-expectations-2.5.0/lib/rspec/matchers/operator_matcher.rb</a></td> <td class='right_align'><tt>87</tt></td> <td class='right_align'><tt>70</tt></td> <td class="left_align"><div class="percent_graph_legend"><tt class=''>70.11%</tt></div> <div class="percent_graph"> <div class="covered" style="width:70px"></div> <div class="uncovered" style="width:30px"></div> </div></td> <td class="left_align"><div class="percent_graph_legend"><tt class=''>67.14%</tt></div> <div class="percent_graph"> <div class="covered" style="width:67px"></div> <div class="uncovered" style="width:33px"></div> </div></td> </tr> </tbody> </table> </div> <h3>Key</h3> <div class="key"><pre><span class='marked'>Code reported as executed by Ruby looks like this...</span><span class='marked1'>and this: this line is also marked as covered.</span><span class='inferred'>Lines considered as run by rcov, but not reported by Ruby, look like this,</span><span class='inferred1'>and this: these lines were inferred by rcov (using simple heuristics).</span><span class='uncovered'>Finally, here's a line marked as not executed.</span></pre></div> <h3>Coverage Details</h3> <table class="details"> <tbody> <tr class="marked"> <td><pre><a name="line1">1</a> module RSpec</pre></td> </tr> <tr class="marked"> <td><pre><a name="line2">2</a> module Matchers</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line3">3</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line4">4</a> class OperatorMatcher</pre></td> </tr> <tr class="marked"> <td><pre><a name="line5">5</a> class << self</pre></td> </tr> <tr class="marked"> <td><pre><a name="line6">6</a> def registry</pre></td> </tr> <tr class="marked"> <td><pre><a name="line7">7</a> @registry ||= {}</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line8">8</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line9">9</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line10">10</a> def register(klass, operator, matcher)</pre></td> </tr> <tr class="marked"> <td><pre><a name="line11">11</a> registry[klass] ||= {}</pre></td> </tr> <tr class="marked"> <td><pre><a name="line12">12</a> registry[klass][operator] = matcher</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line13">13</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line14">14</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line15">15</a> def get(klass, operator)</pre></td> </tr> <tr class="marked"> <td><pre><a name="line16">16</a> registry[klass] && registry[klass][operator]</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line17">17</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line18">18</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line19">19</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line20">20</a> def initialize(actual)</pre></td> </tr> <tr class="marked"> <td><pre><a name="line21">21</a> @actual = actual</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line22">22</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line23">23</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line24">24</a> def self.use_custom_matcher_or_delegate(operator)</pre></td> </tr> <tr class="marked"> <td><pre><a name="line25">25</a> define_method(operator) do |expected|</pre></td> </tr> <tr class="marked"> <td><pre><a name="line26">26</a> if matcher = OperatorMatcher.get(@actual.class, operator)</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line27">27</a> @actual.send(::RSpec::Matchers.last_should, matcher.new(expected))</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line28">28</a> else</pre></td> </tr> <tr class="marked"> <td><pre><a name="line29">29</a> eval_match(@actual, operator, expected)</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line30">30</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line31">31</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line32">32</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line33">33</a> negative_operator = operator.sub(/^=/, '!')</pre></td> </tr> <tr class="marked"> <td><pre><a name="line34">34</a> if negative_operator != operator && respond_to?(negative_operator)</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line35">35</a> define_method(negative_operator) do |expected|</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line36">36</a> opposite_should = ::RSpec::Matchers.last_should == :should ? :should_not : :should</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line37">37</a> raise "RSpec does not support `#{::RSpec::Matchers.last_should} #{negative_operator} expected`. " +</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line38">38</a> "Use `#{opposite_should} #{operator} expected` instead."</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line39">39</a> end</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line40">40</a> end</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line41">41</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line42">42</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line43">43</a> ['==', '===', '=~', '>', '>=', '<', '<='].each do |operator|</pre></td> </tr> <tr class="marked"> <td><pre><a name="line44">44</a> use_custom_matcher_or_delegate operator</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line45">45</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line46">46</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line47">47</a> def fail_with_message(message)</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line48">48</a> RSpec::Expectations.fail_with(message, @expected, @actual)</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line49">49</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line50">50</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line51">51</a> def description</pre></td> </tr> <tr class="marked"> <td><pre><a name="line52">52</a> "#{@operator} #{@expected.inspect}"</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line53">53</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line54">54</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line55">55</a> private</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line56">56</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line57">57</a> def eval_match(actual, operator, expected)</pre></td> </tr> <tr class="marked"> <td><pre><a name="line58">58</a> ::RSpec::Matchers.last_matcher = self</pre></td> </tr> <tr class="marked"> <td><pre><a name="line59">59</a> @operator, @expected = operator, expected</pre></td> </tr> <tr class="marked"> <td><pre><a name="line60">60</a> __delegate_operator(actual, operator, expected)</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line61">61</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line62">62</a> </pre></td> </tr> <tr class="inferred"> <td><pre><a name="line63">63</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line64">64</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line65">65</a> class PositiveOperatorMatcher < OperatorMatcher #:nodoc:</pre></td> </tr> <tr class="marked"> <td><pre><a name="line66">66</a> def __delegate_operator(actual, operator, expected)</pre></td> </tr> <tr class="marked"> <td><pre><a name="line67">67</a> if actual.__send__(operator, expected)</pre></td> </tr> <tr class="marked"> <td><pre><a name="line68">68</a> true</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line69">69</a> elsif ['==','===', '=~'].include?(operator)</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line70">70</a> fail_with_message("expected: #{expected.inspect}\n got: #{actual.inspect} (using #{operator})") </pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line71">71</a> else</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line72">72</a> fail_with_message("expected: #{operator} #{expected.inspect}\n got: #{operator.gsub(/./, ' ')} #{actual.inspect}")</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line73">73</a> end</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line74">74</a> end</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line75">75</a> </pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line76">76</a> end</pre></td> </tr> <tr class="inferred"> <td><pre><a name="line77">77</a> </pre></td> </tr> <tr class="marked"> <td><pre><a name="line78">78</a> class NegativeOperatorMatcher < OperatorMatcher #:nodoc:</pre></td> </tr> <tr class="marked"> <td><pre><a name="line79">79</a> def __delegate_operator(actual, operator, expected)</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line80">80</a> return false unless actual.__send__(operator, expected)</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line81">81</a> return fail_with_message("expected not: #{operator} #{expected.inspect}\n got: #{operator.gsub(/./, ' ')} #{actual.inspect}")</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line82">82</a> end</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line83">83</a> </pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line84">84</a> end</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line85">85</a> </pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line86">86</a> end</pre></td> </tr> <tr class="uncovered"> <td><pre><a name="line87">87</a> end</pre></td> </tr> </tbody> </table> <p>Generated on Fri Apr 22 17:22:42 -0700 2011 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p> </body>
</html>