coverage/index.html in ruby-enum-0.9.0 vs coverage/index.html in ruby-enum-1.0.0
- old
+ new
@@ -12,11 +12,11 @@
<body>
<div id="loading">
<img src="./assets/0.12.3/loading.gif" alt="loading"/>
</div>
<div id="wrapper" class="hide">
- <div class="timestamp">Generated <abbr class="timeago" title="2021-01-31T14:34:10-05:00">2021-01-31T14:34:10-05:00</abbr></div>
+ <div class="timestamp">Generated <abbr class="timeago" title="2024-01-10T11:54:41+01:00">2024-01-10T11:54:41+01:00</abbr></div>
<ul class="group_tabs"></ul>
<div id="content">
<div class="file_list_container" id="AllFiles">
<h2>
@@ -28,25 +28,25 @@
</span>
covered at
<span class="covered_strength">
<span class="green">
- 3.01
+ 2.61
</span>
</span> hits/line
)
</h2>
<a name="AllFiles"></a>
<div>
- <b>7</b> files in total.
+ <b>10</b> files in total.
</div>
<div class="t-line-summary">
- <b>119</b> relevant lines,
- <span class="green"><b>119</b> lines covered</span> and
+ <b>326</b> relevant lines,
+ <span class="green"><b>326</b> lines covered</span> and
<span class="red"><b>0</b> lines missed. </span>
(<span class="green">
100.0%
</span>
)
@@ -69,78 +69,111 @@
</tr>
</thead>
<tbody>
<tr class="t-file">
- <td class="strong t-file__name"><a href="#ee900552ffcf61e4cbcb7de088bb27ce8e102d72" class="src_link" title="lib/ruby-enum.rb">lib/ruby-enum.rb</a></td>
+ <td class="strong t-file__name"><a href="#1aefb18cee22848cb7bcee850bb07481c7b45c07" class="src_link" title="lib/ruby-enum.rb">lib/ruby-enum.rb</a></td>
<td class="green strong cell--number t-file__coverage">100.00 %</td>
- <td class="cell--number">13</td>
- <td class="cell--number">8</td>
- <td class="cell--number">8</td>
+ <td class="cell--number">25</td>
+ <td class="cell--number">11</td>
+ <td class="cell--number">11</td>
<td class="cell--number">0</td>
<td class="cell--number">1.00</td>
</tr>
<tr class="t-file">
- <td class="strong t-file__name"><a href="#5d0cbf07eac0368481292a8c6bf5e85f636264b0" class="src_link" title="lib/ruby-enum/enum.rb">lib/ruby-enum/enum.rb</a></td>
+ <td class="strong t-file__name"><a href="#800d8a6c9d9672ce1ce0149e00493d33a8a8109e" class="src_link" title="lib/ruby-enum/enum.rb">lib/ruby-enum/enum.rb</a></td>
<td class="green strong cell--number t-file__coverage">100.00 %</td>
- <td class="cell--number">171</td>
- <td class="cell--number">67</td>
- <td class="cell--number">67</td>
+ <td class="cell--number">174</td>
+ <td class="cell--number">68</td>
+ <td class="cell--number">68</td>
<td class="cell--number">0</td>
- <td class="cell--number">3.91</td>
+ <td class="cell--number">5.54</td>
</tr>
<tr class="t-file">
- <td class="strong t-file__name"><a href="#8f10848d362db72f4a966812244e1a180d9c0a87" class="src_link" title="lib/ruby-enum/errors/base.rb">lib/ruby-enum/errors/base.rb</a></td>
+ <td class="strong t-file__name"><a href="#9d611104d8095a2ddd3f1e7bffc9ed21a58e762a" class="src_link" title="lib/ruby-enum/enum/case.rb">lib/ruby-enum/enum/case.rb</a></td>
<td class="green strong cell--number t-file__coverage">100.00 %</td>
+ <td class="cell--number">84</td>
+ <td class="cell--number">29</td>
+ <td class="cell--number">29</td>
+ <td class="cell--number">0</td>
+ <td class="cell--number">5.21</td>
+
+ </tr>
+
+ <tr class="t-file">
+ <td class="strong t-file__name"><a href="#dec68bd690f2a686e5ec6abc94957108f77fc86a" class="src_link" title="lib/ruby-enum/enum/i18n_mock.rb">lib/ruby-enum/enum/i18n_mock.rb</a></td>
+ <td class="green strong cell--number t-file__coverage">100.00 %</td>
+ <td class="cell--number">19</td>
+ <td class="cell--number">0</td>
+ <td class="cell--number">0</td>
+ <td class="cell--number">0</td>
+ <td class="cell--number">0.00</td>
+
+ </tr>
+
+ <tr class="t-file">
+ <td class="strong t-file__name"><a href="#cfb904495fd0901e7776673d80a12887fe1124b9" class="src_link" title="lib/ruby-enum/errors/base.rb">lib/ruby-enum/errors/base.rb</a></td>
+ <td class="green strong cell--number t-file__coverage">100.00 %</td>
<td class="cell--number">80</td>
<td class="cell--number">22</td>
<td class="cell--number">22</td>
<td class="cell--number">0</td>
- <td class="cell--number">2.91</td>
+ <td class="cell--number">4.27</td>
</tr>
<tr class="t-file">
- <td class="strong t-file__name"><a href="#c5a5d6fc57bbd314608d88cf9410ed4d56aa0350" class="src_link" title="lib/ruby-enum/errors/duplicate_key_error.rb">lib/ruby-enum/errors/duplicate_key_error.rb</a></td>
+ <td class="strong t-file__name"><a href="#e8c608ef8f74385efbc68f974e79dc6a86b214ab" class="src_link" title="lib/ruby-enum/errors/duplicate_key_error.rb">lib/ruby-enum/errors/duplicate_key_error.rb</a></td>
<td class="green strong cell--number t-file__coverage">100.00 %</td>
<td class="cell--number">14</td>
<td class="cell--number">6</td>
<td class="cell--number">6</td>
<td class="cell--number">0</td>
- <td class="cell--number">1.00</td>
+ <td class="cell--number">1.17</td>
</tr>
<tr class="t-file">
- <td class="strong t-file__name"><a href="#ef6bd6993c68332cd8e116fa109f64e85b49458a" class="src_link" title="lib/ruby-enum/errors/duplicate_value_error.rb">lib/ruby-enum/errors/duplicate_value_error.rb</a></td>
+ <td class="strong t-file__name"><a href="#6f59e1935a54865d7b1a8dea468d7d3634a8a889" class="src_link" title="lib/ruby-enum/errors/duplicate_value_error.rb">lib/ruby-enum/errors/duplicate_value_error.rb</a></td>
<td class="green strong cell--number t-file__coverage">100.00 %</td>
<td class="cell--number">14</td>
<td class="cell--number">6</td>
<td class="cell--number">6</td>
<td class="cell--number">0</td>
- <td class="cell--number">1.00</td>
+ <td class="cell--number">1.17</td>
</tr>
<tr class="t-file">
- <td class="strong t-file__name"><a href="#f2d20eed6db8053addd5fc1fae785eee6e7d3715" class="src_link" title="lib/ruby-enum/errors/uninitialized_constant_error.rb">lib/ruby-enum/errors/uninitialized_constant_error.rb</a></td>
+ <td class="strong t-file__name"><a href="#4b971f076e68fc727f99cd0642ab530d0d701a40" class="src_link" title="lib/ruby-enum/errors/uninitialized_constant_error.rb">lib/ruby-enum/errors/uninitialized_constant_error.rb</a></td>
<td class="green strong cell--number t-file__coverage">100.00 %</td>
<td class="cell--number">13</td>
<td class="cell--number">6</td>
<td class="cell--number">6</td>
<td class="cell--number">0</td>
- <td class="cell--number">1.33</td>
+ <td class="cell--number">1.50</td>
</tr>
<tr class="t-file">
- <td class="strong t-file__name"><a href="#bcbac193211da2bce91236b5d521e23005d4dc30" class="src_link" title="spec/ruby-enum/version_spec.rb">spec/ruby-enum/version_spec.rb</a></td>
+ <td class="strong t-file__name"><a href="#e98ca7f68d20e1cefa52fb3f31f5fb9531af19d7" class="src_link" title="spec/ruby-enum/enum_spec.rb">spec/ruby-enum/enum_spec.rb</a></td>
<td class="green strong cell--number t-file__coverage">100.00 %</td>
+ <td class="cell--number">320</td>
+ <td class="cell--number">174</td>
+ <td class="cell--number">174</td>
+ <td class="cell--number">0</td>
+ <td class="cell--number">1.10</td>
+
+ </tr>
+
+ <tr class="t-file">
+ <td class="strong t-file__name"><a href="#96f04bde05e6d83fa459a9ec1c31bce83526eef5" class="src_link" title="spec/ruby-enum/version_spec.rb">spec/ruby-enum/version_spec.rb</a></td>
+ <td class="green strong cell--number t-file__coverage">100.00 %</td>
<td class="cell--number">9</td>
<td class="cell--number">4</td>
<td class="cell--number">4</td>
<td class="cell--number">0</td>
<td class="cell--number">1.00</td>
@@ -155,18 +188,18 @@
</div>
<div id="footer">
- Generated by <a href="https://github.com/simplecov-ruby/simplecov">simplecov</a> v0.21.2
+ Generated by <a href="https://github.com/simplecov-ruby/simplecov">simplecov</a> v0.22.0
and simplecov-html v0.12.3<br/>
using RSpec
</div>
<div class="source_files">
- <div class="source_table" id="ee900552ffcf61e4cbcb7de088bb27ce8e102d72">
+ <div class="source_table" id="1aefb18cee22848cb7bcee850bb07481c7b45c07">
<div class="header">
<h3>lib/ruby-enum.rb</h3>
<h4>
<span class="green">
100.0%
@@ -176,12 +209,12 @@
</h4>
<div class="t-line-summary">
- <b>8</b> relevant lines.
- <span class="green"><b>8</b> lines covered</span> and
+ <b>11</b> relevant lines.
+ <span class="green"><b>11</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
@@ -217,44 +250,44 @@
<span class="hits">1</span>
- <code class="ruby">require 'i18n'</code>
+ <code class="ruby">require 'ruby-enum/version'</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="4">
+ <li class="covered" data-hits="1" data-linenumber="4">
+ <span class="hits">1</span>
-
- <code class="ruby"></code>
+ <code class="ruby">require 'ruby-enum/enum'</code>
</li>
</div>
<div>
<li class="covered" data-hits="1" data-linenumber="5">
<span class="hits">1</span>
- <code class="ruby">require 'ruby-enum/version'</code>
+ <code class="ruby">require 'ruby-enum/enum/case'</code>
</li>
</div>
<div>
<li class="covered" data-hits="1" data-linenumber="6">
<span class="hits">1</span>
- <code class="ruby">require 'ruby-enum/enum'</code>
+ <code class="ruby">require 'ruby-enum/enum/i18n_mock'</code>
</li>
</div>
<div>
<li class="never" data-hits="" data-linenumber="7">
@@ -266,66 +299,198 @@
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="8">
- <span class="hits">1</span>
+ <li class="never" data-hits="" data-linenumber="8">
+
- <code class="ruby">I18n.load_path << File.join(File.dirname(__FILE__), 'config', 'locales', 'en.yml')</code>
+ <code class="ruby"># Try to load the I18n gem and provide a mock if it is not available.</code>
</li>
</div>
<div>
<li class="never" data-hits="" data-linenumber="9">
- <code class="ruby"></code>
+ <code class="ruby">begin</code>
</li>
</div>
<div>
<li class="covered" data-hits="1" data-linenumber="10">
<span class="hits">1</span>
- <code class="ruby">require 'ruby-enum/errors/base'</code>
+ <code class="ruby"> require 'i18n'</code>
</li>
</div>
<div>
<li class="covered" data-hits="1" data-linenumber="11">
<span class="hits">1</span>
+ <code class="ruby"> Ruby::Enum.i18n = I18n</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="12">
+
+
+
+
+
+ <code class="ruby">rescue LoadError</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="13">
+
+
+
+
+
+ <code class="ruby"> # I18n is not available</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="14">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> # :nocov:</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="15">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> # Tests for this loading are in the spec_i18n folder</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="0" data-linenumber="16">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> Ruby::Enum.i18n = Ruby::Enum::I18nMock</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="17">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> # :nocov:</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="18">
+
+
+
+
+
+ <code class="ruby">end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="19">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="20">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby">Ruby::Enum.i18n.load_path << File.join(File.dirname(__FILE__), 'config', 'locales', 'en.yml')</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="21">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="22">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby">require 'ruby-enum/errors/base'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="23">
+ <span class="hits">1</span>
+
+
+
+
<code class="ruby">require 'ruby-enum/errors/uninitialized_constant_error'</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="12">
+ <li class="covered" data-hits="1" data-linenumber="24">
<span class="hits">1</span>
<code class="ruby">require 'ruby-enum/errors/duplicate_key_error'</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="13">
+ <li class="covered" data-hits="1" data-linenumber="25">
<span class="hits">1</span>
@@ -336,11 +501,11 @@
</ol>
</pre>
</div>
- <div class="source_table" id="5d0cbf07eac0368481292a8c6bf5e85f636264b0">
+ <div class="source_table" id="800d8a6c9d9672ce1ce0149e00493d33a8a8109e">
<div class="header">
<h3>lib/ruby-enum/enum.rb</h3>
<h4>
<span class="green">
100.0%
@@ -350,12 +515,12 @@
</h4>
<div class="t-line-summary">
- <b>67</b> relevant lines.
- <span class="green"><b>67</b> lines covered</span> and
+ <b>68</b> relevant lines.
+ <span class="green"><b>68</b> lines covered</span> and
<span class="red"><b>0</b> lines missed.</span>
</div>
@@ -413,1831 +578,2819 @@
<span class="hits">1</span>
- <code class="ruby"> attr_reader :key, :value</code>
+ <code class="ruby"> class << self</code>
</li>
</div>
<div>
<li class="never" data-hits="" data-linenumber="6">
- <code class="ruby"></code>
+ <code class="ruby"> # Needed for I18n mock</code>
</li>
</div>
<div>
<li class="covered" data-hits="1" data-linenumber="7">
<span class="hits">1</span>
+ <code class="ruby"> attr_accessor :i18n</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="8">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="9">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="10">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> attr_reader :key, :value</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="11">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="12">
+ <span class="hits">1</span>
+
+
+
+
<code class="ruby"> def initialize(key, value)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="8" data-linenumber="8">
- <span class="hits">8</span>
+ <li class="covered" data-hits="11" data-linenumber="13">
+ <span class="hits">11</span>
<code class="ruby"> @key = key</code>
</li>
</div>
<div>
- <li class="covered" data-hits="8" data-linenumber="9">
- <span class="hits">8</span>
+ <li class="covered" data-hits="11" data-linenumber="14">
+ <span class="hits">11</span>
<code class="ruby"> @value = value</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="10">
+ <li class="never" data-hits="" data-linenumber="15">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="11">
+ <li class="never" data-hits="" data-linenumber="16">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="12">
+ <li class="covered" data-hits="1" data-linenumber="17">
<span class="hits">1</span>
<code class="ruby"> def self.included(base)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="4" data-linenumber="13">
- <span class="hits">4</span>
+ <li class="covered" data-hits="5" data-linenumber="18">
+ <span class="hits">5</span>
<code class="ruby"> base.extend Enumerable</code>
</li>
</div>
<div>
- <li class="covered" data-hits="4" data-linenumber="14">
- <span class="hits">4</span>
+ <li class="covered" data-hits="5" data-linenumber="19">
+ <span class="hits">5</span>
<code class="ruby"> base.extend ClassMethods</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="15">
+ <li class="never" data-hits="" data-linenumber="20">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="4" data-linenumber="16">
- <span class="hits">4</span>
+ <li class="covered" data-hits="5" data-linenumber="21">
+ <span class="hits">5</span>
<code class="ruby"> base.private_class_method(:new)</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="17">
+ <li class="never" data-hits="" data-linenumber="22">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="18">
+ <li class="never" data-hits="" data-linenumber="23">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="19">
+ <li class="covered" data-hits="1" data-linenumber="24">
<span class="hits">1</span>
<code class="ruby"> module ClassMethods</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="20">
+ <li class="never" data-hits="" data-linenumber="25">
<code class="ruby"> # Define an enumerated value.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="21">
+ <li class="never" data-hits="" data-linenumber="26">
<code class="ruby"> #</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="22">
+ <li class="never" data-hits="" data-linenumber="27">
<code class="ruby"> # === Parameters</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="23">
+ <li class="never" data-hits="" data-linenumber="28">
<code class="ruby"> # [key] Enumerator key.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="24">
+ <li class="never" data-hits="" data-linenumber="29">
<code class="ruby"> # [value] Enumerator value.</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="25">
+ <li class="covered" data-hits="1" data-linenumber="30">
<span class="hits">1</span>
<code class="ruby"> def define(key, value = key)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="10" data-linenumber="26">
- <span class="hits">10</span>
+ <li class="covered" data-hits="15" data-linenumber="31">
+ <span class="hits">15</span>
<code class="ruby"> @_enum_hash ||= {}</code>
</li>
</div>
<div>
- <li class="covered" data-hits="10" data-linenumber="27">
- <span class="hits">10</span>
+ <li class="covered" data-hits="15" data-linenumber="32">
+ <span class="hits">15</span>
<code class="ruby"> @_enums_by_value ||= {}</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="28">
+ <li class="never" data-hits="" data-linenumber="33">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="10" data-linenumber="29">
- <span class="hits">10</span>
+ <li class="covered" data-hits="15" data-linenumber="34">
+ <span class="hits">15</span>
<code class="ruby"> validate_key!(key)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="9" data-linenumber="30">
- <span class="hits">9</span>
+ <li class="covered" data-hits="13" data-linenumber="35">
+ <span class="hits">13</span>
<code class="ruby"> validate_value!(value)</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="31">
+ <li class="never" data-hits="" data-linenumber="36">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="8" data-linenumber="32">
- <span class="hits">8</span>
+ <li class="covered" data-hits="11" data-linenumber="37">
+ <span class="hits">11</span>
<code class="ruby"> store_new_instance(key, value)</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="33">
+ <li class="never" data-hits="" data-linenumber="38">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="8" data-linenumber="34">
- <span class="hits">8</span>
+ <li class="covered" data-hits="11" data-linenumber="39">
+ <span class="hits">11</span>
<code class="ruby"> if upper?(key.to_s)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="5" data-linenumber="35">
- <span class="hits">5</span>
+ <li class="covered" data-hits="8" data-linenumber="40">
+ <span class="hits">8</span>
<code class="ruby"> const_set key, value</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="36">
+ <li class="never" data-hits="" data-linenumber="41">
<code class="ruby"> else</code>
</li>
</div>
<div>
- <li class="covered" data-hits="6" data-linenumber="37">
+ <li class="covered" data-hits="6" data-linenumber="42">
<span class="hits">6</span>
<code class="ruby"> define_singleton_method(key) { value }</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="38">
+ <li class="never" data-hits="" data-linenumber="43">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="39">
+ <li class="never" data-hits="" data-linenumber="44">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="40">
+ <li class="never" data-hits="" data-linenumber="45">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="41">
+ <li class="covered" data-hits="1" data-linenumber="46">
<span class="hits">1</span>
<code class="ruby"> def store_new_instance(key, value)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="8" data-linenumber="42">
- <span class="hits">8</span>
+ <li class="covered" data-hits="11" data-linenumber="47">
+ <span class="hits">11</span>
<code class="ruby"> new_instance = new(key, value)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="8" data-linenumber="43">
- <span class="hits">8</span>
+ <li class="covered" data-hits="11" data-linenumber="48">
+ <span class="hits">11</span>
<code class="ruby"> @_enum_hash[key] = new_instance</code>
</li>
</div>
<div>
- <li class="covered" data-hits="8" data-linenumber="44">
- <span class="hits">8</span>
+ <li class="covered" data-hits="11" data-linenumber="49">
+ <span class="hits">11</span>
<code class="ruby"> @_enums_by_value[value] = new_instance</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="45">
+ <li class="never" data-hits="" data-linenumber="50">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="46">
+ <li class="never" data-hits="" data-linenumber="51">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="47">
+ <li class="covered" data-hits="1" data-linenumber="52">
<span class="hits">1</span>
<code class="ruby"> def const_missing(key)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="3" data-linenumber="48">
- <span class="hits">3</span>
+ <li class="covered" data-hits="4" data-linenumber="53">
+ <span class="hits">4</span>
<code class="ruby"> raise Ruby::Enum::Errors::UninitializedConstantError, name: name, key: key</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="49">
+ <li class="never" data-hits="" data-linenumber="54">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="50">
+ <li class="never" data-hits="" data-linenumber="55">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="51">
+ <li class="never" data-hits="" data-linenumber="56">
<code class="ruby"> # Iterate over all enumerated values.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="52">
+ <li class="never" data-hits="" data-linenumber="57">
<code class="ruby"> # Required for Enumerable mixin</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="53">
+ <li class="covered" data-hits="1" data-linenumber="58">
<span class="hits">1</span>
<code class="ruby"> def each(&block)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="8" data-linenumber="54">
+ <li class="covered" data-hits="8" data-linenumber="59">
<span class="hits">8</span>
<code class="ruby"> @_enum_hash.each(&block)</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="55">
+ <li class="never" data-hits="" data-linenumber="60">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="56">
+ <li class="never" data-hits="" data-linenumber="61">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="57">
+ <li class="never" data-hits="" data-linenumber="62">
<code class="ruby"> # Attempt to parse an enum key and return the</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="58">
+ <li class="never" data-hits="" data-linenumber="63">
<code class="ruby"> # corresponding value.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="59">
+ <li class="never" data-hits="" data-linenumber="64">
<code class="ruby"> #</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="60">
+ <li class="never" data-hits="" data-linenumber="65">
<code class="ruby"> # === Parameters</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="61">
+ <li class="never" data-hits="" data-linenumber="66">
<code class="ruby"> # [k] The key string to parse.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="62">
+ <li class="never" data-hits="" data-linenumber="67">
<code class="ruby"> #</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="63">
+ <li class="never" data-hits="" data-linenumber="68">
<code class="ruby"> # Returns the corresponding value or nil.</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="64">
+ <li class="covered" data-hits="1" data-linenumber="69">
<span class="hits">1</span>
<code class="ruby"> def parse(k)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="4" data-linenumber="65">
+ <li class="covered" data-hits="4" data-linenumber="70">
<span class="hits">4</span>
<code class="ruby"> k = k.to_s.upcase</code>
</li>
</div>
<div>
- <li class="covered" data-hits="4" data-linenumber="66">
+ <li class="covered" data-hits="4" data-linenumber="71">
<span class="hits">4</span>
<code class="ruby"> each do |key, enum|</code>
</li>
</div>
<div>
- <li class="covered" data-hits="6" data-linenumber="67">
+ <li class="covered" data-hits="6" data-linenumber="72">
<span class="hits">6</span>
<code class="ruby"> return enum.value if key.to_s.upcase == k</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="68">
+ <li class="never" data-hits="" data-linenumber="73">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="69">
+ <li class="never" data-hits="" data-linenumber="74">
<code class="ruby"> nil</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="70">
+ <li class="never" data-hits="" data-linenumber="75">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="71">
+ <li class="never" data-hits="" data-linenumber="76">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="72">
+ <li class="never" data-hits="" data-linenumber="77">
<code class="ruby"> # Whether the specified key exists in this enum.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="73">
+ <li class="never" data-hits="" data-linenumber="78">
<code class="ruby"> #</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="74">
+ <li class="never" data-hits="" data-linenumber="79">
<code class="ruby"> # === Parameters</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="75">
+ <li class="never" data-hits="" data-linenumber="80">
<code class="ruby"> # [k] The string key to check.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="76">
+ <li class="never" data-hits="" data-linenumber="81">
<code class="ruby"> #</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="77">
+ <li class="never" data-hits="" data-linenumber="82">
<code class="ruby"> # Returns true if the key exists, false otherwise.</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="78">
+ <li class="covered" data-hits="1" data-linenumber="83">
<span class="hits">1</span>
<code class="ruby"> def key?(k)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="7" data-linenumber="79">
+ <li class="covered" data-hits="7" data-linenumber="84">
<span class="hits">7</span>
<code class="ruby"> @_enum_hash.key?(k)</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="80">
+ <li class="never" data-hits="" data-linenumber="85">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="81">
+ <li class="never" data-hits="" data-linenumber="86">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="82">
+ <li class="never" data-hits="" data-linenumber="87">
<code class="ruby"> # Gets the string value for the specified key.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="83">
+ <li class="never" data-hits="" data-linenumber="88">
<code class="ruby"> #</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="84">
+ <li class="never" data-hits="" data-linenumber="89">
<code class="ruby"> # === Parameters</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="85">
+ <li class="never" data-hits="" data-linenumber="90">
<code class="ruby"> # [k] The key symbol to get the value for.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="86">
+ <li class="never" data-hits="" data-linenumber="91">
<code class="ruby"> #</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="87">
+ <li class="never" data-hits="" data-linenumber="92">
<code class="ruby"> # Returns the corresponding enum instance or nil.</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="88">
+ <li class="covered" data-hits="1" data-linenumber="93">
<span class="hits">1</span>
<code class="ruby"> def value(k)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="5" data-linenumber="89">
+ <li class="covered" data-hits="5" data-linenumber="94">
<span class="hits">5</span>
<code class="ruby"> enum = @_enum_hash[k]</code>
</li>
</div>
<div>
- <li class="covered" data-hits="5" data-linenumber="90">
+ <li class="covered" data-hits="5" data-linenumber="95">
<span class="hits">5</span>
<code class="ruby"> enum&.value</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="91">
+ <li class="never" data-hits="" data-linenumber="96">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="92">
+ <li class="never" data-hits="" data-linenumber="97">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="93">
+ <li class="never" data-hits="" data-linenumber="98">
<code class="ruby"> # Whether the specified value exists in this enum.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="94">
+ <li class="never" data-hits="" data-linenumber="99">
<code class="ruby"> #</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="95">
+ <li class="never" data-hits="" data-linenumber="100">
<code class="ruby"> # === Parameters</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="96">
+ <li class="never" data-hits="" data-linenumber="101">
<code class="ruby"> # [k] The string value to check.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="97">
+ <li class="never" data-hits="" data-linenumber="102">
<code class="ruby"> #</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="98">
+ <li class="never" data-hits="" data-linenumber="103">
<code class="ruby"> # Returns true if the value exists, false otherwise.</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="99">
+ <li class="covered" data-hits="1" data-linenumber="104">
<span class="hits">1</span>
<code class="ruby"> def value?(v)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="7" data-linenumber="100">
+ <li class="covered" data-hits="7" data-linenumber="105">
<span class="hits">7</span>
<code class="ruby"> @_enums_by_value.key?(v)</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="101">
+ <li class="never" data-hits="" data-linenumber="106">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="102">
+ <li class="never" data-hits="" data-linenumber="107">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="103">
+ <li class="never" data-hits="" data-linenumber="108">
<code class="ruby"> # Gets the key symbol for the specified value.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="104">
+ <li class="never" data-hits="" data-linenumber="109">
<code class="ruby"> #</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="105">
+ <li class="never" data-hits="" data-linenumber="110">
<code class="ruby"> # === Parameters</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="106">
+ <li class="never" data-hits="" data-linenumber="111">
<code class="ruby"> # [v] The string value to parse.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="107">
+ <li class="never" data-hits="" data-linenumber="112">
<code class="ruby"> #</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="108">
+ <li class="never" data-hits="" data-linenumber="113">
<code class="ruby"> # Returns the corresponding key symbol or nil.</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="109">
+ <li class="covered" data-hits="1" data-linenumber="114">
<span class="hits">1</span>
<code class="ruby"> def key(v)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="5" data-linenumber="110">
+ <li class="covered" data-hits="5" data-linenumber="115">
<span class="hits">5</span>
<code class="ruby"> enum = @_enums_by_value[v]</code>
</li>
</div>
<div>
- <li class="covered" data-hits="5" data-linenumber="111">
+ <li class="covered" data-hits="5" data-linenumber="116">
<span class="hits">5</span>
<code class="ruby"> enum&.key</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="112">
+ <li class="never" data-hits="" data-linenumber="117">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="113">
+ <li class="never" data-hits="" data-linenumber="118">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="114">
+ <li class="never" data-hits="" data-linenumber="119">
<code class="ruby"> # Returns all enum keys.</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="115">
+ <li class="covered" data-hits="1" data-linenumber="120">
<span class="hits">1</span>
<code class="ruby"> def keys</code>
</li>
</div>
<div>
- <li class="covered" data-hits="2" data-linenumber="116">
+ <li class="covered" data-hits="2" data-linenumber="121">
<span class="hits">2</span>
<code class="ruby"> @_enum_hash.values.map(&:key)</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="117">
+ <li class="never" data-hits="" data-linenumber="122">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="118">
+ <li class="never" data-hits="" data-linenumber="123">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="119">
+ <li class="never" data-hits="" data-linenumber="124">
<code class="ruby"> # Returns all enum values.</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="120">
+ <li class="covered" data-hits="1" data-linenumber="125">
<span class="hits">1</span>
<code class="ruby"> def values</code>
</li>
</div>
<div>
- <li class="covered" data-hits="7" data-linenumber="121">
- <span class="hits">7</span>
+ <li class="covered" data-hits="25" data-linenumber="126">
+ <span class="hits">25</span>
<code class="ruby"> result = @_enum_hash.values.map(&:value)</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="122">
+ <li class="never" data-hits="" data-linenumber="127">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="7" data-linenumber="123">
- <span class="hits">7</span>
+ <li class="covered" data-hits="25" data-linenumber="128">
+ <span class="hits">25</span>
<code class="ruby"> if superclass < Ruby::Enum</code>
</li>
</div>
<div>
- <li class="covered" data-hits="3" data-linenumber="124">
+ <li class="covered" data-hits="3" data-linenumber="129">
<span class="hits">3</span>
<code class="ruby"> superclass.values + result</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="125">
+ <li class="never" data-hits="" data-linenumber="130">
<code class="ruby"> else</code>
</li>
</div>
<div>
- <li class="covered" data-hits="4" data-linenumber="126">
- <span class="hits">4</span>
+ <li class="covered" data-hits="22" data-linenumber="131">
+ <span class="hits">22</span>
<code class="ruby"> result</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="127">
+ <li class="never" data-hits="" data-linenumber="132">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="128">
+ <li class="never" data-hits="" data-linenumber="133">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="129">
+ <li class="never" data-hits="" data-linenumber="134">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="130">
+ <li class="never" data-hits="" data-linenumber="135">
<code class="ruby"> # Iterate over all enumerated values.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="131">
+ <li class="never" data-hits="" data-linenumber="136">
<code class="ruby"> # Required for Enumerable mixin</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="132">
+ <li class="covered" data-hits="1" data-linenumber="137">
<span class="hits">1</span>
<code class="ruby"> def each_value(&_block)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="133">
+ <li class="covered" data-hits="1" data-linenumber="138">
<span class="hits">1</span>
<code class="ruby"> @_enum_hash.each_value do |v|</code>
</li>
</div>
<div>
- <li class="covered" data-hits="2" data-linenumber="134">
+ <li class="covered" data-hits="2" data-linenumber="139">
<span class="hits">2</span>
<code class="ruby"> yield v.value</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="135">
+ <li class="never" data-hits="" data-linenumber="140">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="136">
+ <li class="never" data-hits="" data-linenumber="141">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="137">
+ <li class="never" data-hits="" data-linenumber="142">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="138">
+ <li class="never" data-hits="" data-linenumber="143">
<code class="ruby"> # Iterate over all enumerated keys.</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="139">
+ <li class="never" data-hits="" data-linenumber="144">
<code class="ruby"> # Required for Enumerable mixin</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="140">
+ <li class="covered" data-hits="1" data-linenumber="145">
<span class="hits">1</span>
<code class="ruby"> def each_key(&_block)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="141">
+ <li class="covered" data-hits="1" data-linenumber="146">
<span class="hits">1</span>
<code class="ruby"> @_enum_hash.each_value do |v|</code>
</li>
</div>
<div>
- <li class="covered" data-hits="2" data-linenumber="142">
+ <li class="covered" data-hits="2" data-linenumber="147">
<span class="hits">2</span>
<code class="ruby"> yield v.key</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="143">
+ <li class="never" data-hits="" data-linenumber="148">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="144">
+ <li class="never" data-hits="" data-linenumber="149">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="145">
+ <li class="never" data-hits="" data-linenumber="150">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="146">
+ <li class="covered" data-hits="1" data-linenumber="151">
<span class="hits">1</span>
<code class="ruby"> def to_h</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="147">
+ <li class="covered" data-hits="1" data-linenumber="152">
<span class="hits">1</span>
- <code class="ruby"> Hash[@_enum_hash.map do |key, enum|</code>
+ <code class="ruby"> @_enum_hash.transform_values(&:value)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="2" data-linenumber="148">
- <span class="hits">2</span>
+ <li class="never" data-hits="" data-linenumber="153">
+
- <code class="ruby"> [key, enum.value]</code>
+ <code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="149">
+ <li class="never" data-hits="" data-linenumber="154">
- <code class="ruby"> end]</code>
+ <code class="ruby"></code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="150">
+ <li class="covered" data-hits="1" data-linenumber="155">
+ <span class="hits">1</span>
+
+ <code class="ruby"> private</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="156">
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="157">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> def upper?(s)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="11" data-linenumber="158">
+ <span class="hits">11</span>
+
+
+
+
+ <code class="ruby"> !/[[:upper:]]/.match(s).nil?</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="159">
+
+
+
+
+
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="151">
+ <li class="never" data-hits="" data-linenumber="160">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="152">
+ <li class="covered" data-hits="1" data-linenumber="161">
<span class="hits">1</span>
- <code class="ruby"> private</code>
+ <code class="ruby"> def validate_key!(key)</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="153">
+ <li class="covered" data-hits="15" data-linenumber="162">
+ <span class="hits">15</span>
+
+ <code class="ruby"> return unless @_enum_hash.key?(key)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="163">
+
+
+
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="154">
+ <li class="covered" data-hits="2" data-linenumber="164">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> raise Ruby::Enum::Errors::DuplicateKeyError, name: name, key: key</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="165">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="166">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="167">
<span class="hits">1</span>
- <code class="ruby"> def upper?(s)</code>
+ <code class="ruby"> def validate_value!(value)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="8" data-linenumber="155">
- <span class="hits">8</span>
+ <li class="covered" data-hits="13" data-linenumber="168">
+ <span class="hits">13</span>
- <code class="ruby"> !/[[:upper:]]/.match(s).nil?</code>
+ <code class="ruby"> return unless @_enums_by_value.key?(value)</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="156">
+ <li class="never" data-hits="" data-linenumber="169">
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="170">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> raise Ruby::Enum::Errors::DuplicateValueError, name: name, value: value</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="171">
+
+
+
+
+
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="157">
+ <li class="never" data-hits="" data-linenumber="172">
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="173">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="174">
+
+
+
+
+
+ <code class="ruby">end</code>
+ </li>
+ </div>
+
+ </ol>
+ </pre>
+</div>
+
+
+ <div class="source_table" id="9d611104d8095a2ddd3f1e7bffc9ed21a58e762a">
+ <div class="header">
+ <h3>lib/ruby-enum/enum/case.rb</h3>
+ <h4>
+ <span class="green">
+ 100.0%
+</span>
+
+ lines covered
+ </h4>
+
+
+
+ <div class="t-line-summary">
+ <b>29</b> relevant lines.
+ <span class="green"><b>29</b> lines covered</span> and
+ <span class="red"><b>0</b> lines missed.</span>
+ </div>
+
+
+
+ </div>
+
+ <pre>
+ <ol>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="1">
+
+
+
+
+
+ <code class="ruby"># frozen_string_literal: true</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="2">
+
+
+
+
+
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="158">
+ <li class="covered" data-hits="1" data-linenumber="3">
<span class="hits">1</span>
- <code class="ruby"> def validate_key!(key)</code>
+ <code class="ruby">module Ruby</code>
</li>
</div>
<div>
- <li class="covered" data-hits="10" data-linenumber="159">
- <span class="hits">10</span>
+ <li class="covered" data-hits="1" data-linenumber="4">
+ <span class="hits">1</span>
- <code class="ruby"> return unless @_enum_hash.key?(key)</code>
+ <code class="ruby"> module Enum</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="160">
+ <li class="never" data-hits="" data-linenumber="5">
- <code class="ruby"></code>
+ <code class="ruby"> ##</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="161">
+ <li class="never" data-hits="" data-linenumber="6">
+
+
+
+
+
+ <code class="ruby"> # Adds a method to an enum class that allows for exhaustive matching on a value.</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="7">
+
+
+
+
+
+ <code class="ruby"> #</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="8">
+
+
+
+
+
+ <code class="ruby"> # @example</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="9">
+
+
+
+
+
+ <code class="ruby"> # class Color</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="10">
+
+
+
+
+
+ <code class="ruby"> # include Ruby::Enum</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="11">
+
+
+
+
+
+ <code class="ruby"> # include Ruby::Enum::Case</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="12">
+
+
+
+
+
+ <code class="ruby"> #</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="13">
+
+
+
+
+
+ <code class="ruby"> # define :RED, :red</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="14">
+
+
+
+
+
+ <code class="ruby"> # define :GREEN, :green</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="15">
+
+
+
+
+
+ <code class="ruby"> # define :BLUE, :blue</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="16">
+
+
+
+
+
+ <code class="ruby"> # define :YELLOW, :yellow</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="17">
+
+
+
+
+
+ <code class="ruby"> # end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="18">
+
+
+
+
+
+ <code class="ruby"> #</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="19">
+
+
+
+
+
+ <code class="ruby"> # Color.case(Color::RED, {</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="20">
+
+
+
+
+
+ <code class="ruby"> # [Color::RED, Color::GREEN] => -> { "red or green" },</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="21">
+
+
+
+
+
+ <code class="ruby"> # Color::BLUE => -> { "blue" },</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="22">
+
+
+
+
+
+ <code class="ruby"> # Color::YELLOW => -> { "yellow" },</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="23">
+
+
+
+
+
+ <code class="ruby"> # })</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="24">
+
+
+
+
+
+ <code class="ruby"> #</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="25">
+
+
+
+
+
+ <code class="ruby"> # Reserves the :else key for a default case:</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="26">
+
+
+
+
+
+ <code class="ruby"> # Color.case(Color::RED, {</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="27">
+
+
+
+
+
+ <code class="ruby"> # [Color::RED, Color::GREEN] => -> { "red or green" },</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="28">
+
+
+
+
+
+ <code class="ruby"> # else: -> { "blue or yellow" },</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="29">
+
+
+
+
+
+ <code class="ruby"> # })</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="30">
<span class="hits">1</span>
- <code class="ruby"> raise Ruby::Enum::Errors::DuplicateKeyError, name: name, key: key</code>
+ <code class="ruby"> module Case</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="162">
+ <li class="covered" data-hits="1" data-linenumber="31">
+ <span class="hits">1</span>
+
+ <code class="ruby"> def self.included(klass)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="32">
+ <span class="hits">1</span>
+
+
+ <code class="ruby"> klass.extend(ClassMethods)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="33">
+
+
+
+
+
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="163">
+ <li class="never" data-hits="" data-linenumber="34">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="164">
+ <li class="never" data-hits="" data-linenumber="35">
+
+
+
+
+
+ <code class="ruby"> ##</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="36">
+
+
+
+
+
+ <code class="ruby"> # @see Ruby::Enum::Case</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="37">
<span class="hits">1</span>
- <code class="ruby"> def validate_value!(value)</code>
+ <code class="ruby"> module ClassMethods</code>
</li>
</div>
<div>
- <li class="covered" data-hits="9" data-linenumber="165">
+ <li class="covered" data-hits="1" data-linenumber="38">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> class ValuesNotDefinedError < StandardError</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="39">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="40">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="41">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> class NotAllCasesHandledError < StandardError</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="42">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="43">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="44">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> def case(value, cases)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="9" data-linenumber="45">
<span class="hits">9</span>
- <code class="ruby"> return unless @_enums_by_value.key?(value)</code>
+ <code class="ruby"> validate_cases(cases)</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="166">
+ <li class="never" data-hits="" data-linenumber="46">
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="167">
+ <li class="covered" data-hits="7" data-linenumber="47">
+ <span class="hits">7</span>
+
+
+
+
+ <code class="ruby"> filtered_cases = cases.select do |values, _proc|</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="15" data-linenumber="48">
+ <span class="hits">15</span>
+
+
+
+
+ <code class="ruby"> values = [values] unless values.is_a?(Array)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="15" data-linenumber="49">
+ <span class="hits">15</span>
+
+
+
+
+ <code class="ruby"> values.include?(value)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="50">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="51">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="7" data-linenumber="52">
+ <span class="hits">7</span>
+
+
+
+
+ <code class="ruby"> return call_proc(cases[:else], value) if filtered_cases.none?</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="53">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="9" data-linenumber="54">
+ <span class="hits">9</span>
+
+
+
+
+ <code class="ruby"> results = filtered_cases.map { |_values, proc| call_proc(proc, value) }</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="55">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="56">
+
+
+
+
+
+ <code class="ruby"> # Return the first result if there is only one result</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="4" data-linenumber="57">
+ <span class="hits">4</span>
+
+
+
+
+ <code class="ruby"> results.size == 1 ? results.first : results</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="58">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="59">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="60">
<span class="hits">1</span>
- <code class="ruby"> raise Ruby::Enum::Errors::DuplicateValueError, name: name, value: value</code>
+ <code class="ruby"> private</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="168">
+ <li class="never" data-hits="" data-linenumber="61">
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="62">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> def call_proc(proc, value)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="8" data-linenumber="63">
+ <span class="hits">8</span>
+
+
+
+
+ <code class="ruby"> return if proc.nil?</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="64">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="6" data-linenumber="65">
+ <span class="hits">6</span>
+
+
+
+
+ <code class="ruby"> if proc.arity == 1</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="66">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> proc.call(value)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="67">
+
+
+
+
+
+ <code class="ruby"> else</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="5" data-linenumber="68">
+ <span class="hits">5</span>
+
+
+
+
+ <code class="ruby"> proc.call</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="69">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="70">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="71">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="72">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> def validate_cases(cases)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="9" data-linenumber="73">
+ <span class="hits">9</span>
+
+
+
+
+ <code class="ruby"> all_values = cases.keys.flatten - [:else]</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="9" data-linenumber="74">
+ <span class="hits">9</span>
+
+
+
+
+ <code class="ruby"> else_defined = cases.key?(:else)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="9" data-linenumber="75">
+ <span class="hits">9</span>
+
+
+
+
+ <code class="ruby"> superfluous_values = all_values - values</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="9" data-linenumber="76">
+ <span class="hits">9</span>
+
+
+
+
+ <code class="ruby"> missing_values = values - all_values</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="77">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="9" data-linenumber="78">
+ <span class="hits">9</span>
+
+
+
+
+ <code class="ruby"> raise ValuesNotDefinedError, "Value(s) not defined: #{superfluous_values.join(', ')}" if superfluous_values.any?</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="8" data-linenumber="79">
+ <span class="hits">8</span>
+
+
+
+
+ <code class="ruby"> raise NotAllCasesHandledError, "Not all cases handled: #{missing_values.join(', ')}" if missing_values.any? && !else_defined</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="80">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="81">
+
+
+
+
+
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="169">
+ <li class="never" data-hits="" data-linenumber="82">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="170">
+ <li class="never" data-hits="" data-linenumber="83">
<code class="ruby"> end</code>
</li>
</div>
<div>
- <li class="never" data-hits="" data-linenumber="171">
+ <li class="never" data-hits="" data-linenumber="84">
@@ -2248,12 +3401,252 @@
</ol>
</pre>
</div>
- <div class="source_table" id="8f10848d362db72f4a966812244e1a180d9c0a87">
+ <div class="source_table" id="dec68bd690f2a686e5ec6abc94957108f77fc86a">
<div class="header">
+ <h3>lib/ruby-enum/enum/i18n_mock.rb</h3>
+ <h4>
+ <span class="green">
+ 100.0%
+</span>
+
+ lines covered
+ </h4>
+
+
+
+ <div class="t-line-summary">
+ <b>0</b> relevant lines.
+ <span class="green"><b>0</b> lines covered</span> and
+ <span class="red"><b>0</b> lines missed.</span>
+ </div>
+
+
+
+ </div>
+
+ <pre>
+ <ol>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="1">
+
+
+
+
+
+ <code class="ruby"># frozen_string_literal: true</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="2">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="3">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"># :nocov:</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="1" data-linenumber="4">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby">module Ruby</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="1" data-linenumber="5">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> module Enum</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="6">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> ##</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="7">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> # Mock I18n module in case the i18n gem is not available.</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="1" data-linenumber="8">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> module I18nMock</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="1" data-linenumber="9">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> def self.load_path</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="0" data-linenumber="10">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> []</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="11">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="12">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="1" data-linenumber="13">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> def self.translate(key, _options = {})</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="9" data-linenumber="14">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> key</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="15">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="16">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="17">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="18">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby">end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="skipped" data-hits="" data-linenumber="19">
+
+ <span class="hits">skipped</span>
+
+
+
+ <code class="ruby"># :nocov:</code>
+ </li>
+ </div>
+
+ </ol>
+ </pre>
+</div>
+
+
+ <div class="source_table" id="cfb904495fd0901e7776673d80a12887fe1124b9">
+ <div class="header">
<h3>lib/ruby-enum/errors/base.rb</h3>
<h4>
<span class="green">
100.0%
</span>
@@ -2495,34 +3888,34 @@
<code class="ruby"> def compose_message(key, attributes = {})</code>
</li>
</div>
<div>
- <li class="covered" data-hits="5" data-linenumber="21">
- <span class="hits">5</span>
+ <li class="covered" data-hits="8" data-linenumber="21">
+ <span class="hits">8</span>
<code class="ruby"> @problem = create_problem(key, attributes)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="5" data-linenumber="22">
- <span class="hits">5</span>
+ <li class="covered" data-hits="8" data-linenumber="22">
+ <span class="hits">8</span>
<code class="ruby"> @summary = create_summary(key, attributes)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="5" data-linenumber="23">
- <span class="hits">5</span>
+ <li class="covered" data-hits="8" data-linenumber="23">
+ <span class="hits">8</span>
<code class="ruby"> @resolution = create_resolution(key, attributes)</code>
@@ -2539,17 +3932,17 @@
<code class="ruby"></code>
</li>
</div>
<div>
- <li class="covered" data-hits="5" data-linenumber="25">
- <span class="hits">5</span>
+ <li class="covered" data-hits="8" data-linenumber="25">
+ <span class="hits">8</span>
- <code class="ruby"> "\nProblem:\n #{@problem}"\</code>
+ <code class="ruby"> "\nProblem:\n #{@problem}" \</code>
</li>
</div>
<div>
<li class="never" data-hits="" data-linenumber="26">
@@ -2611,11 +4004,11 @@
<span class="hits">1</span>
- <code class="ruby"> BASE_KEY = 'ruby.enum.errors.messages' #:nodoc:</code>
+ <code class="ruby"> BASE_KEY = 'ruby.enum.errors.messages' # :nodoc:</code>
</li>
</div>
<div>
<li class="never" data-hits="" data-linenumber="32">
@@ -2726,17 +4119,17 @@
<code class="ruby"> def translate(key, options)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="15" data-linenumber="42">
- <span class="hits">15</span>
+ <li class="covered" data-hits="24" data-linenumber="42">
+ <span class="hits">24</span>
- <code class="ruby"> ::I18n.translate("#{BASE_KEY}.#{key}", **{ locale: :en }.merge(options)).strip</code>
+ <code class="ruby"> Ruby::Enum.i18n.translate("#{BASE_KEY}.#{key}", locale: :en, **options).strip</code>
</li>
</div>
<div>
<li class="never" data-hits="" data-linenumber="43">
@@ -2847,12 +4240,12 @@
<code class="ruby"> def create_problem(key, attributes)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="5" data-linenumber="53">
- <span class="hits">5</span>
+ <li class="covered" data-hits="8" data-linenumber="53">
+ <span class="hits">8</span>
<code class="ruby"> translate("#{key}.message", attributes)</code>
@@ -2968,12 +4361,12 @@
<code class="ruby"> def create_summary(key, attributes)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="5" data-linenumber="64">
- <span class="hits">5</span>
+ <li class="covered" data-hits="8" data-linenumber="64">
+ <span class="hits">8</span>
<code class="ruby"> translate("#{key}.summary", attributes)</code>
@@ -3089,12 +4482,12 @@
<code class="ruby"> def create_resolution(key, attributes)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="5" data-linenumber="75">
- <span class="hits">5</span>
+ <li class="covered" data-hits="8" data-linenumber="75">
+ <span class="hits">8</span>
<code class="ruby"> translate("#{key}.resolution", attributes)</code>
@@ -3159,11 +4552,11 @@
</ol>
</pre>
</div>
- <div class="source_table" id="c5a5d6fc57bbd314608d88cf9410ed4d56aa0350">
+ <div class="source_table" id="e8c608ef8f74385efbc68f974e79dc6a86b214ab">
<div class="header">
<h3>lib/ruby-enum/errors/duplicate_key_error.rb</h3>
<h4>
<span class="green">
100.0%
@@ -3274,12 +4667,12 @@
<code class="ruby"> def initialize(attrs)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="9">
- <span class="hits">1</span>
+ <li class="covered" data-hits="2" data-linenumber="9">
+ <span class="hits">2</span>
<code class="ruby"> super(compose_message('duplicate_key', attrs))</code>
@@ -3344,11 +4737,11 @@
</ol>
</pre>
</div>
- <div class="source_table" id="ef6bd6993c68332cd8e116fa109f64e85b49458a">
+ <div class="source_table" id="6f59e1935a54865d7b1a8dea468d7d3634a8a889">
<div class="header">
<h3>lib/ruby-enum/errors/duplicate_value_error.rb</h3>
<h4>
<span class="green">
100.0%
@@ -3459,12 +4852,12 @@
<code class="ruby"> def initialize(attrs)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="1" data-linenumber="9">
- <span class="hits">1</span>
+ <li class="covered" data-hits="2" data-linenumber="9">
+ <span class="hits">2</span>
<code class="ruby"> super(compose_message('duplicate_value', attrs))</code>
@@ -3529,11 +4922,11 @@
</ol>
</pre>
</div>
- <div class="source_table" id="f2d20eed6db8053addd5fc1fae785eee6e7d3715">
+ <div class="source_table" id="4b971f076e68fc727f99cd0642ab530d0d701a40">
<div class="header">
<h3>lib/ruby-enum/errors/uninitialized_constant_error.rb</h3>
<h4>
<span class="green">
100.0%
@@ -3633,12 +5026,12 @@
<code class="ruby"> def initialize(attrs)</code>
</li>
</div>
<div>
- <li class="covered" data-hits="3" data-linenumber="8">
- <span class="hits">3</span>
+ <li class="covered" data-hits="4" data-linenumber="8">
+ <span class="hits">4</span>
<code class="ruby"> super(compose_message('uninitialized_constant', attrs))</code>
@@ -3703,10 +5096,3561 @@
</ol>
</pre>
</div>
- <div class="source_table" id="bcbac193211da2bce91236b5d521e23005d4dc30">
+ <div class="source_table" id="e98ca7f68d20e1cefa52fb3f31f5fb9531af19d7">
+ <div class="header">
+ <h3>spec/ruby-enum/enum_spec.rb</h3>
+ <h4>
+ <span class="green">
+ 100.0%
+</span>
+
+ lines covered
+ </h4>
+
+
+
+ <div class="t-line-summary">
+ <b>174</b> relevant lines.
+ <span class="green"><b>174</b> lines covered</span> and
+ <span class="red"><b>0</b> lines missed.</span>
+ </div>
+
+
+
+ </div>
+
+ <pre>
+ <ol>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="1">
+
+
+
+
+
+ <code class="ruby"># frozen_string_literal: true</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="2">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="3">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby">require 'spec_helper'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="4">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="5">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby">class Colors</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="6">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> include Ruby::Enum</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="7">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="8">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> define :RED, 'red'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="9">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> define :GREEN, 'green'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="10">
+
+
+
+
+
+ <code class="ruby">end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="11">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="12">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby">class FirstSubclass < Colors</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="13">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> define :ORANGE, 'orange'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="14">
+
+
+
+
+
+ <code class="ruby">end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="15">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="16">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby">class SecondSubclass < FirstSubclass</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="17">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> define :PINK, 'pink'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="18">
+
+
+
+
+
+ <code class="ruby">end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="19">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="20">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby">describe Ruby::Enum do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="21">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns an enum value' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="22">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors::RED).to eq 'red'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="23">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors::GREEN).to eq 'green'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="24">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="25">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="26">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> context 'when the i18n gem is loaded' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="27">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'raises UninitializedConstantError on an invalid constant' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="28">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="29">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors::ANYTHING</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="30">
+
+
+
+
+
+ <code class="ruby"> end.to raise_error Ruby::Enum::Errors::UninitializedConstantError, /The constant Colors::ANYTHING has not been defined./</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="31">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="32">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="33">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="34">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> context 'when the i18n gem is not loaded' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="35">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> before do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="36">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> allow(described_class).to receive(:i18n).and_return(Ruby::Enum::I18nMock)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="37">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="38">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="39">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'raises UninitializedConstantError on an invalid constant' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="40">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="41">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors::ANYTHING</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="42">
+
+
+
+
+
+ <code class="ruby"> end.to raise_error Ruby::Enum::Errors::UninitializedConstantError, /ruby.enum.errors.messages.uninitialized_constant.summary/</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="43">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="44">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="45">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="46">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe '#each' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="47">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'iterates over constants' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="48">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> keys = []</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="49">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> enum_keys = []</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="50">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> enum_values = []</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="51">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors.each do |key, enum|</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="52">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> keys << key</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="53">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> enum_keys << enum.key</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="54">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> enum_values << enum.value</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="55">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="56">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(keys).to eq %i[RED GREEN]</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="57">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(enum_keys).to eq %i[RED GREEN]</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="58">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(enum_values).to eq %w[red green]</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="59">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="60">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="61">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="62">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe '#map' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="63">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'maps constants' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="64">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> key_key_values = Colors.map do |key, enum|</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="65">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> [key, enum.key, enum.value]</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="66">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="67">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(key_key_values.count).to eq 2</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="68">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(key_key_values[0]).to eq [:RED, :RED, 'red']</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="69">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(key_key_values[1]).to eq [:GREEN, :GREEN, 'green']</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="70">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="71">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="72">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="73">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe '#parse' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="74">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'parses exact value' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="75">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.parse('red')).to eq(Colors::RED)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="76">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="77">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="78">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'is case-insensitive' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="79">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.parse('ReD')).to eq(Colors::RED)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="80">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="81">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="82">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns nil for a null value' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="83">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.parse(nil)).to be_nil</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="84">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="85">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="86">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns nil for an invalid value' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="87">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.parse('invalid')).to be_nil</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="88">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="89">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="90">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="91">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe '#key?' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="92">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns true for valid keys accessed directly' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="93">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors.keys.each do |key| # rubocop:disable Style/HashEachMethods</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="94">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.key?(key)).to be(true)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="95">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="96">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="97">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="98">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns true for valid keys accessed via each_keys' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="99">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors.each_key do |key|</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="100">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.key?(key)).to be(true)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="101">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="102">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="103">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="104">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns false for invalid keys' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="105">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.key?(:NOT_A_KEY)).to be(false)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="106">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="107">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="108">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="109">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe '#value' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="110">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns string values for keys' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="111">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors.each do |key, enum|</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="112">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.value(key)).to eq(enum.value)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="113">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="114">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="115">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="116">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns nil for an invalid key' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="117">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.value(:NOT_A_KEY)).to be_nil</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="118">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="119">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="120">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="121">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe '#value?' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="122">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns true for valid values accessed directly' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="123">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors.values.each do |value| # rubocop:disable Style/HashEachMethods</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="124">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.value?(value)).to be(true)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="125">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="126">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="127">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="128">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns true for valid values accessed via each_value' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="129">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors.each_value do |value|</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="130">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.value?(value)).to be(true)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="131">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="132">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="133">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="134">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns false for invalid values' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="135">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.value?('I am not a value')).to be(false)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="136">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="137">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="138">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="139">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe '#key' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="140">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns enum instances for values' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="141">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors.each do |_, enum| # rubocop:disable Style/HashEachMethods</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="142">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.key(enum.value)).to eq(enum.key)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="143">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="144">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="145">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="146">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns nil for an invalid value' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="147">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.key('invalid')).to be_nil</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="148">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="149">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="150">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="151">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe '#keys' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="152">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns keys' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="153">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.keys).to eq(%i[RED GREEN])</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="154">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="155">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="156">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="157">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe '#values' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="158">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns values' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="159">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.values).to eq(%w[red green])</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="160">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="161">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="162">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="163">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe '#to_h' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="164">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'returns a hash of key:values' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="165">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(Colors.to_h).to eq(RED: 'red', GREEN: 'green')</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="166">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="167">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="168">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="169">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> context 'when a duplicate key is used' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="170">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> context 'when the i18n gem is loaded' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="171">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'raises DuplicateKeyError' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="172">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="173">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors.class_eval do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="174">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> define :RED, 'some'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="175">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="176">
+
+
+
+
+
+ <code class="ruby"> end.to raise_error Ruby::Enum::Errors::DuplicateKeyError, /The constant Colors::RED has already been defined./</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="177">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="178">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="179">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="180">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> context 'when the i18n gem is not loaded' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="181">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> before do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="182">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> allow(described_class).to receive(:i18n).and_return(Ruby::Enum::I18nMock)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="183">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="184">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="185">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'raises DuplicateKeyError' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="186">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="187">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors.class_eval do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="188">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> define :RED, 'some'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="189">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="190">
+
+
+
+
+
+ <code class="ruby"> end.to raise_error Ruby::Enum::Errors::DuplicateKeyError, /ruby.enum.errors.messages.duplicate_key.message/</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="191">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="192">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="193">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="194">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="195">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> context 'when a duplicate value is used' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="196">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> context 'when the i18n gem is loaded' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="197">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'raises a DuplicateValueError' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="198">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="199">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors.class_eval do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="200">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> define :Other, 'red'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="201">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="202">
+
+
+
+
+
+ <code class="ruby"> end.to raise_error Ruby::Enum::Errors::DuplicateValueError, /The value red has already been defined./</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="203">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="204">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="205">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="206">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> context 'when the i18n gem is not loaded' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="207">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> before do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="208">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> allow(described_class).to receive(:i18n).and_return(Ruby::Enum::I18nMock)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="209">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="210">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="211">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'raises a DuplicateValueError' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="212">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="213">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> Colors.class_eval do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="214">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> define :Other, 'red'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="215">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="216">
+
+
+
+
+
+ <code class="ruby"> end.to raise_error Ruby::Enum::Errors::DuplicateValueError, /ruby.enum.errors.messages.duplicate_value.summary/</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="217">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="218">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="219">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="220">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="221">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe 'Given a class that has not defined any enums' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="222">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> class EmptyEnums</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="223">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> include Ruby::Enum</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="224">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="225">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="226">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> expect { EmptyEnums::ORANGE }.to raise_error Ruby::Enum::Errors::UninitializedConstantError</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="227">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="228">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="229">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="230">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> context 'when a constant is redefined in a global namespace' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="231">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> before do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="232">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> RED = 'black'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="233">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="234">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="235">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> it { expect(Colors::RED).to eq 'red' }</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="236">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="237">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="238">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe 'Subclass behavior' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="239">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'contains the enums defined in the parent class' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="240">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(FirstSubclass::GREEN).to eq 'green'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="241">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(FirstSubclass::RED).to eq 'red'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="242">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="243">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="244">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'contains its own enums' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="245">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(FirstSubclass::ORANGE).to eq 'orange'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="246">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="247">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="248">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'parent class should not have enums defined in child classes' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="249">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> expect { Colors::ORANGE }.to raise_error Ruby::Enum::Errors::UninitializedConstantError</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="250">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="251">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="252">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> context 'when defining a 2 level depth subclass' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="253">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> subject { SecondSubclass }</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="254">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="255">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'contains its own enums and all the enums defined in the parent classes' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="256">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject::RED).to eq 'red'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="257">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject::GREEN).to eq 'green'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="258">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject::ORANGE).to eq 'orange'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="259">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject::PINK).to eq 'pink'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="260">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="261">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="262">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe '#values' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="263">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> subject { SecondSubclass.values }</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="264">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="265">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'contains the values from all of the parent classes' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="266">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject).to eq(%w[red green orange pink])</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="267">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="268">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="269">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="270">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="271">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe '#values' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="272">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> subject { FirstSubclass.values }</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="273">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="274">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'contains the values from the parent class' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="275">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject).to eq(%w[red green orange])</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="276">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="277">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="278">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="279">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="280">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe 'default value' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="281">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> class Default</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="282">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> include Ruby::Enum</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="283">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> define :KEY</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="284">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="285">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="286">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> subject { Default::KEY }</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="287">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="288">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'equals the key' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="289">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject).to eq(:KEY)</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="290">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="291">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="292">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="293">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> describe 'non constant definitions' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="294">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> class States</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="295">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> include Ruby::Enum</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="296">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> define :created, 'Created'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="297">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> define :published, 'Published'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="298">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> define :undefined</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="299">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="2" data-linenumber="300">
+ <span class="hits">2</span>
+
+
+
+
+ <code class="ruby"> subject { States }</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="301">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="302">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> it 'behaves like an enum' do</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="303">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject.created).to eq 'Created'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="304">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject.published).to eq 'Published'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="305">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject.undefined).to eq :undefined</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="306">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="307">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject.key?(:created)).to be true</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="308">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject.key('Created')).to eq :created</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="309">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="310">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject.value?('Created')).to be true</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="311">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject.value(:created)).to eq 'Created'</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="312">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="313">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject.key?(:undefined)).to be true</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="314">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject.key(:undefined)).to eq :undefined</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="315">
+
+
+
+
+
+ <code class="ruby"></code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="316">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject.value?(:undefined)).to be true</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="covered" data-hits="1" data-linenumber="317">
+ <span class="hits">1</span>
+
+
+
+
+ <code class="ruby"> expect(subject.value(:undefined)).to eq :undefined</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="318">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="319">
+
+
+
+
+
+ <code class="ruby"> end</code>
+ </li>
+ </div>
+
+ <div>
+ <li class="never" data-hits="" data-linenumber="320">
+
+
+
+
+
+ <code class="ruby">end</code>
+ </li>
+ </div>
+
+ </ol>
+ </pre>
+</div>
+
+
+ <div class="source_table" id="96f04bde05e6d83fa459a9ec1c31bce83526eef5">
<div class="header">
<h3>spec/ruby-enum/version_spec.rb</h3>
<h4>
<span class="green">
100.0%