Regenerated docs for version 5.2.0

This commit is contained in:
Pedro Paiva 2022-09-17 11:04:45 -03:00
parent 2f3ee91479
commit eefbbb2a51
28 changed files with 18632 additions and 1 deletions

View File

@ -2,7 +2,7 @@
<html>
<head>
<title>shoulda-matchers Documentation - latest</title>
<meta http-equiv="refresh" content="0;URL=v5.1.0">
<meta http-equiv="refresh" content="0;URL=v5.2.0">
</head>
<body>
</body>

133
docs/v5.2.0/Shoulda.html Normal file
View File

@ -0,0 +1,133 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Shoulda
&mdash; Documentation by YARD 0.9.25
</title>
<link rel="stylesheet" href="css/solarized.css" type="text/css" />
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="css/global.css" type="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "Shoulda";
relpath = '';
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery.stickyheaders.js"></script>
<script type="text/javascript" charset="utf-8" src="js/underscore.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<div id="header">
<div class="header-row">
<div id="menu">
<span class="title">
<a href="index.html" title="Home">Home</a>
</span> &raquo;
<span class="title">Shoulda</span>
</div>
<div id="search" class="js-search">
<ul>
<li>
<a href="class_list.html">
Class List
</a>
</li>
<li>
<a href="method_list.html">
Method List
</a>
</li>
<li>
<a href="file_list.html">
File List
</a>
</li>
</ul>
<iframe id="search_frame" class="js-search-frame"></iframe>
</div>
<div class="clear"></div>
</div>
</div>
<div id="main">
<div id="content"><h1>Module: Shoulda
</h1>
<dl class="box">
</dl>
<h2>Defined Under Namespace</h2>
<p class="children">
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Shoulda/Matchers.html" title="Shoulda::Matchers (module)">Matchers</a></span>
</p>
</div>
<div id="footer">
Generated on
September 17, 2022
by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">YARD</a>.
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,139 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Shoulda::Matchers
&mdash; Documentation by YARD 0.9.25
</title>
<link rel="stylesheet" href="../css/solarized.css" type="text/css" />
<link rel="stylesheet" href="../css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="../css/global.css" type="text/css" />
<link rel="stylesheet" href="../css/style.css" type="text/css" />
<link rel="stylesheet" href="../css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "Shoulda::Matchers";
relpath = '../';
</script>
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/jquery.stickyheaders.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/underscore.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
</head>
<body>
<div id="header">
<div class="header-row">
<div id="menu">
<span class="title">
<a href="../index.html" title="Home">Home</a>
</span> &raquo;
<span class='title'><span class='object_link'><a href="../Shoulda.html" title="Shoulda (module)">Shoulda</a></span></span>
&raquo;
<span class="title">Matchers</span>
</div>
<div id="search" class="js-search">
<ul>
<li>
<a href="../class_list.html">
Class List
</a>
</li>
<li>
<a href="../method_list.html">
Method List
</a>
</li>
<li>
<a href="../file_list.html">
File List
</a>
</li>
</ul>
<iframe id="search_frame" class="js-search-frame"></iframe>
</div>
<div class="clear"></div>
</div>
</div>
<div id="main">
<div id="content"><h1>Module: Shoulda::Matchers
</h1>
<dl class="box">
</dl>
<h2>Defined Under Namespace</h2>
<p class="children">
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Matchers/ActionController.html" title="Shoulda::Matchers::ActionController (module)">ActionController</a></span>, <span class='object_link'><a href="Matchers/ActiveModel.html" title="Shoulda::Matchers::ActiveModel (module)">ActiveModel</a></span>, <span class='object_link'><a href="Matchers/ActiveRecord.html" title="Shoulda::Matchers::ActiveRecord (module)">ActiveRecord</a></span>, <span class='object_link'><a href="Matchers/Independent.html" title="Shoulda::Matchers::Independent (module)">Independent</a></span>
</p>
</div>
<div id="footer">
Generated on
September 17, 2022
by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">YARD</a>.
</div>
</div>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,383 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Shoulda::Matchers::Independent
&mdash; Documentation by YARD 0.9.25
</title>
<link rel="stylesheet" href="../../css/solarized.css" type="text/css" />
<link rel="stylesheet" href="../../css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="../../css/global.css" type="text/css" />
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "Shoulda::Matchers::Independent";
relpath = '../../';
</script>
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/jquery.stickyheaders.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/underscore.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
</head>
<body>
<div id="header">
<div class="header-row">
<div id="menu">
<span class="title">
<a href="../../index.html" title="Home">Home</a>
</span> &raquo;
<span class='title'><span class='object_link'><a href="../../Shoulda.html" title="Shoulda (module)">Shoulda</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Matchers.html" title="Shoulda::Matchers (module)">Matchers</a></span></span>
&raquo;
<span class="title">Independent</span>
</div>
<div id="search" class="js-search">
<ul>
<li>
<a href="../../class_list.html">
Class List
</a>
</li>
<li>
<a href="../../method_list.html">
Method List
</a>
</li>
<li>
<a href="../../file_list.html">
File List
</a>
</li>
</ul>
<iframe id="search_frame" class="js-search-frame"></iframe>
</div>
<div class="clear"></div>
</div>
</div>
<div id="main">
<div id="content"><h1>Module: Shoulda::Matchers::Independent
</h1>
<dl class="box">
</dl>
<h2>Overview</h2><div class="docstring">
<div class="discussion">
<p>This module provides matchers that are used to test behavior outside of
Rails-specific classes.</p>
</div>
</div>
<div class="tags">
</div>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#delegate_method-instance_method" title="#delegate_method (instance method)">#<strong>delegate_method</strong>(delegating_method) &#x21d2; DelegateMethodMatcher </a>
</span>
<span class="summary_desc"><div class='inline'><p>The <code>delegate_method</code> matcher tests that an object forwards messages to other, internal objects by way of delegation.</p>
</div></span>
</li>
</ul>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="delegate_method-instance_method">
#<strong>delegate_method</strong>(delegating_method) &#x21d2; <tt><span class='object_link'>DelegateMethodMatcher</span></tt>
</h3><div class="docstring">
<div class="discussion">
<p>The <code>delegate_method</code> matcher tests that an object forwards messages
to other, internal objects by way of delegation.</p>
<p>In this example, we test that Courier forwards a call to #deliver onto
its PostOffice instance:</p>
<pre class="code ruby"><code class="ruby"><span class="nb">require</span> <span class="s1">'forwardable'</span>
<span class="k">class</span> <span class="nc">Courier</span>
<span class="kp">extend</span> <span class="no">Forwardable</span>
<span class="nb">attr_reader</span> <span class="ss">:post_office</span>
<span class="n">def_delegators</span> <span class="ss">:post_office</span><span class="p">,</span> <span class="ss">:deliver</span>
<span class="k">def</span> <span class="nf">initialize</span>
<span class="vi">@post_office</span> <span class="o">=</span> <span class="no">PostOffice</span><span class="p">.</span><span class="nf">new</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># RSpec</span>
<span class="n">describe</span> <span class="no">Courier</span> <span class="k">do</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:deliver</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:post_office</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="c1"># Minitest</span>
<span class="k">class</span> <span class="nc">CourierTest</span> <span class="o">&lt;</span> <span class="no">Minitest</span><span class="o">::</span><span class="no">Test</span>
<span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:deliver</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:post_office</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
<p>You can also use <code>delegate_method</code> with Rails&#39;s <code>delegate</code> macro:</p>
<pre class="code ruby"><code class="ruby"><span class="k">class</span> <span class="nc">Courier</span>
<span class="nb">attr_reader</span> <span class="ss">:post_office</span>
<span class="n">delegate</span> <span class="ss">:deliver</span><span class="p">,</span> <span class="ss">to: :post_office</span>
<span class="k">def</span> <span class="nf">initialize</span>
<span class="vi">@post_office</span> <span class="o">=</span> <span class="no">PostOffice</span><span class="p">.</span><span class="nf">new</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="n">describe</span> <span class="no">Courier</span> <span class="k">do</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:deliver</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:post_office</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
</code></pre>
<p>To employ some terminology, we would say that Courier&#39;s #deliver method
is the <em>delegating method</em>, PostOffice is the <em>delegate object</em>, and
PostOffice#deliver is the <em>delegate method</em>.</p>
<h4 id="qualifiers">Qualifiers</h4>
<h5 id="as">as</h5>
<p>Use <code>as</code> if the name of the delegate method is different from the name
of the delegating method.</p>
<p>Here, Courier has a #deliver method, but instead of calling #deliver on
the PostOffice, it calls #ship:</p>
<pre class="code ruby"><code class="ruby"><span class="k">class</span> <span class="nc">Courier</span>
<span class="nb">attr_reader</span> <span class="ss">:post_office</span>
<span class="k">def</span> <span class="nf">initialize</span>
<span class="vi">@post_office</span> <span class="o">=</span> <span class="no">PostOffice</span><span class="p">.</span><span class="nf">new</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">deliver</span><span class="p">(</span><span class="n">package</span><span class="p">)</span>
<span class="n">post_office</span><span class="p">.</span><span class="nf">ship</span><span class="p">(</span><span class="n">package</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># RSpec</span>
<span class="n">describe</span> <span class="no">Courier</span> <span class="k">do</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:deliver</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:post_office</span><span class="p">).</span><span class="nf">as</span><span class="p">(</span><span class="ss">:ship</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="c1"># Minitest</span>
<span class="k">class</span> <span class="nc">CourierTest</span> <span class="o">&lt;</span> <span class="no">Minitest</span><span class="o">::</span><span class="no">Test</span>
<span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:deliver</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:post_office</span><span class="p">).</span><span class="nf">as</span><span class="p">(</span><span class="ss">:ship</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
<h5 id="with_prefix">with_prefix</h5>
<p>Use <code>with_prefix</code> when using Rails&#39;s <code>delegate</code> helper along with the
<code>:prefix</code> option.</p>
<pre class="code ruby"><code class="ruby"><span class="k">class</span> <span class="nc">Page</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span>
<span class="n">belongs_to</span> <span class="ss">:site</span>
<span class="n">delegate</span> <span class="ss">:name</span><span class="p">,</span> <span class="ss">to: :site</span><span class="p">,</span> <span class="ss">prefix: </span><span class="kp">true</span>
<span class="n">delegate</span> <span class="ss">:title</span><span class="p">,</span> <span class="ss">to: :site</span><span class="p">,</span> <span class="ss">prefix: :root</span>
<span class="k">end</span>
<span class="c1"># RSpec</span>
<span class="n">describe</span> <span class="no">Page</span> <span class="k">do</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:name</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:site</span><span class="p">).</span><span class="nf">with_prefix</span> <span class="p">}</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:name</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:site</span><span class="p">).</span><span class="nf">with_prefix</span><span class="p">(</span><span class="kp">true</span><span class="p">)</span> <span class="p">}</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:title</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:site</span><span class="p">).</span><span class="nf">with_prefix</span><span class="p">(</span><span class="ss">:root</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="c1"># Minitest</span>
<span class="k">class</span> <span class="nc">PageTest</span> <span class="o">&lt;</span> <span class="no">Minitest</span><span class="o">::</span><span class="no">Test</span>
<span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:name</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:site</span><span class="p">).</span><span class="nf">with_prefix</span>
<span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:name</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:site</span><span class="p">).</span><span class="nf">with_prefix</span><span class="p">(</span><span class="kp">true</span><span class="p">)</span>
<span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:title</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:site</span><span class="p">).</span><span class="nf">with_prefix</span><span class="p">(</span><span class="ss">:root</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
<h5 id="with_arguments">with_arguments</h5>
<p>Use <code>with_arguments</code> to assert that the delegate method is called with
certain arguments. Note that this qualifier can only be used when the
delegating method takes no arguments; it does not support delegating
or delegate methods that take arbitrary arguments.</p>
<p>Here, when Courier#deliver_package calls PostOffice#deliver_package, it
adds an options hash:</p>
<pre class="code ruby"><code class="ruby"><span class="k">class</span> <span class="nc">Courier</span>
<span class="nb">attr_reader</span> <span class="ss">:post_office</span>
<span class="k">def</span> <span class="nf">initialize</span>
<span class="vi">@post_office</span> <span class="o">=</span> <span class="no">PostOffice</span><span class="p">.</span><span class="nf">new</span>
<span class="k">end</span>
<span class="k">def</span> <span class="nf">deliver_package</span>
<span class="n">post_office</span><span class="p">.</span><span class="nf">deliver_package</span><span class="p">(</span><span class="ss">expedited: </span><span class="kp">true</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># RSpec</span>
<span class="n">describe</span> <span class="no">Courier</span> <span class="k">do</span>
<span class="n">it</span> <span class="k">do</span>
<span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:deliver_package</span><span class="p">).</span>
<span class="nf">to</span><span class="p">(</span><span class="ss">:post_office</span><span class="p">).</span>
<span class="nf">with_arguments</span><span class="p">(</span><span class="ss">expedited: </span><span class="kp">true</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># Minitest</span>
<span class="k">class</span> <span class="nc">CourierTest</span> <span class="o">&lt;</span> <span class="no">Minitest</span><span class="o">::</span><span class="no">Test</span>
<span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:deliver_package</span><span class="p">).</span>
<span class="nf">to</span><span class="p">(</span><span class="ss">:post_office</span><span class="p">).</span>
<span class="nf">with_arguments</span><span class="p">(</span><span class="ss">expedited: </span><span class="kp">true</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
<h5 id="allow_nil">allow_nil</h5>
<p>Use <code>allow_nil</code> if the delegation accounts for the fact that your
delegate object could be nil. (This is mostly intended as an analogue to
the <code>allow_nil</code> option that Rails&#39; <code>delegate</code> helper takes.)</p>
<pre class="code ruby"><code class="ruby"><span class="k">class</span> <span class="nc">Account</span>
<span class="n">delegate</span> <span class="ss">:plan</span><span class="p">,</span> <span class="ss">to: :subscription</span><span class="p">,</span> <span class="ss">allow_nil: </span><span class="kp">true</span>
<span class="k">end</span>
<span class="c1"># RSpec</span>
<span class="n">describe</span> <span class="no">Account</span> <span class="k">do</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:plan</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:subscription</span><span class="p">).</span><span class="nf">allow_nil</span> <span class="p">}</span>
<span class="k">end</span>
<span class="c1"># Minitest</span>
<span class="k">class</span> <span class="nc">PageTest</span> <span class="o">&lt;</span> <span class="no">Minitest</span><span class="o">::</span><span class="no">Test</span>
<span class="n">should</span> <span class="n">delegate_method</span><span class="p">(</span><span class="ss">:plan</span><span class="p">).</span><span class="nf">to</span><span class="p">(</span><span class="ss">:subscription</span><span class="p">).</span><span class="nf">allow_nil</span>
<span class="k">end</span>
</code></pre>
</div>
</div>
<div class="tags">
</div><table class="source_code">
<tr>
<td class="lines">
<pre>
173
174
175</pre>
</td>
<td class="code">
<pre><span class="info file"># File 'lib/shoulda/matchers/independent/delegate_method_matcher.rb', line 173</span>
<span class="k">def</span> <span class="nf">delegate_method</span><span class="p">(</span><span class="n">delegating_method</span><span class="p">)</span>
<span class="no">DelegateMethodMatcher</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="n">delegating_method</span><span class="p">).</span><span class="nf">in_context</span><span class="p">(</span><span class="nb">self</span><span class="p">)</span>
<span class="k">end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on
September 17, 2022
by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">YARD</a>.
</div>
</div>
</body>
</html>

200
docs/v5.2.0/_index.html Normal file
View File

@ -0,0 +1,200 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Documentation by YARD 0.9.25
</title>
<link rel="stylesheet" href="css/solarized.css" type="text/css" />
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="css/global.css" type="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/common.css" type="text/css" />
<script type="text/javascript">
pathId = null;
relpath = '';
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery.stickyheaders.js"></script>
<script type="text/javascript" charset="utf-8" src="js/underscore.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<div id="header">
<div class="header-row">
<div id="menu">
<span class="title">
<a href="index.html" title="Home">Home</a>
</span> &raquo;
</div>
<div id="search" class="js-search">
<ul>
<li>
<a href="class_list.html">
Class List
</a>
</li>
<li>
<a href="method_list.html">
Method List
</a>
</li>
<li>
<a href="file_list.html">
File List
</a>
</li>
</ul>
<iframe id="search_frame" class="js-search-frame"></iframe>
</div>
<div class="clear"></div>
</div>
</div>
<div id="main">
<div id="content"><h1 class="noborder title">Documentation by YARD 0.9.25</h1>
<div id="listing">
<h1 class="alphaindex">Alphabetic Index</h1>
<h2>File Listing</h2>
<ul id="files" class="index_inline_list">
<li class="r1"><a href="index.html" title="README">README</a></li>
<li class="r2"><a href="file.CHANGELOG.html" title="CHANGELOG">CHANGELOG</a></li>
<li class="r1"><a href="file.NonCaseSwappableValueError.html" title="NonCaseSwappableValueError">NonCaseSwappableValueError</a></li>
</ul>
<div class="clear"></div>
<h2>Namespace Listing A-Z</h2>
<table>
<tr>
<td valign='top' width="33%">
<ul id="alpha_A" class="alpha">
<li class="letter">A</li>
<ul>
<li>
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html" title="Shoulda::Matchers::ActionController (module)">ActionController</a></span>
<small>(Shoulda::Matchers)</small>
</li>
<li>
<span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html" title="Shoulda::Matchers::ActiveModel (module)">ActiveModel</a></span>
<small>(Shoulda::Matchers)</small>
</li>
<li>
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html" title="Shoulda::Matchers::ActiveRecord (module)">ActiveRecord</a></span>
<small>(Shoulda::Matchers)</small>
</li>
</ul>
</ul>
<ul id="alpha_I" class="alpha">
<li class="letter">I</li>
<ul>
<li>
<span class='object_link'><a href="Shoulda/Matchers/Independent.html" title="Shoulda::Matchers::Independent (module)">Independent</a></span>
<small>(Shoulda::Matchers)</small>
</li>
</ul>
</ul>
<ul id="alpha_M" class="alpha">
<li class="letter">M</li>
<ul>
<li>
<span class='object_link'><a href="Shoulda/Matchers.html" title="Shoulda::Matchers (module)">Matchers</a></span>
<small>(Shoulda)</small>
</li>
</ul>
</ul>
<ul id="alpha_S" class="alpha">
<li class="letter">S</li>
<ul>
<li>
<span class='object_link'><a href="Shoulda.html" title="Shoulda (module)">Shoulda</a></span>
</li>
</ul>
</ul>
</td>
</tr>
</table>
</div>
</div>
<div id="footer">
Generated on
September 17, 2022
by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">YARD</a>.
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,37 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/solarized.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/global.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
<title>Class List</title>
<base id="base_target" target="_parent" />
</head>
<body>
<div id="content">
<h1 id="full_list_header">Class List</h1>
<ul id="full_list" class="class">
<li id='object_Shoulda' class='even'><div class='item'><a class='toggle'></a> <span class='object_link'><a href="Shoulda.html" title="Shoulda (module)">Shoulda</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Shoulda::Matchers' class='collapsed odd'><div class='item'><a class='toggle'></a> <span class='object_link'><a href="Shoulda/Matchers.html" title="Shoulda::Matchers (module)">Matchers</a></span><small class='search_info'>Shoulda</small></div><ul><li id='object_Shoulda::Matchers::ActionController' class='collapsed'><div class='item'><span class='object_link'><a href="Shoulda/Matchers/ActionController.html" title="Shoulda::Matchers::ActionController (module)">ActionController</a></span><small class='search_info'>Shoulda::Matchers</small></div></li><li id='object_Shoulda::Matchers::ActiveModel' class='collapsed'><div class='item'><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html" title="Shoulda::Matchers::ActiveModel (module)">ActiveModel</a></span><small class='search_info'>Shoulda::Matchers</small></div></li><li id='object_Shoulda::Matchers::ActiveRecord' class='collapsed'><div class='item'><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html" title="Shoulda::Matchers::ActiveRecord (module)">ActiveRecord</a></span><small class='search_info'>Shoulda::Matchers</small></div></li><li id='object_Shoulda::Matchers::Independent' class='collapsed'><div class='item'><span class='object_link'><a href="Shoulda/Matchers/Independent.html" title="Shoulda::Matchers::Independent (module)">Independent</a></span><small class='search_info'>Shoulda::Matchers</small></div></li></ul></li></ul></li>
</ul>
</div>
</body>
</html>

5967
docs/v5.2.0/css/bootstrap.css vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
/* Override this file with custom rules */

View File

@ -0,0 +1,12 @@
body {
font-size: 14px;
padding: 20px;
}
h1 {
font-size: 1.5em;
}
.search_info, .toggle {
display: none;
}

View File

@ -0,0 +1,68 @@
@import "https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,300italic,400,400italic,600,600italic,800|Droid+Sans+Mono";
body {
font-size: 16px;
line-height: 1.5;
}
a, a:hover {
color: #136cc6;
}
h1, h2, h3, h4, h5, h6, p, pre {
margin-bottom: 1em;
margin-top: 0;
}
h1, h2, h3, h4, h5, h6, body {
font-family: "Source Sans Pro", sans-serif;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 800;
}
pre, tt, code {
background: #FFFBF4;
border-radius: 3px;
border: 1px solid rgba(0,0,0,0.1);
font-family: "Droid Sans Mono", monospace;
font-size: 13px;
}
pre code {
border: none;
}
tt, code {
color: black;
padding: 0 4px;
}
ul, ol {
margin-left: 1em;
padding-left: 1em;
}
p, blockquote {
margin-bottom: 1.25em;
}
blockquote {
font-style: italic;
padding-top: 0;
padding-bottom: 0;
padding-left: 1em;
}
blockquote p {
font-size: inherit;
font-weight: inherit;
line-height: inherit;
}
/*
ul ul, ol ol, ul ol, ol ul {
margin-bottom: 1.25em;
}
*/

View File

@ -0,0 +1,69 @@
pre, code { background-color: #fdf6e3; color: #586e75 }
pre .c { color: #93a1a1 } /* Comment */
pre .err { color: #586e75 } /* Error */
pre .g { color: #586e75 } /* Generic */
pre .k { color: #859900 } /* Keyword */
pre .l { color: #586e75 } /* Literal */
pre .n { color: #586e75 } /* Name */
pre .o { color: #859900 } /* Operator */
pre .x { color: #cb4b16 } /* Other */
pre .p { color: #586e75 } /* Punctuation */
pre .cm { color: #93a1a1 } /* Comment.Multiline */
pre .cp { color: #859900 } /* Comment.Preproc */
pre .c1 { color: #93a1a1 } /* Comment.Single */
pre .cs { color: #859900 } /* Comment.Special */
pre .gd { color: #2aa198 } /* Generic.Deleted */
pre .ge { color: #586e75; font-style: italic } /* Generic.Emph */
pre .gr { color: #dc322f } /* Generic.Error */
pre .gh { color: #cb4b16 } /* Generic.Heading */
pre .gi { color: #859900 } /* Generic.Inserted */
pre .go { color: #586e75 } /* Generic.Output */
pre .gp { color: #586e75 } /* Generic.Prompt */
pre .gs { color: #586e75; font-weight: bold } /* Generic.Strong */
pre .gu { color: #cb4b16 } /* Generic.Subheading */
pre .gt { color: #586e75 } /* Generic.Traceback */
pre .kc { color: #cb4b16 } /* Keyword.Constant */
pre .kd { color: #268bd2 } /* Keyword.Declaration */
pre .kn { color: #859900 } /* Keyword.Namespace */
pre .kp { color: #859900 } /* Keyword.Pseudo */
pre .kr { color: #268bd2 } /* Keyword.Reserved */
pre .kt { color: #dc322f } /* Keyword.Type */
pre .ld { color: #586e75 } /* Literal.Date */
pre .m { color: #2aa198 } /* Literal.Number */
pre .s { color: #2aa198 } /* Literal.String */
pre .na { color: #586e75 } /* Name.Attribute */
pre .nb { color: #B58900 } /* Name.Builtin */
pre .nc { color: #268bd2 } /* Name.Class */
pre .no { color: #cb4b16 } /* Name.Constant */
pre .nd { color: #268bd2 } /* Name.Decorator */
pre .ni { color: #cb4b16 } /* Name.Entity */
pre .ne { color: #cb4b16 } /* Name.Exception */
pre .nf { color: #268bd2 } /* Name.Function */
pre .nl { color: #586e75 } /* Name.Label */
pre .nn { color: #586e75 } /* Name.Namespace */
pre .nx { color: #586e75 } /* Name.Other */
pre .py { color: #586e75 } /* Name.Property */
pre .nt { color: #268bd2 } /* Name.Tag */
pre .nv { color: #268bd2 } /* Name.Variable */
pre .ow { color: #859900 } /* Operator.Word */
pre .w { color: #586e75 } /* Text.Whitespace */
pre .mf { color: #2aa198 } /* Literal.Number.Float */
pre .mh { color: #2aa198 } /* Literal.Number.Hex */
pre .mi { color: #2aa198 } /* Literal.Number.Integer */
pre .mo { color: #2aa198 } /* Literal.Number.Oct */
pre .sb { color: #93a1a1 } /* Literal.String.Backtick */
pre .sc { color: #2aa198 } /* Literal.String.Char */
pre .sd { color: #586e75 } /* Literal.String.Doc */
pre .s2 { color: #2aa198 } /* Literal.String.Double */
pre .se { color: #cb4b16 } /* Literal.String.Escape */
pre .sh { color: #586e75 } /* Literal.String.Heredoc */
pre .si { color: #2aa198 } /* Literal.String.Interpol */
pre .sx { color: #2aa198 } /* Literal.String.Other */
pre .sr { color: #dc322f } /* Literal.String.Regex */
pre .s1 { color: #2aa198 } /* Literal.String.Single */
pre .ss { color: #2aa198 } /* Literal.String.Symbol */
pre .bp { color: #268bd2 } /* Name.Builtin.Pseudo */
pre .vc { color: #268bd2 } /* Name.Variable.Class */
pre .vg { color: #268bd2 } /* Name.Variable.Global */
pre .vi { color: #268bd2 } /* Name.Variable.Instance */
pre .il { color: #2aa198 } /* Literal.Number.Integer.Long */

312
docs/v5.2.0/css/style.css Normal file
View File

@ -0,0 +1,312 @@
/******** LAYOUT *********/
h1 {
font-size: 2.2em;
margin-top: 1em;
}
h2 {
font-size: 2em;
}
h2, h3 {
margin-top: 1em;
padding-top: 0.5em;
}
h4, h5 {
margin-top: 1em;
}
h1 + h2,
h2 + h3,
h2 + .method_details h3,
h4 + h5 {
margin-top: 0;
}
#main h3 tt,
#sticky-header tt {
background: transparent;
border: none;
font-family: "Source Sans Pro", sans-serif;
font-size: 1em;
font-style: italic;
font-weight: normal;
padding: 0;
}
#main h2,
#main h3,
#sticky-header h2,
#sticky-header h3 {
border: none;
padding-bottom: 0;
}
#main h2,
#sticky-header h2 {
font-size: 1.8em;
}
#main h3,
#sticky-header h3 {
font-size: 1.5em;
font-style: italic;
}
#main h4,
#sticky-header h4 {
border-bottom: 1px solid rgba(0,0,0,0.3);
font-size: 1.4em;
font-style: italic;
padding-bottom: 2px;
}
#main h5,
#sticky-header h5 {
font-size: 1.1em;
}
#sticky-header h2,
#sticky-header h3,
#sticky-header h4 {
line-height: inherit;
margin: 0;
padding: 0;
}
/* Header */
#header, #main {
position: absolute;
}
#header {
left: 0;
right: 0;
top: 0;
}
#menu, #search {
height: 6rem;
line-height: 6rem;
font-size: 1.1em;
}
#main {
top: 6rem;
}
#menu {
float: left;
padding-left: 2em;
position: relative;
width: 45em;
}
#menu .noframes {
display: inline;
}
#search {
float: right;
}
#search ul {
list-style: none;
}
#search ul, #search li {
margin: 0;
padding: 0;
display: inline;
}
#search a {
border-left: 1px solid rgba(0,0,0,0.3);
float: left;
padding: 0 2em;
text-align: center;
text-decoration: none;
-webkit-transition: 0.1s background-color, 0.1s color;
-moz-transition: 0.1s background-color, 0.1s color;
transition: 0.1s background-color, 0.1s color;
}
#search a:hover {
background-color: #f0f8ff;
}
#search .active a {
background-color: #136cc6;
border-left-color: #136cc6;
color: white;
}
#search .active + li a {
border-left-color: #136cc6;
}
#search_frame {
background: white;
border: 1px solid rgba(0,0,0,0.2);
box-shadow: 0px 2px 3px 0px rgba(0,0,0,0.3);
height: 0;
opacity: 0;
position: absolute;
right: 0;
top: 100%;
-webkit-transition: 0.1s height ease-in-out, 0.1s opacity 0.05s;
-moz-transition: 0.1s height ease-in-out, 0.1s opacity 0.05s;
transition: 0.1s height ease-in-out, 0.1s opacity 0.05s;
width: 500px;
z-index: 9999;
}
#search_frame.open {
height: 500px;
opacity: 1;
-webkit-transition: 0.1s height ease-in-out, 0.1s opacity;
-moz-transition: 0.1s height ease-in-out, 0.1s opacity;
transition: 0.1s height ease-in-out, 0.1s opacity;
}
/* Main */
#main {
border-top: 1px solid rgba(0,0,0,0.2);
bottom: 0;
left: 0;
overflow-y: auto;
right: 0;
}
#content {
padding-bottom: 1.5em;
padding-left: 2em;
padding-right: 2em;
}
#toc {
display: none;
}
/* Footer */
#footer {
background-color: rgba(0,0,0,0.3);
color: white;
font-weight: 100;
padding: 10px;
text-align: center;
text-shadow: 0 1px 1px rgba(0,0,0,0.4);
font-size: 0.9em;
}
#footer a {
color: #ffedd5;
}
/* Class/Module */
.summary .deprecated {
display: none;
}
.method_details {}
.method_details .signature .aliases {
display: none;
}
.method_details td {
padding: 10px;
}
.method_details .showSource {
display: block;
margin-bottom: 1em;
}
.method_details .source_code {
border: 1px solid rgba(0,0,0,0.1);
display: none;
overflow: auto;
width: 100%;
}
.method_details .source_code pre {
background-color: transparent;
border-radius: 0;
border: none;
color: inherit;
margin-bottom: 0;
padding: 0;
}
.method_details .source_code td {
border: 1px solid rgba(0,0,0,0.1);
}
.method_details .source_code td.lines {
background-color: #f0f0f0;
color: #93a1a1;
width: 50px;
}
.method_details .source_code td.code {
background-color: #f8f8f8;
}
.method_details .source_code td.code pre .info {
color: #93a1a1 /* Comment */
}
.method_details .deprecated {
margin-bottom: 1em;
font-size: 1.1em;
}
.method_details .deprecated strong {
background-color: #F03434;
color: white;
text-transform: uppercase;
border-radius: 3px;
padding: 0 4px;
}
.method_details .deprecated .inline {
padding-left: 3px;
}
.method_details .deprecated div,
.method_details .deprecated p {
display: inline
}
.docstring, .method_details .showSource, .method_details .source_code {
margin-left: 1em;
}
#sticky-header {
background-color: rgba(255,255,255,0.8);
border-bottom: 1px solid rgba(0,0,0,0.2);
height: 3em;
line-height: 3em;
opacity: 0;
padding-left: 2em; /* same as content padding */
padding-right: 2em; /* same as content padding */
position: fixed;
text-align: right;
top: 6.1rem;
-webkit-transition: 0.1s opacity ease-in-out;
-moz-transition: 0.1s opacity ease-in-out;
transition: 0.1s opacity ease-in-out;
width: 100%;
z-index: 999;
}
#sticky-header.show {
opacity: 1;
}
.clear {
clear: both;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,217 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
File: NonCaseSwappableValueError
&mdash; Documentation by YARD 0.9.25
</title>
<link rel="stylesheet" href="css/solarized.css" type="text/css" />
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="css/global.css" type="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "NonCaseSwappableValueError";
relpath = '';
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery.stickyheaders.js"></script>
<script type="text/javascript" charset="utf-8" src="js/underscore.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<div id="header">
<div class="header-row">
<div id="menu">
<span class="title">
<a href="index.html" title="Home">Home</a>
</span> &raquo;
<span class="title">NonCaseSwappableValueError</span>
</div>
<div id="search" class="js-search">
<ul>
<li>
<a href="class_list.html">
Class List
</a>
</li>
<li>
<a href="method_list.html">
Method List
</a>
</li>
<li>
<a href="file_list.html">
File List
</a>
</li>
</ul>
<iframe id="search_frame" class="js-search-frame"></iframe>
</div>
<div class="clear"></div>
</div>
</div>
<div id="main">
<div id="content"><div id='filecontents'><h1 id="noncaseswappablevalueerror">NonCaseSwappableValueError</h1>
<p>This error is raised when using <code>validate_uniqueness_of</code>. This matcher, of
course, tests that an attribute disallows a non-unique value -- and what
constitutes as &quot;unique&quot; depends on whether the case-sensitivity of that value
matters. If it does matter -- meaning that the uniqueness validation in your
model isn&#39;t using <code>case_sensitive: false</code> and you haven&#39;t qualified the matcher
with <code>case_insensitive</code> -- then the matcher will run the following test:</p>
<blockquote>
<p>Creating first a record with a value of &quot;A&quot;:</p>
<ul>
<li>A new record with a value of &quot;A&quot; should not be valid (failing the uniqueness
validation)</li>
<li>A new record with a value of &quot;a&quot; should be valid</li>
</ul>
</blockquote>
<p>The test value we&#39;re using is in this case &quot;A&quot;, and this is what the matcher
will use if an existing record is not already present in the database. But if
a record already exists, then the matcher will use it as comparison -- it will
read the attribute under test off of the record and use its value. So a better
example might be:</p>
<blockquote>
<p>Given an existing record with a value:</p>
<ul>
<li>A new record with the same value should not be valid (failing the uniqueness
validation)</li>
<li>A new record with the same value, but where the case is swapped (using
String#swapcase), should be valid</li>
</ul>
</blockquote>
<p>Now, what happens if an existing record is there, but the value being used is
not one whose case can be swapped, such as <code>&quot;123&quot;</code> or <code>&quot;{-#%}&quot;</code>? Then the second
assertion cannot be made effectively.</p>
<p>So this is why you&#39;re getting this exception. What can you do about it? As the
error message explains, you have two options:</p>
<ol>
<li><p>If you want the uniqueness validation in the model to operate
case-sensitively and you didn&#39;t mean to use a non-case-swappable value,
then you need to provide an existing record with a different value, one that
contains alpha characters. Here&#39;s an example:</p>
<pre class="code ruby"><code class="ruby"><span class="c1"># Model</span>
<span class="k">class</span> <span class="nc">User</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span>
<span class="n">validates_uniqueness_of</span> <span class="ss">:username</span>
<span class="k">end</span>
<span class="c1"># RSpec</span>
<span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">User</span><span class="p">,</span> <span class="ss">type: :model</span> <span class="k">do</span>
<span class="n">context</span> <span class="s2">"validations"</span> <span class="k">do</span>
<span class="n">subject</span> <span class="k">do</span>
<span class="c1"># Note that "123" == "123".swapcase. This is a problem!</span>
<span class="no">User</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="ss">username: </span><span class="s2">"123"</span><span class="p">)</span>
<span class="k">end</span>
<span class="n">it</span> <span class="k">do</span>
<span class="c1"># So you can either override it like this, or just fix the subject.</span>
<span class="n">user</span> <span class="o">=</span> <span class="no">User</span><span class="p">.</span><span class="nf">create!</span><span class="p">(</span><span class="ss">username: </span><span class="s2">"john123"</span><span class="p">)</span>
<span class="n">expect</span><span class="p">(</span><span class="n">user</span><span class="p">).</span><span class="nf">to</span> <span class="n">validate_uniqueness_of</span><span class="p">(</span><span class="ss">:username</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># Minitest (Shoulda)</span>
<span class="k">class</span> <span class="nc">UserTest</span> <span class="o">&lt;</span> <span class="no">ActiveSupport</span><span class="o">::</span><span class="no">TestCase</span>
<span class="n">context</span> <span class="s2">"validations"</span> <span class="k">do</span>
<span class="n">subject</span> <span class="k">do</span>
<span class="c1"># Note that "123" == "123".swapcase. This is a problem!</span>
<span class="no">User</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="ss">username: </span><span class="s2">"123"</span><span class="p">)</span>
<span class="k">end</span>
<span class="n">should</span> <span class="s2">"validate uniqueness of :username"</span> <span class="k">do</span>
<span class="c1"># So you can either override it like this, or just fix the subject.</span>
<span class="n">user</span> <span class="o">=</span> <span class="no">User</span><span class="p">.</span><span class="nf">create!</span><span class="p">(</span><span class="ss">username: </span><span class="s2">"john123"</span><span class="p">)</span>
<span class="n">assert_accepts</span> <span class="n">validate_uniqueness_of</span><span class="p">(</span><span class="ss">:username</span><span class="p">),</span> <span class="n">record</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></li>
<li><p>If you don&#39;t want the uniqueness validation to operate case-sensitively,
then you need to add <code>case_sensitive: false</code> to the validation and add
<code>case_insensitive</code> to the matcher:</p>
<pre class="code ruby"><code class="ruby"><span class="c1"># Model</span>
<span class="k">class</span> <span class="nc">User</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span>
<span class="n">validates_uniqueness_of</span> <span class="ss">:username</span><span class="p">,</span> <span class="ss">case_sensitive: </span><span class="kp">false</span>
<span class="k">end</span>
<span class="c1"># RSpec</span>
<span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">User</span><span class="p">,</span> <span class="ss">type: :model</span> <span class="k">do</span>
<span class="n">context</span> <span class="s2">"validations"</span> <span class="k">do</span>
<span class="n">subject</span> <span class="k">do</span>
<span class="c1"># Note that "123" == "123".swapcase, but it's okay</span>
<span class="no">User</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="ss">username: </span><span class="s2">"123"</span><span class="p">)</span>
<span class="k">end</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">validate_uniqueness_of</span><span class="p">(</span><span class="ss">:username</span><span class="p">).</span><span class="nf">case_insensitive</span> <span class="p">}</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># Minitest (Shoulda)</span>
<span class="k">class</span> <span class="nc">UserTest</span> <span class="o">&lt;</span> <span class="no">ActiveSupport</span><span class="o">::</span><span class="no">TestCase</span>
<span class="n">context</span> <span class="s2">"validations"</span> <span class="k">do</span>
<span class="n">subject</span> <span class="k">do</span>
<span class="c1"># Note that "123" == "123".swapcase, but it's okay</span>
<span class="no">User</span><span class="p">.</span><span class="nf">new</span><span class="p">(</span><span class="ss">username: </span><span class="s2">"123"</span><span class="p">)</span>
<span class="k">end</span>
<span class="n">should</span> <span class="n">validate_uniqueness_of</span><span class="p">(</span><span class="ss">:username</span><span class="p">).</span><span class="nf">case_insensitive</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre></li>
</ol>
</div></div>
<div id="footer">
Generated on
September 17, 2022
by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">YARD</a>.
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,592 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
File: README
&mdash; Documentation by YARD 0.9.25
</title>
<link rel="stylesheet" href="css/solarized.css" type="text/css" />
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="css/global.css" type="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "README";
relpath = '';
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery.stickyheaders.js"></script>
<script type="text/javascript" charset="utf-8" src="js/underscore.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<div id="header">
<div class="header-row">
<div id="menu">
<span class="title">README</span>
</div>
<div id="search" class="js-search">
<ul>
<li>
<a href="class_list.html">
Class List
</a>
</li>
<li>
<a href="method_list.html">
Method List
</a>
</li>
<li>
<a href="file_list.html">
File List
</a>
</li>
</ul>
<iframe id="search_frame" class="js-search-frame"></iframe>
</div>
<div class="clear"></div>
</div>
</div>
<div id="main">
<div id="content"><div id='filecontents'><h1 id="shoulda-matchers">Shoulda Matchers <a href="https://rubygems.org/gems/shoulda-matchers"><img src="https://img.shields.io/gem/v/shoulda-matchers.svg" alt="Gem Version"></a> <a href="https://github.com/thoughtbot/shoulda-matchers/actions"><img src="https://img.shields.io/github/workflow/status/thoughtbot/shoulda-matchers/Test" alt="Build Status"></a> <a href="https://rubygems.org/gems/shoulda-matchers"><img src="https://img.shields.io/gem/dt/shoulda-matchers.svg" alt="Total Downloads"></a> <a href="https://rubygems.org/gems/shoulda-matchers"><img src="https://img.shields.io/gem/dtv/shoulda-matchers.svg" alt="Downloads"></a></h1>
<p><a href="https://matchers.shoulda.io/"><img src="https://matchers.shoulda.io/images/shoulda-matchers-logo.png" alt="shoulda-matchers"></a></p>
<p>Shoulda Matchers provides RSpec- and Minitest-compatible one-liners to test
common Rails functionality that, if written by hand, would be much longer, more
complex, and error-prone.</p>
<h2 id="quick-links">Quick links</h2>
<p>📖 <strong><a href="https://matchers.shoulda.io/docs">Read the documentation for the latest version</a>.</strong>
📢 <strong><a href="CHANGELOG.md">See what&#39;s changed in recent versions</a>.</strong></p>
<h2 id="table-of-contents">Table of contents</h2>
<ul>
<li><a href="#getting-started">Getting started</a>
<ul>
<li><a href="#rspec">RSpec</a></li>
<li><a href="#minitest">Minitest</a></li>
</ul></li>
<li><a href="#usage">Usage</a>
<ul>
<li><a href="#on-the-subject-of-subject">On the subject of <code>subject</code></a></li>
<li><a href="#availability-of-rspec-matchers-in-example-groups">Availability of RSpec matchers in example groups</a></li>
<li><a href="#should-vs-is_expectedto"><code>should</code> vs <code>is_expected.to</code></a></li>
</ul></li>
<li><a href="#matchers">Matchers</a>
<ul>
<li><a href="#activemodel-matchers">ActiveModel matchers</a></li>
<li><a href="#activerecord-matchers">ActiveRecord matchers</a></li>
<li><a href="#actioncontroller-matchers">ActionController matchers</a></li>
<li><a href="#independent-matchers">Independent matchers</a></li>
</ul></li>
<li><a href="#extensions">Extensions</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#compatibility">Compatibility</a></li>
<li><a href="#versioning">Versioning</a></li>
<li><a href="#team">Team</a></li>
<li><a href="#copyright-license">Copyright/License</a></li>
<li><a href="#about-thoughtbot">About thoughtbot</a></li>
</ul>
<h2 id="getting-started">Getting started</h2>
<h3 id="rspec">RSpec</h3>
<p>Start by including <code>shoulda-matchers</code> in your Gemfile:</p>
<pre class="code ruby"><code class="ruby"><span class="n">group</span> <span class="ss">:test</span> <span class="k">do</span>
<span class="n">gem</span> <span class="s1">'shoulda-matchers'</span><span class="p">,</span> <span class="s1">'~&gt; 5.0'</span>
<span class="k">end</span>
</code></pre>
<p>Then run <code>bundle install</code>.</p>
<p>Now you need to configure the gem by telling it:</p>
<ul>
<li>which matchers you want to use in your tests</li>
<li>that you&#39;re using RSpec so that it can make those matchers available in
your example groups</li>
</ul>
<h4 id="rails-apps">Rails apps</h4>
<p>If you&#39;re working on a Rails app, simply place this at the bottom of
<code>spec/rails_helper.rb</code> (or in a support file if you so choose):</p>
<pre class="code ruby"><code class="ruby"><span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="p">.</span><span class="nf">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">integrate</span> <span class="k">do</span> <span class="o">|</span><span class="n">with</span><span class="o">|</span>
<span class="n">with</span><span class="p">.</span><span class="nf">test_framework</span> <span class="ss">:rspec</span>
<span class="n">with</span><span class="p">.</span><span class="nf">library</span> <span class="ss">:rails</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h4 id="non-rails-apps">Non-Rails apps</h4>
<p>If you&#39;re not working on a Rails app, but you still make use of ActiveRecord or
ActiveModel in your project, you can still use this gem too! In that case,
you&#39;ll want to place the following configuration at the bottom of
<code>spec/spec_helper.rb</code>:</p>
<pre class="code ruby"><code class="ruby"><span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="p">.</span><span class="nf">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">integrate</span> <span class="k">do</span> <span class="o">|</span><span class="n">with</span><span class="o">|</span>
<span class="n">with</span><span class="p">.</span><span class="nf">test_framework</span> <span class="ss">:rspec</span>
<span class="c1"># Keep as many of these lines as are necessary:</span>
<span class="n">with</span><span class="p">.</span><span class="nf">library</span> <span class="ss">:active_record</span>
<span class="n">with</span><span class="p">.</span><span class="nf">library</span> <span class="ss">:active_model</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h3 id="minitest">Minitest</h3>
<p>If you&#39;re using our umbrella gem <a href="https://github.com/thoughtbot/shoulda">Shoulda</a>, then make sure that you&#39;re using the
latest version:</p>
<pre class="code ruby"><code class="ruby"><span class="n">group</span> <span class="ss">:test</span> <span class="k">do</span>
<span class="n">gem</span> <span class="s1">'shoulda'</span><span class="p">,</span> <span class="s1">'~&gt; 4.0'</span>
<span class="k">end</span>
</code></pre>
<p>Otherwise, add <code>shoulda-matchers</code> to your Gemfile:</p>
<pre class="code ruby"><code class="ruby"><span class="n">group</span> <span class="ss">:test</span> <span class="k">do</span>
<span class="n">gem</span> <span class="s1">'shoulda-matchers'</span><span class="p">,</span> <span class="s1">'~&gt; 5.0'</span>
<span class="k">end</span>
</code></pre>
<p>Then run <code>bundle install</code>.</p>
<p>Now you need to configure the gem by telling it:</p>
<ul>
<li>which matchers you want to use in your tests</li>
<li>that you&#39;re using Minitest so that it can make those matchers available in
your test case classes</li>
</ul>
<h4 id="rails-apps">Rails apps</h4>
<p>If you&#39;re working on a Rails app, simply place this at the bottom of
<code>test/test_helper.rb</code>:</p>
<pre class="code ruby"><code class="ruby"><span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="p">.</span><span class="nf">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">integrate</span> <span class="k">do</span> <span class="o">|</span><span class="n">with</span><span class="o">|</span>
<span class="n">with</span><span class="p">.</span><span class="nf">test_framework</span> <span class="ss">:minitest</span>
<span class="n">with</span><span class="p">.</span><span class="nf">library</span> <span class="ss">:rails</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h4 id="non-rails-apps">Non-Rails apps</h4>
<p>If you&#39;re not working on a Rails app, but you still make use of ActiveRecord or
ActiveModel in your project, you can still use this gem too! In that case,
you&#39;ll want to place the following configuration at the bottom of
<code>test/test_helper.rb</code>:</p>
<pre class="code ruby"><code class="ruby"><span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="p">.</span><span class="nf">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">integrate</span> <span class="k">do</span> <span class="o">|</span><span class="n">with</span><span class="o">|</span>
<span class="n">with</span><span class="p">.</span><span class="nf">test_framework</span> <span class="ss">:minitest</span>
<span class="c1"># Keep as many of these lines as are necessary:</span>
<span class="n">with</span><span class="p">.</span><span class="nf">library</span> <span class="ss">:active_record</span>
<span class="n">with</span><span class="p">.</span><span class="nf">library</span> <span class="ss">:active_model</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h2 id="usage">Usage</h2>
<p>Most of the matchers provided by this gem are useful in a Rails context, and as
such, can be used for different parts of a Rails app:</p>
<ul>
<li><a href="#activemodel-matchers">database models backed by ActiveRecord</a></li>
<li><a href="#activerecord-matchers">non-database models, form objects, etc. backed by
ActiveModel</a></li>
<li><a href="#actioncontroller-matchers">controllers</a></li>
<li><a href="#routing-matchers">routes</a> (RSpec only)</li>
<li><a href="#independent-matchers">Rails-specific features like <code>delegate</code></a></li>
</ul>
<p>As the name of the gem indicates, most matchers are designed to be used in
&quot;one-liner&quot; form using the <code>should</code> macro, a special directive available in both
RSpec and <a href="https://github.com/thoughtbot/shoulda">Shoulda</a>. For instance, a model test case may look something like:</p>
<pre class="code ruby"><code class="ruby"><span class="c1"># RSpec</span>
<span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">MenuItem</span><span class="p">,</span> <span class="ss">type: :model</span> <span class="k">do</span>
<span class="n">describe</span> <span class="s1">'associations'</span> <span class="k">do</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">belong_to</span><span class="p">(</span><span class="ss">:category</span><span class="p">).</span><span class="nf">class_name</span><span class="p">(</span><span class="s1">'MenuCategory'</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="n">describe</span> <span class="s1">'validations'</span> <span class="k">do</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">validate_presence_of</span><span class="p">(</span><span class="ss">:name</span><span class="p">)</span> <span class="p">}</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">validate_uniqueness_of</span><span class="p">(</span><span class="ss">:name</span><span class="p">).</span><span class="nf">scoped_to</span><span class="p">(</span><span class="ss">:category_id</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># Minitest (Shoulda)</span>
<span class="k">class</span> <span class="nc">MenuItemTest</span> <span class="o">&lt;</span> <span class="no">ActiveSupport</span><span class="o">::</span><span class="no">TestCase</span>
<span class="n">context</span> <span class="s1">'associations'</span> <span class="k">do</span>
<span class="n">should</span> <span class="n">belong_to</span><span class="p">(</span><span class="ss">:category</span><span class="p">).</span><span class="nf">class_name</span><span class="p">(</span><span class="s1">'MenuCategory'</span><span class="p">)</span>
<span class="k">end</span>
<span class="n">context</span> <span class="s1">'validations'</span> <span class="k">do</span>
<span class="n">should</span> <span class="n">validate_presence_of</span><span class="p">(</span><span class="ss">:name</span><span class="p">)</span>
<span class="n">should</span> <span class="n">validate_uniqueness_of</span><span class="p">(</span><span class="ss">:name</span><span class="p">).</span><span class="nf">scoped_to</span><span class="p">(</span><span class="ss">:category_id</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p><a href="#matchers">See below</a> for the full set of matchers that you can use.</p>
<h3 id="on-the-subject-of-subject">On the subject of <code>subject</code></h3>
<p>For both RSpec and Shoulda, the <strong>subject</strong> is an implicit reference to the
object under test, and through the use of <code>should</code> as demonstrated above, all of
the matchers make use of <code>subject</code> internally when they are run. A <code>subject</code> is
always set automatically by your test framework in any given test case; however,
in certain cases it can be advantageous to override it. For instance, when
testing validations in a model, it is customary to provide a valid model instead
of a fresh one:</p>
<pre class="code ruby"><code class="ruby"><span class="c1"># RSpec</span>
<span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">Post</span><span class="p">,</span> <span class="ss">type: :model</span> <span class="k">do</span>
<span class="n">describe</span> <span class="s1">'validations'</span> <span class="k">do</span>
<span class="c1"># Here we're using FactoryBot, but you could use anything</span>
<span class="n">subject</span> <span class="p">{</span> <span class="n">build</span><span class="p">(</span><span class="ss">:post</span><span class="p">)</span> <span class="p">}</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">validate_presence_of</span><span class="p">(</span><span class="ss">:title</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># Minitest (Shoulda)</span>
<span class="k">class</span> <span class="nc">PostTest</span> <span class="o">&lt;</span> <span class="no">ActiveSupport</span><span class="o">::</span><span class="no">TestCase</span>
<span class="n">context</span> <span class="s1">'validations'</span> <span class="k">do</span>
<span class="n">subject</span> <span class="p">{</span> <span class="n">build</span><span class="p">(</span><span class="ss">:post</span><span class="p">)</span> <span class="p">}</span>
<span class="n">should</span> <span class="n">validate_presence_of</span><span class="p">(</span><span class="ss">:title</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>When overriding the subject in this manner, then, it&#39;s important to provide the
correct object. <strong>When in doubt, provide an instance of the class under test.</strong>
This is particularly necessary for controller tests, where it is easy to
accidentally write something like:</p>
<pre class="code ruby"><code class="ruby"><span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">PostsController</span><span class="p">,</span> <span class="ss">type: :controller</span> <span class="k">do</span>
<span class="n">describe</span> <span class="s1">'GET #index'</span> <span class="k">do</span>
<span class="n">subject</span> <span class="p">{</span> <span class="n">get</span> <span class="ss">:index</span> <span class="p">}</span>
<span class="c1"># This may work...</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">have_http_status</span><span class="p">(</span><span class="ss">:success</span><span class="p">)</span> <span class="p">}</span>
<span class="c1"># ...but this will not!</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">permit</span><span class="p">(</span><span class="ss">:title</span><span class="p">,</span> <span class="ss">:body</span><span class="p">).</span><span class="nf">for</span><span class="p">(</span><span class="ss">:post</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>In this case, you would want to use <code>before</code> rather than <code>subject</code>:</p>
<pre class="code ruby"><code class="ruby"><span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">PostsController</span><span class="p">,</span> <span class="ss">type: :controller</span> <span class="k">do</span>
<span class="n">describe</span> <span class="s1">'GET #index'</span> <span class="k">do</span>
<span class="n">before</span> <span class="p">{</span> <span class="n">get</span> <span class="ss">:index</span> <span class="p">}</span>
<span class="c1"># Notice that we have to assert have_http_status on the response here...</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">expect</span><span class="p">(</span><span class="n">response</span><span class="p">).</span><span class="nf">to</span> <span class="n">have_http_status</span><span class="p">(</span><span class="ss">:success</span><span class="p">)</span> <span class="p">}</span>
<span class="c1"># ...but we do not have to provide a subject for render_template</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">render_template</span><span class="p">(</span><span class="s1">'index'</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h3 id="availability-of-rspec-matchers-in-example-groups">Availability of RSpec matchers in example groups</h3>
<h4 id="rails-projects">Rails projects</h4>
<p>If you&#39;re using RSpec, then you&#39;re probably familiar with the concept of example
groups. Example groups can be assigned tags order to assign different behavior
to different kinds of example groups. This comes into play especially when using
<code>rspec-rails</code>, where, for instance, controller example groups, tagged with
<code>type: :controller</code>, are written differently than request example groups, tagged
with <code>type: :request</code>. This difference in writing style arises because
<code>rspec-rails</code> mixes different behavior and methods into controller example
groups vs. request example groups.</p>
<p>Relying on this behavior, Shoulda Matchers automatically makes certain matchers
available in certain kinds of example groups:</p>
<ul>
<li>ActiveRecord and ActiveModel matchers are available only in model example
groups, i.e., those tagged with <code>type: :model</code> or in files located under
<code>spec/models</code>.</li>
<li>ActionController matchers are available only in controller example groups,
i.e., those tagged with <code>type: :controller</code> or in files located under
<code>spec/controllers</code>.</li>
<li>The <code>route</code> matcher is available in routing example groups, i.e., those
tagged with <code>type: :routing</code> or in files located under <code>spec/routing</code>.</li>
<li>Independent matchers are available in all example groups.</li>
</ul>
<p>As long as you&#39;re using Rails, you don&#39;t need to worry about these details —
everything should &quot;just work&quot;.</p>
<h4 id="non-rails-projects">Non-Rails projects</h4>
<p><strong>What if you are using ActiveModel or ActiveRecord outside of Rails, however,
and you want to use model matchers in a certain example group?</strong> Then you&#39;ll
need to manually include the module that holds those matchers into that example
group. For instance, you might have to say:</p>
<pre class="code ruby"><code class="ruby"><span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">MySpecialModel</span> <span class="k">do</span>
<span class="kp">include</span> <span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="o">::</span><span class="no">ActiveModel</span>
<span class="kp">include</span> <span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="o">::</span><span class="no">ActiveRecord</span>
<span class="k">end</span>
</code></pre>
<p>If you have a lot of similar example groups in which you need to do this, then
you might find it more helpful to tag your example groups appropriately, then
instruct RSpec to mix these modules into any example groups that have that tag.
For instance, you could add this to your <code>rails_helper.rb</code>:</p>
<pre class="code ruby"><code class="ruby"><span class="no">RSpec</span><span class="p">.</span><span class="nf">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">include</span><span class="p">(</span><span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="o">::</span><span class="no">ActiveModel</span><span class="p">,</span> <span class="ss">type: :model</span><span class="p">)</span>
<span class="n">config</span><span class="p">.</span><span class="nf">include</span><span class="p">(</span><span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="o">::</span><span class="no">ActiveRecord</span><span class="p">,</span> <span class="ss">type: :model</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
<p>And from then on, you could say:</p>
<pre class="code ruby"><code class="ruby"><span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">MySpecialModel</span><span class="p">,</span> <span class="ss">type: :model</span> <span class="k">do</span>
<span class="c1"># ...</span>
<span class="k">end</span>
</code></pre>
<h3 id="should-vs-is_expected-to"><code>should</code> vs <code>is_expected.to</code></h3>
<p>In this README and throughout the documentation, you&#39;ll notice that we use the
<code>should</code> form of RSpec&#39;s one-liner syntax over <code>is_expected.to</code>. Beside being
the namesake of the gem itself, this is our preferred syntax as it&#39;s short and
sweet. But if you prefer to use <code>is_expected.to</code>, you can do that too:</p>
<pre class="code ruby"><code class="ruby"><span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">Person</span><span class="p">,</span> <span class="ss">type: :model</span> <span class="k">do</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">is_expected</span><span class="p">.</span><span class="nf">to</span> <span class="n">validate_presence_of</span><span class="p">(</span><span class="ss">:name</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
</code></pre>
<h2 id="matchers">Matchers</h2>
<p>Here is the full list of matchers that ship with this gem. If you need details
about any of them, make sure to <a href="https://matchers.shoulda.io/docs">consult the documentation</a>!</p>
<h3 id="activemodel-matchers">ActiveModel matchers</h3>
<ul>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#allow_value-instance_method" title="Shoulda::Matchers::ActiveModel#allow_value (method)">allow_value</a></span></strong>
tests that an attribute is valid or invalid if set to one or more values.
<em>(Aliased as #allow_values.)</em></li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#have_secure_password-instance_method" title="Shoulda::Matchers::ActiveModel#have_secure_password (method)">have_secure_password</a></span></strong>
tests usage of <code>has_secure_password</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_absence_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_absence_of (method)">validate_absence_of</a></span></strong>
tests usage of <code>validates_absence_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_acceptance_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_acceptance_of (method)">validate_acceptance_of</a></span></strong>
tests usage of <code>validates_acceptance_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_confirmation_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_confirmation_of (method)">validate_confirmation_of</a></span></strong>
tests usage of <code>validates_confirmation_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_exclusion_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_exclusion_of (method)">validate_exclusion_of</a></span></strong>
tests usage of <code>validates_exclusion_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_inclusion_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_inclusion_of (method)">validate_inclusion_of</a></span></strong>
tests usage of <code>validates_inclusion_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_length_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_length_of (method)">validate_length_of</a></span></strong>
tests usage of <code>validates_length_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_numericality_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_numericality_of (method)">validate_numericality_of</a></span></strong>
tests usage of <code>validates_numericality_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_presence_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_presence_of (method)">validate_presence_of</a></span></strong>
tests usage of <code>validates_presence_of</code>.</li>
</ul>
<h3 id="activerecord-matchers">ActiveRecord matchers</h3>
<ul>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#accept_nested_attributes_for-instance_method" title="Shoulda::Matchers::ActiveRecord#accept_nested_attributes_for (method)">accept_nested_attributes_for</a></span></strong>
tests usage of the <code>accepts_nested_attributes_for</code> macro.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#belong_to-instance_method" title="Shoulda::Matchers::ActiveRecord#belong_to (method)">belong_to</a></span></strong>
tests your <code>belongs_to</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#define_enum_for-instance_method" title="Shoulda::Matchers::ActiveRecord#define_enum_for (method)">define_enum_for</a></span></strong>
tests usage of the <code>enum</code> macro.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_and_belong_to_many-instance_method" title="Shoulda::Matchers::ActiveRecord#have_and_belong_to_many (method)">have_and_belong_to_many</a></span></strong>
tests your <code>has_and_belongs_to_many</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_db_column-instance_method" title="Shoulda::Matchers::ActiveRecord#have_db_column (method)">have_db_column</a></span></strong>
tests that the table that backs your model has a specific column.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_db_index-instance_method" title="Shoulda::Matchers::ActiveRecord#have_db_index (method)">have_db_index</a></span></strong>
tests that the table that backs your model has an index on a specific column.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_implicit_order_column-instance_method" title="Shoulda::Matchers::ActiveRecord#have_implicit_order_column (method)">have_implicit_order_column</a></span></strong>
tests usage of <code>implicit_order_column</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_many-instance_method" title="Shoulda::Matchers::ActiveRecord#have_many (method)">have_many</a></span></strong>
tests your <code>has_many</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_many_attached-instance_method" title="Shoulda::Matchers::ActiveRecord#have_many_attached (method)">have_many_attached</a></span></strong>
tests your <code>has_many_attached</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_one-instance_method" title="Shoulda::Matchers::ActiveRecord#have_one (method)">have_one</a></span></strong>
tests your <code>has_one</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_one_attached-instance_method" title="Shoulda::Matchers::ActiveRecord#have_one_attached (method)">have_one_attached</a></span></strong>
tests your <code>has_one_attached</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_readonly_attribute-instance_method" title="Shoulda::Matchers::ActiveRecord#have_readonly_attribute (method)">have_readonly_attribute</a></span></strong>
tests usage of the <code>attr_readonly</code> macro.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_rich_text-instance_method" title="Shoulda::Matchers::ActiveRecord#have_rich_text (method)">have_rich_text</a></span></strong>
tests your <code>has_rich_text</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#serialize-instance_method" title="Shoulda::Matchers::ActiveRecord#serialize (method)">serialize</a></span></strong> tests
usage of the <code>serialize</code> macro.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#validate_uniqueness_of-instance_method" title="Shoulda::Matchers::ActiveRecord#validate_uniqueness_of (method)">validate_uniqueness_of</a></span></strong>
tests usage of <code>validates_uniqueness_of</code>.</li>
</ul>
<h3 id="actioncontroller-matchers">ActionController matchers</h3>
<ul>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#filter_param-instance_method" title="Shoulda::Matchers::ActionController#filter_param (method)">filter_param</a></span></strong>
tests parameter filtering configuration.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#permit-instance_method" title="Shoulda::Matchers::ActionController#permit (method)">permit</a></span></strong> tests
that an action places a restriction on the <code>params</code> hash.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#redirect_to-instance_method" title="Shoulda::Matchers::ActionController#redirect_to (method)">redirect_to</a></span></strong>
tests that an action redirects to a certain location.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#render_template-instance_method" title="Shoulda::Matchers::ActionController#render_template (method)">render_template</a></span></strong>
tests that an action renders a template.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#render_with_layout-instance_method" title="Shoulda::Matchers::ActionController#render_with_layout (method)">render_with_layout</a></span></strong>
tests that an action is rendered with a certain layout.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#rescue_from-instance_method" title="Shoulda::Matchers::ActionController#rescue_from (method)">rescue_from</a></span></strong>
tests usage of the <code>rescue_from</code> macro.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#respond_with-instance_method" title="Shoulda::Matchers::ActionController#respond_with (method)">respond_with</a></span></strong>
tests that an action responds with a certain status code.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#route-instance_method" title="Shoulda::Matchers::ActionController#route (method)">route</a></span></strong> tests
your routes.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#set_session-instance_method" title="Shoulda::Matchers::ActionController#set_session (method)">set_session</a></span></strong>
makes assertions on the <code>session</code> hash.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#set_flash-instance_method" title="Shoulda::Matchers::ActionController#set_flash (method)">set_flash</a></span></strong>
makes assertions on the <code>flash</code> hash.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#use_after_action-instance_method" title="Shoulda::Matchers::ActionController#use_after_action (method)">use_after_action</a></span></strong>
tests that an <code>after_action</code> callback is defined in your controller.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#use_around_action-instance_method" title="Shoulda::Matchers::ActionController#use_around_action (method)">use_around_action</a></span></strong>
tests that an <code>around_action</code> callback is defined in your controller.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#use_before_action-instance_method" title="Shoulda::Matchers::ActionController#use_before_action (method)">use_before_action</a></span></strong>
tests that a <code>before_action</code> callback is defined in your controller.</li>
</ul>
<h3 id="routing-matchers">Routing matchers</h3>
<ul>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#route-instance_method" title="Shoulda::Matchers::ActionController#route (method)">route</a></span></strong> tests
your routes.</li>
</ul>
<h3 id="independent-matchers">Independent matchers</h3>
<ul>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/Independent.html#delegate_method-instance_method" title="Shoulda::Matchers::Independent#delegate_method (method)">delegate_method</a></span></strong>
tests that an object forwards messages to other, internal objects by way of
delegation.</li>
</ul>
<h2 id="extensions">Extensions</h2>
<p>Over time our community has created extensions to Shoulda Matchers. If you&#39;ve
created something that you want to share, please <a href="https://github.com/thoughtbot/shoulda-matchers/issues/new">let us know</a>!</p>
<ul>
<li><strong><a href="https://github.com/majioa/shoulda-matchers-cucumber">shoulda-matchers-cucumber</a></strong> Adds support for using Shoulda Matchers in
Cucumber tests.</li>
</ul>
<h2 id="contributing">Contributing</h2>
<p>Have a fix for a problem you&#39;ve been running into or an idea for a new feature
you think would be useful? Take a look at the <a href="CONTRIBUTING.md">Contributing
document</a> for instructions on setting up the repo on your
machine, understanding the codebase, and creating a good pull request.</p>
<h2 id="compatibility">Compatibility</h2>
<p>Shoulda Matchers is tested and supported against Ruby 2.6+, Rails
5.2+, RSpec 3.x, and Minitest 5.x.</p>
<ul>
<li>For Ruby &lt; 2.4 and Rails &lt; 4.1 compatibility, please use <a href="https://github.com/thoughtbot/shoulda-matchers/tree/v3.1.3">v3.1.3</a>.</li>
<li>For Ruby &lt; 3.0 and Rails &lt; 6.1 compatibility, please use <a href="https://github.com/thoughtbot/shoulda-matchers/tree/v4.5.1">v4.5.1</a>.</li>
</ul>
<h2 id="versioning">Versioning</h2>
<p>Shoulda Matchers follows Semantic Versioning 2.0 as defined at
<a href="https://semver.org">https://semver.org</a>.</p>
<h2 id="team">Team</h2>
<p>Shoulda Matchers is maintained by <a href="https://github.com/mcmire">Elliot Winkler</a> and <a href="https://github.com/guialbuk">Gui
Albuk</a>.</p>
<h2 id="copyright-license">Copyright/License</h2>
<p>Shoulda Matchers is copyright © 2006-2022 Tammer Saleh and <a href="https://thoughtbot.com">thoughtbot,
inc</a>. It is free and opensource software and may be
redistributed under the terms specified in the <a href="LICENSE">LICENSE</a> file.</p>
<h2 id="about-thoughtbot">About thoughtbot</h2>
<p><img src="https://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg" alt="thoughtbot"></p>
<p>The names and logos for thoughtbot are trademarks of thoughtbot, inc.</p>
<p>We are passionate about open source software. See <a href="https://thoughtbot.com/community?utm_source=github">our other
projects</a>. We are <a href="https://thoughtbot.com?utm_source=github">available for hire</a>.</p>
</div></div>
<div id="footer">
Generated on
September 17, 2022
by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">YARD</a>.
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,53 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/solarized.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/global.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
<title>File List</title>
<base id="base_target" target="_parent" />
</head>
<body>
<div id="content">
<h1 id="full_list_header">File List</h1>
<ul id="full_list" class="file">
<li id="object_README" class="odd">
<div class="item"><span class="object_link"><a href="index.html" title="README">README</a></span></div>
</li>
<li id="object_CHANGELOG" class="even">
<div class="item"><span class="object_link"><a href="file.CHANGELOG.html" title="CHANGELOG">CHANGELOG</a></span></div>
</li>
<li id="object_NonCaseSwappableValueError" class="odd">
<div class="item"><span class="object_link"><a href="file.NonCaseSwappableValueError.html" title="NonCaseSwappableValueError">NonCaseSwappableValueError</a></span></div>
</li>
</ul>
</div>
</body>
</html>

17
docs/v5.2.0/frames.html Normal file
View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Documentation by YARD 0.9.25</title>
</head>
<script type="text/javascript">
var match = unescape(window.location.hash).match(/^#!(.+)/);
var name = match ? match[1] : 'index.html';
name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
window.top.location = name;
</script>
<noscript>
<h1>Oops!</h1>
<h2>YARD requires JavaScript!</h2>
</noscript>
</html>

592
docs/v5.2.0/index.html Normal file
View File

@ -0,0 +1,592 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
File: README
&mdash; Documentation by YARD 0.9.25
</title>
<link rel="stylesheet" href="css/solarized.css" type="text/css" />
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="css/global.css" type="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "README";
relpath = '';
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery.stickyheaders.js"></script>
<script type="text/javascript" charset="utf-8" src="js/underscore.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<div id="header">
<div class="header-row">
<div id="menu">
<span class="title">README</span>
</div>
<div id="search" class="js-search">
<ul>
<li>
<a href="class_list.html">
Class List
</a>
</li>
<li>
<a href="method_list.html">
Method List
</a>
</li>
<li>
<a href="file_list.html">
File List
</a>
</li>
</ul>
<iframe id="search_frame" class="js-search-frame"></iframe>
</div>
<div class="clear"></div>
</div>
</div>
<div id="main">
<div id="content"><div id='filecontents'><h1 id="shoulda-matchers">Shoulda Matchers <a href="https://rubygems.org/gems/shoulda-matchers"><img src="https://img.shields.io/gem/v/shoulda-matchers.svg" alt="Gem Version"></a> <a href="https://github.com/thoughtbot/shoulda-matchers/actions"><img src="https://img.shields.io/github/workflow/status/thoughtbot/shoulda-matchers/Test" alt="Build Status"></a> <a href="https://rubygems.org/gems/shoulda-matchers"><img src="https://img.shields.io/gem/dt/shoulda-matchers.svg" alt="Total Downloads"></a> <a href="https://rubygems.org/gems/shoulda-matchers"><img src="https://img.shields.io/gem/dtv/shoulda-matchers.svg" alt="Downloads"></a></h1>
<p><a href="https://matchers.shoulda.io/"><img src="https://matchers.shoulda.io/images/shoulda-matchers-logo.png" alt="shoulda-matchers"></a></p>
<p>Shoulda Matchers provides RSpec- and Minitest-compatible one-liners to test
common Rails functionality that, if written by hand, would be much longer, more
complex, and error-prone.</p>
<h2 id="quick-links">Quick links</h2>
<p>📖 <strong><a href="https://matchers.shoulda.io/docs">Read the documentation for the latest version</a>.</strong>
📢 <strong><a href="CHANGELOG.md">See what&#39;s changed in recent versions</a>.</strong></p>
<h2 id="table-of-contents">Table of contents</h2>
<ul>
<li><a href="#getting-started">Getting started</a>
<ul>
<li><a href="#rspec">RSpec</a></li>
<li><a href="#minitest">Minitest</a></li>
</ul></li>
<li><a href="#usage">Usage</a>
<ul>
<li><a href="#on-the-subject-of-subject">On the subject of <code>subject</code></a></li>
<li><a href="#availability-of-rspec-matchers-in-example-groups">Availability of RSpec matchers in example groups</a></li>
<li><a href="#should-vs-is_expectedto"><code>should</code> vs <code>is_expected.to</code></a></li>
</ul></li>
<li><a href="#matchers">Matchers</a>
<ul>
<li><a href="#activemodel-matchers">ActiveModel matchers</a></li>
<li><a href="#activerecord-matchers">ActiveRecord matchers</a></li>
<li><a href="#actioncontroller-matchers">ActionController matchers</a></li>
<li><a href="#independent-matchers">Independent matchers</a></li>
</ul></li>
<li><a href="#extensions">Extensions</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#compatibility">Compatibility</a></li>
<li><a href="#versioning">Versioning</a></li>
<li><a href="#team">Team</a></li>
<li><a href="#copyright-license">Copyright/License</a></li>
<li><a href="#about-thoughtbot">About thoughtbot</a></li>
</ul>
<h2 id="getting-started">Getting started</h2>
<h3 id="rspec">RSpec</h3>
<p>Start by including <code>shoulda-matchers</code> in your Gemfile:</p>
<pre class="code ruby"><code class="ruby"><span class="n">group</span> <span class="ss">:test</span> <span class="k">do</span>
<span class="n">gem</span> <span class="s1">'shoulda-matchers'</span><span class="p">,</span> <span class="s1">'~&gt; 5.0'</span>
<span class="k">end</span>
</code></pre>
<p>Then run <code>bundle install</code>.</p>
<p>Now you need to configure the gem by telling it:</p>
<ul>
<li>which matchers you want to use in your tests</li>
<li>that you&#39;re using RSpec so that it can make those matchers available in
your example groups</li>
</ul>
<h4 id="rails-apps">Rails apps</h4>
<p>If you&#39;re working on a Rails app, simply place this at the bottom of
<code>spec/rails_helper.rb</code> (or in a support file if you so choose):</p>
<pre class="code ruby"><code class="ruby"><span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="p">.</span><span class="nf">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">integrate</span> <span class="k">do</span> <span class="o">|</span><span class="n">with</span><span class="o">|</span>
<span class="n">with</span><span class="p">.</span><span class="nf">test_framework</span> <span class="ss">:rspec</span>
<span class="n">with</span><span class="p">.</span><span class="nf">library</span> <span class="ss">:rails</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h4 id="non-rails-apps">Non-Rails apps</h4>
<p>If you&#39;re not working on a Rails app, but you still make use of ActiveRecord or
ActiveModel in your project, you can still use this gem too! In that case,
you&#39;ll want to place the following configuration at the bottom of
<code>spec/spec_helper.rb</code>:</p>
<pre class="code ruby"><code class="ruby"><span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="p">.</span><span class="nf">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">integrate</span> <span class="k">do</span> <span class="o">|</span><span class="n">with</span><span class="o">|</span>
<span class="n">with</span><span class="p">.</span><span class="nf">test_framework</span> <span class="ss">:rspec</span>
<span class="c1"># Keep as many of these lines as are necessary:</span>
<span class="n">with</span><span class="p">.</span><span class="nf">library</span> <span class="ss">:active_record</span>
<span class="n">with</span><span class="p">.</span><span class="nf">library</span> <span class="ss">:active_model</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h3 id="minitest">Minitest</h3>
<p>If you&#39;re using our umbrella gem <a href="https://github.com/thoughtbot/shoulda">Shoulda</a>, then make sure that you&#39;re using the
latest version:</p>
<pre class="code ruby"><code class="ruby"><span class="n">group</span> <span class="ss">:test</span> <span class="k">do</span>
<span class="n">gem</span> <span class="s1">'shoulda'</span><span class="p">,</span> <span class="s1">'~&gt; 4.0'</span>
<span class="k">end</span>
</code></pre>
<p>Otherwise, add <code>shoulda-matchers</code> to your Gemfile:</p>
<pre class="code ruby"><code class="ruby"><span class="n">group</span> <span class="ss">:test</span> <span class="k">do</span>
<span class="n">gem</span> <span class="s1">'shoulda-matchers'</span><span class="p">,</span> <span class="s1">'~&gt; 5.0'</span>
<span class="k">end</span>
</code></pre>
<p>Then run <code>bundle install</code>.</p>
<p>Now you need to configure the gem by telling it:</p>
<ul>
<li>which matchers you want to use in your tests</li>
<li>that you&#39;re using Minitest so that it can make those matchers available in
your test case classes</li>
</ul>
<h4 id="rails-apps">Rails apps</h4>
<p>If you&#39;re working on a Rails app, simply place this at the bottom of
<code>test/test_helper.rb</code>:</p>
<pre class="code ruby"><code class="ruby"><span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="p">.</span><span class="nf">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">integrate</span> <span class="k">do</span> <span class="o">|</span><span class="n">with</span><span class="o">|</span>
<span class="n">with</span><span class="p">.</span><span class="nf">test_framework</span> <span class="ss">:minitest</span>
<span class="n">with</span><span class="p">.</span><span class="nf">library</span> <span class="ss">:rails</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h4 id="non-rails-apps">Non-Rails apps</h4>
<p>If you&#39;re not working on a Rails app, but you still make use of ActiveRecord or
ActiveModel in your project, you can still use this gem too! In that case,
you&#39;ll want to place the following configuration at the bottom of
<code>test/test_helper.rb</code>:</p>
<pre class="code ruby"><code class="ruby"><span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="p">.</span><span class="nf">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">integrate</span> <span class="k">do</span> <span class="o">|</span><span class="n">with</span><span class="o">|</span>
<span class="n">with</span><span class="p">.</span><span class="nf">test_framework</span> <span class="ss">:minitest</span>
<span class="c1"># Keep as many of these lines as are necessary:</span>
<span class="n">with</span><span class="p">.</span><span class="nf">library</span> <span class="ss">:active_record</span>
<span class="n">with</span><span class="p">.</span><span class="nf">library</span> <span class="ss">:active_model</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h2 id="usage">Usage</h2>
<p>Most of the matchers provided by this gem are useful in a Rails context, and as
such, can be used for different parts of a Rails app:</p>
<ul>
<li><a href="#activemodel-matchers">database models backed by ActiveRecord</a></li>
<li><a href="#activerecord-matchers">non-database models, form objects, etc. backed by
ActiveModel</a></li>
<li><a href="#actioncontroller-matchers">controllers</a></li>
<li><a href="#routing-matchers">routes</a> (RSpec only)</li>
<li><a href="#independent-matchers">Rails-specific features like <code>delegate</code></a></li>
</ul>
<p>As the name of the gem indicates, most matchers are designed to be used in
&quot;one-liner&quot; form using the <code>should</code> macro, a special directive available in both
RSpec and <a href="https://github.com/thoughtbot/shoulda">Shoulda</a>. For instance, a model test case may look something like:</p>
<pre class="code ruby"><code class="ruby"><span class="c1"># RSpec</span>
<span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">MenuItem</span><span class="p">,</span> <span class="ss">type: :model</span> <span class="k">do</span>
<span class="n">describe</span> <span class="s1">'associations'</span> <span class="k">do</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">belong_to</span><span class="p">(</span><span class="ss">:category</span><span class="p">).</span><span class="nf">class_name</span><span class="p">(</span><span class="s1">'MenuCategory'</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="n">describe</span> <span class="s1">'validations'</span> <span class="k">do</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">validate_presence_of</span><span class="p">(</span><span class="ss">:name</span><span class="p">)</span> <span class="p">}</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">validate_uniqueness_of</span><span class="p">(</span><span class="ss">:name</span><span class="p">).</span><span class="nf">scoped_to</span><span class="p">(</span><span class="ss">:category_id</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># Minitest (Shoulda)</span>
<span class="k">class</span> <span class="nc">MenuItemTest</span> <span class="o">&lt;</span> <span class="no">ActiveSupport</span><span class="o">::</span><span class="no">TestCase</span>
<span class="n">context</span> <span class="s1">'associations'</span> <span class="k">do</span>
<span class="n">should</span> <span class="n">belong_to</span><span class="p">(</span><span class="ss">:category</span><span class="p">).</span><span class="nf">class_name</span><span class="p">(</span><span class="s1">'MenuCategory'</span><span class="p">)</span>
<span class="k">end</span>
<span class="n">context</span> <span class="s1">'validations'</span> <span class="k">do</span>
<span class="n">should</span> <span class="n">validate_presence_of</span><span class="p">(</span><span class="ss">:name</span><span class="p">)</span>
<span class="n">should</span> <span class="n">validate_uniqueness_of</span><span class="p">(</span><span class="ss">:name</span><span class="p">).</span><span class="nf">scoped_to</span><span class="p">(</span><span class="ss">:category_id</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p><a href="#matchers">See below</a> for the full set of matchers that you can use.</p>
<h3 id="on-the-subject-of-subject">On the subject of <code>subject</code></h3>
<p>For both RSpec and Shoulda, the <strong>subject</strong> is an implicit reference to the
object under test, and through the use of <code>should</code> as demonstrated above, all of
the matchers make use of <code>subject</code> internally when they are run. A <code>subject</code> is
always set automatically by your test framework in any given test case; however,
in certain cases it can be advantageous to override it. For instance, when
testing validations in a model, it is customary to provide a valid model instead
of a fresh one:</p>
<pre class="code ruby"><code class="ruby"><span class="c1"># RSpec</span>
<span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">Post</span><span class="p">,</span> <span class="ss">type: :model</span> <span class="k">do</span>
<span class="n">describe</span> <span class="s1">'validations'</span> <span class="k">do</span>
<span class="c1"># Here we're using FactoryBot, but you could use anything</span>
<span class="n">subject</span> <span class="p">{</span> <span class="n">build</span><span class="p">(</span><span class="ss">:post</span><span class="p">)</span> <span class="p">}</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">validate_presence_of</span><span class="p">(</span><span class="ss">:title</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># Minitest (Shoulda)</span>
<span class="k">class</span> <span class="nc">PostTest</span> <span class="o">&lt;</span> <span class="no">ActiveSupport</span><span class="o">::</span><span class="no">TestCase</span>
<span class="n">context</span> <span class="s1">'validations'</span> <span class="k">do</span>
<span class="n">subject</span> <span class="p">{</span> <span class="n">build</span><span class="p">(</span><span class="ss">:post</span><span class="p">)</span> <span class="p">}</span>
<span class="n">should</span> <span class="n">validate_presence_of</span><span class="p">(</span><span class="ss">:title</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>When overriding the subject in this manner, then, it&#39;s important to provide the
correct object. <strong>When in doubt, provide an instance of the class under test.</strong>
This is particularly necessary for controller tests, where it is easy to
accidentally write something like:</p>
<pre class="code ruby"><code class="ruby"><span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">PostsController</span><span class="p">,</span> <span class="ss">type: :controller</span> <span class="k">do</span>
<span class="n">describe</span> <span class="s1">'GET #index'</span> <span class="k">do</span>
<span class="n">subject</span> <span class="p">{</span> <span class="n">get</span> <span class="ss">:index</span> <span class="p">}</span>
<span class="c1"># This may work...</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">have_http_status</span><span class="p">(</span><span class="ss">:success</span><span class="p">)</span> <span class="p">}</span>
<span class="c1"># ...but this will not!</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">permit</span><span class="p">(</span><span class="ss">:title</span><span class="p">,</span> <span class="ss">:body</span><span class="p">).</span><span class="nf">for</span><span class="p">(</span><span class="ss">:post</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<p>In this case, you would want to use <code>before</code> rather than <code>subject</code>:</p>
<pre class="code ruby"><code class="ruby"><span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">PostsController</span><span class="p">,</span> <span class="ss">type: :controller</span> <span class="k">do</span>
<span class="n">describe</span> <span class="s1">'GET #index'</span> <span class="k">do</span>
<span class="n">before</span> <span class="p">{</span> <span class="n">get</span> <span class="ss">:index</span> <span class="p">}</span>
<span class="c1"># Notice that we have to assert have_http_status on the response here...</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">expect</span><span class="p">(</span><span class="n">response</span><span class="p">).</span><span class="nf">to</span> <span class="n">have_http_status</span><span class="p">(</span><span class="ss">:success</span><span class="p">)</span> <span class="p">}</span>
<span class="c1"># ...but we do not have to provide a subject for render_template</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">should</span> <span class="n">render_template</span><span class="p">(</span><span class="s1">'index'</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
<span class="k">end</span>
</code></pre>
<h3 id="availability-of-rspec-matchers-in-example-groups">Availability of RSpec matchers in example groups</h3>
<h4 id="rails-projects">Rails projects</h4>
<p>If you&#39;re using RSpec, then you&#39;re probably familiar with the concept of example
groups. Example groups can be assigned tags order to assign different behavior
to different kinds of example groups. This comes into play especially when using
<code>rspec-rails</code>, where, for instance, controller example groups, tagged with
<code>type: :controller</code>, are written differently than request example groups, tagged
with <code>type: :request</code>. This difference in writing style arises because
<code>rspec-rails</code> mixes different behavior and methods into controller example
groups vs. request example groups.</p>
<p>Relying on this behavior, Shoulda Matchers automatically makes certain matchers
available in certain kinds of example groups:</p>
<ul>
<li>ActiveRecord and ActiveModel matchers are available only in model example
groups, i.e., those tagged with <code>type: :model</code> or in files located under
<code>spec/models</code>.</li>
<li>ActionController matchers are available only in controller example groups,
i.e., those tagged with <code>type: :controller</code> or in files located under
<code>spec/controllers</code>.</li>
<li>The <code>route</code> matcher is available in routing example groups, i.e., those
tagged with <code>type: :routing</code> or in files located under <code>spec/routing</code>.</li>
<li>Independent matchers are available in all example groups.</li>
</ul>
<p>As long as you&#39;re using Rails, you don&#39;t need to worry about these details —
everything should &quot;just work&quot;.</p>
<h4 id="non-rails-projects">Non-Rails projects</h4>
<p><strong>What if you are using ActiveModel or ActiveRecord outside of Rails, however,
and you want to use model matchers in a certain example group?</strong> Then you&#39;ll
need to manually include the module that holds those matchers into that example
group. For instance, you might have to say:</p>
<pre class="code ruby"><code class="ruby"><span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">MySpecialModel</span> <span class="k">do</span>
<span class="kp">include</span> <span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="o">::</span><span class="no">ActiveModel</span>
<span class="kp">include</span> <span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="o">::</span><span class="no">ActiveRecord</span>
<span class="k">end</span>
</code></pre>
<p>If you have a lot of similar example groups in which you need to do this, then
you might find it more helpful to tag your example groups appropriately, then
instruct RSpec to mix these modules into any example groups that have that tag.
For instance, you could add this to your <code>rails_helper.rb</code>:</p>
<pre class="code ruby"><code class="ruby"><span class="no">RSpec</span><span class="p">.</span><span class="nf">configure</span> <span class="k">do</span> <span class="o">|</span><span class="n">config</span><span class="o">|</span>
<span class="n">config</span><span class="p">.</span><span class="nf">include</span><span class="p">(</span><span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="o">::</span><span class="no">ActiveModel</span><span class="p">,</span> <span class="ss">type: :model</span><span class="p">)</span>
<span class="n">config</span><span class="p">.</span><span class="nf">include</span><span class="p">(</span><span class="no">Shoulda</span><span class="o">::</span><span class="no">Matchers</span><span class="o">::</span><span class="no">ActiveRecord</span><span class="p">,</span> <span class="ss">type: :model</span><span class="p">)</span>
<span class="k">end</span>
</code></pre>
<p>And from then on, you could say:</p>
<pre class="code ruby"><code class="ruby"><span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">MySpecialModel</span><span class="p">,</span> <span class="ss">type: :model</span> <span class="k">do</span>
<span class="c1"># ...</span>
<span class="k">end</span>
</code></pre>
<h3 id="should-vs-is_expected-to"><code>should</code> vs <code>is_expected.to</code></h3>
<p>In this README and throughout the documentation, you&#39;ll notice that we use the
<code>should</code> form of RSpec&#39;s one-liner syntax over <code>is_expected.to</code>. Beside being
the namesake of the gem itself, this is our preferred syntax as it&#39;s short and
sweet. But if you prefer to use <code>is_expected.to</code>, you can do that too:</p>
<pre class="code ruby"><code class="ruby"><span class="no">RSpec</span><span class="p">.</span><span class="nf">describe</span> <span class="no">Person</span><span class="p">,</span> <span class="ss">type: :model</span> <span class="k">do</span>
<span class="n">it</span> <span class="p">{</span> <span class="n">is_expected</span><span class="p">.</span><span class="nf">to</span> <span class="n">validate_presence_of</span><span class="p">(</span><span class="ss">:name</span><span class="p">)</span> <span class="p">}</span>
<span class="k">end</span>
</code></pre>
<h2 id="matchers">Matchers</h2>
<p>Here is the full list of matchers that ship with this gem. If you need details
about any of them, make sure to <a href="https://matchers.shoulda.io/docs">consult the documentation</a>!</p>
<h3 id="activemodel-matchers">ActiveModel matchers</h3>
<ul>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#allow_value-instance_method" title="Shoulda::Matchers::ActiveModel#allow_value (method)">allow_value</a></span></strong>
tests that an attribute is valid or invalid if set to one or more values.
<em>(Aliased as #allow_values.)</em></li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#have_secure_password-instance_method" title="Shoulda::Matchers::ActiveModel#have_secure_password (method)">have_secure_password</a></span></strong>
tests usage of <code>has_secure_password</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_absence_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_absence_of (method)">validate_absence_of</a></span></strong>
tests usage of <code>validates_absence_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_acceptance_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_acceptance_of (method)">validate_acceptance_of</a></span></strong>
tests usage of <code>validates_acceptance_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_confirmation_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_confirmation_of (method)">validate_confirmation_of</a></span></strong>
tests usage of <code>validates_confirmation_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_exclusion_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_exclusion_of (method)">validate_exclusion_of</a></span></strong>
tests usage of <code>validates_exclusion_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_inclusion_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_inclusion_of (method)">validate_inclusion_of</a></span></strong>
tests usage of <code>validates_inclusion_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_length_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_length_of (method)">validate_length_of</a></span></strong>
tests usage of <code>validates_length_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_numericality_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_numericality_of (method)">validate_numericality_of</a></span></strong>
tests usage of <code>validates_numericality_of</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_presence_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_presence_of (method)">validate_presence_of</a></span></strong>
tests usage of <code>validates_presence_of</code>.</li>
</ul>
<h3 id="activerecord-matchers">ActiveRecord matchers</h3>
<ul>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#accept_nested_attributes_for-instance_method" title="Shoulda::Matchers::ActiveRecord#accept_nested_attributes_for (method)">accept_nested_attributes_for</a></span></strong>
tests usage of the <code>accepts_nested_attributes_for</code> macro.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#belong_to-instance_method" title="Shoulda::Matchers::ActiveRecord#belong_to (method)">belong_to</a></span></strong>
tests your <code>belongs_to</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#define_enum_for-instance_method" title="Shoulda::Matchers::ActiveRecord#define_enum_for (method)">define_enum_for</a></span></strong>
tests usage of the <code>enum</code> macro.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_and_belong_to_many-instance_method" title="Shoulda::Matchers::ActiveRecord#have_and_belong_to_many (method)">have_and_belong_to_many</a></span></strong>
tests your <code>has_and_belongs_to_many</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_db_column-instance_method" title="Shoulda::Matchers::ActiveRecord#have_db_column (method)">have_db_column</a></span></strong>
tests that the table that backs your model has a specific column.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_db_index-instance_method" title="Shoulda::Matchers::ActiveRecord#have_db_index (method)">have_db_index</a></span></strong>
tests that the table that backs your model has an index on a specific column.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_implicit_order_column-instance_method" title="Shoulda::Matchers::ActiveRecord#have_implicit_order_column (method)">have_implicit_order_column</a></span></strong>
tests usage of <code>implicit_order_column</code>.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_many-instance_method" title="Shoulda::Matchers::ActiveRecord#have_many (method)">have_many</a></span></strong>
tests your <code>has_many</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_many_attached-instance_method" title="Shoulda::Matchers::ActiveRecord#have_many_attached (method)">have_many_attached</a></span></strong>
tests your <code>has_many_attached</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_one-instance_method" title="Shoulda::Matchers::ActiveRecord#have_one (method)">have_one</a></span></strong>
tests your <code>has_one</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_one_attached-instance_method" title="Shoulda::Matchers::ActiveRecord#have_one_attached (method)">have_one_attached</a></span></strong>
tests your <code>has_one_attached</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_readonly_attribute-instance_method" title="Shoulda::Matchers::ActiveRecord#have_readonly_attribute (method)">have_readonly_attribute</a></span></strong>
tests usage of the <code>attr_readonly</code> macro.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_rich_text-instance_method" title="Shoulda::Matchers::ActiveRecord#have_rich_text (method)">have_rich_text</a></span></strong>
tests your <code>has_rich_text</code> associations.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#serialize-instance_method" title="Shoulda::Matchers::ActiveRecord#serialize (method)">serialize</a></span></strong> tests
usage of the <code>serialize</code> macro.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#validate_uniqueness_of-instance_method" title="Shoulda::Matchers::ActiveRecord#validate_uniqueness_of (method)">validate_uniqueness_of</a></span></strong>
tests usage of <code>validates_uniqueness_of</code>.</li>
</ul>
<h3 id="actioncontroller-matchers">ActionController matchers</h3>
<ul>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#filter_param-instance_method" title="Shoulda::Matchers::ActionController#filter_param (method)">filter_param</a></span></strong>
tests parameter filtering configuration.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#permit-instance_method" title="Shoulda::Matchers::ActionController#permit (method)">permit</a></span></strong> tests
that an action places a restriction on the <code>params</code> hash.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#redirect_to-instance_method" title="Shoulda::Matchers::ActionController#redirect_to (method)">redirect_to</a></span></strong>
tests that an action redirects to a certain location.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#render_template-instance_method" title="Shoulda::Matchers::ActionController#render_template (method)">render_template</a></span></strong>
tests that an action renders a template.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#render_with_layout-instance_method" title="Shoulda::Matchers::ActionController#render_with_layout (method)">render_with_layout</a></span></strong>
tests that an action is rendered with a certain layout.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#rescue_from-instance_method" title="Shoulda::Matchers::ActionController#rescue_from (method)">rescue_from</a></span></strong>
tests usage of the <code>rescue_from</code> macro.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#respond_with-instance_method" title="Shoulda::Matchers::ActionController#respond_with (method)">respond_with</a></span></strong>
tests that an action responds with a certain status code.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#route-instance_method" title="Shoulda::Matchers::ActionController#route (method)">route</a></span></strong> tests
your routes.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#set_session-instance_method" title="Shoulda::Matchers::ActionController#set_session (method)">set_session</a></span></strong>
makes assertions on the <code>session</code> hash.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#set_flash-instance_method" title="Shoulda::Matchers::ActionController#set_flash (method)">set_flash</a></span></strong>
makes assertions on the <code>flash</code> hash.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#use_after_action-instance_method" title="Shoulda::Matchers::ActionController#use_after_action (method)">use_after_action</a></span></strong>
tests that an <code>after_action</code> callback is defined in your controller.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#use_around_action-instance_method" title="Shoulda::Matchers::ActionController#use_around_action (method)">use_around_action</a></span></strong>
tests that an <code>around_action</code> callback is defined in your controller.</li>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#use_before_action-instance_method" title="Shoulda::Matchers::ActionController#use_before_action (method)">use_before_action</a></span></strong>
tests that a <code>before_action</code> callback is defined in your controller.</li>
</ul>
<h3 id="routing-matchers">Routing matchers</h3>
<ul>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/ActionController.html#route-instance_method" title="Shoulda::Matchers::ActionController#route (method)">route</a></span></strong> tests
your routes.</li>
</ul>
<h3 id="independent-matchers">Independent matchers</h3>
<ul>
<li><strong><span class='object_link'><a href="Shoulda/Matchers/Independent.html#delegate_method-instance_method" title="Shoulda::Matchers::Independent#delegate_method (method)">delegate_method</a></span></strong>
tests that an object forwards messages to other, internal objects by way of
delegation.</li>
</ul>
<h2 id="extensions">Extensions</h2>
<p>Over time our community has created extensions to Shoulda Matchers. If you&#39;ve
created something that you want to share, please <a href="https://github.com/thoughtbot/shoulda-matchers/issues/new">let us know</a>!</p>
<ul>
<li><strong><a href="https://github.com/majioa/shoulda-matchers-cucumber">shoulda-matchers-cucumber</a></strong> Adds support for using Shoulda Matchers in
Cucumber tests.</li>
</ul>
<h2 id="contributing">Contributing</h2>
<p>Have a fix for a problem you&#39;ve been running into or an idea for a new feature
you think would be useful? Take a look at the <a href="CONTRIBUTING.md">Contributing
document</a> for instructions on setting up the repo on your
machine, understanding the codebase, and creating a good pull request.</p>
<h2 id="compatibility">Compatibility</h2>
<p>Shoulda Matchers is tested and supported against Ruby 2.6+, Rails
5.2+, RSpec 3.x, and Minitest 5.x.</p>
<ul>
<li>For Ruby &lt; 2.4 and Rails &lt; 4.1 compatibility, please use <a href="https://github.com/thoughtbot/shoulda-matchers/tree/v3.1.3">v3.1.3</a>.</li>
<li>For Ruby &lt; 3.0 and Rails &lt; 6.1 compatibility, please use <a href="https://github.com/thoughtbot/shoulda-matchers/tree/v4.5.1">v4.5.1</a>.</li>
</ul>
<h2 id="versioning">Versioning</h2>
<p>Shoulda Matchers follows Semantic Versioning 2.0 as defined at
<a href="https://semver.org">https://semver.org</a>.</p>
<h2 id="team">Team</h2>
<p>Shoulda Matchers is maintained by <a href="https://github.com/mcmire">Elliot Winkler</a> and <a href="https://github.com/guialbuk">Gui
Albuk</a>.</p>
<h2 id="copyright-license">Copyright/License</h2>
<p>Shoulda Matchers is copyright © 2006-2022 Tammer Saleh and <a href="https://thoughtbot.com">thoughtbot,
inc</a>. It is free and opensource software and may be
redistributed under the terms specified in the <a href="LICENSE">LICENSE</a> file.</p>
<h2 id="about-thoughtbot">About thoughtbot</h2>
<p><img src="https://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg" alt="thoughtbot"></p>
<p>The names and logos for thoughtbot are trademarks of thoughtbot, inc.</p>
<p>We are passionate about open source software. See <a href="https://thoughtbot.com/community?utm_source=github">our other
projects</a>. We are <a href="https://thoughtbot.com?utm_source=github">available for hire</a>.</p>
</div></div>
<div id="footer">
Generated on
September 17, 2022
by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">YARD</a>.
</div>
</div>
</body>
</html>

281
docs/v5.2.0/js/app.js Normal file
View File

@ -0,0 +1,281 @@
function createSourceLinks() {
$('.method_details_list .source_code').
before("<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>");
$('.toggleSource').toggle(function() {
$(this).parent().nextAll('.source_code').show();
$(this).text("Hide source");
StickyHeaders.update();
},
function() {
$(this).parent().nextAll('.source_code').hide();
$(this).text("View source");
StickyHeaders.update();
});
}
function createDefineLinks() {
var tHeight = 0;
$('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
$('.toggleDefines').toggle(function() {
tHeight = $(this).parent().prev().height();
$(this).prev().show();
$(this).parent().prev().height($(this).parent().height());
$(this).text("(less)");
StickyHeaders.update();
},
function() {
$(this).prev().hide();
$(this).parent().prev().height(tHeight);
$(this).text("more...");
StickyHeaders.update();
});
}
function createFullTreeLinks() {
var tHeight = 0;
$('.inheritanceTree').toggle(function() {
tHeight = $(this).parent().prev().height();
$(this).parent().toggleClass('showAll');
$(this).text("(hide)");
$(this).parent().prev().height($(this).parent().height());
StickyHeaders.update();
},
function() {
$(this).parent().toggleClass('showAll');
$(this).parent().prev().height(tHeight);
$(this).text("show all");
StickyHeaders.update();
});
}
function hideSearchFrameOnBlur() {
$(document.body).on('click', hideSearchFrame);
}
function initSearchFrameLinks() {
var search = $('.js-search');
var items = search.find('li');
var links = search.find('a');
var frame = $('.js-search-frame');
function listen() {
links.on('click', function (event) {
event.preventDefault();
event.stopPropagation();
toggle(this, this.href);
});
$(document).on('keydown', function (event) {
if (event.which == 27) {
close();
}
})
$(document).on('click', function (event) {
close();
})
}
function toggle(link, frameSrc) {
if (isOpen() && clickedOnSameLink(frameSrc)) {
close();
} else {
open(link, frameSrc);
}
}
function isOpen() {
return frame.hasClass('open');
}
function clickedOnSameLink(location) {
return frame.attr('src') === location;
}
function reset() {
items.removeClass('active');
}
function open(link, location) {
reset();
$(link).parent().addClass('active');
frame.attr('src', location).one('load', function () {
frame.addClass('open');
})
}
function close() {
reset();
frame.removeClass('open');
}
listen();
}
function linkSummaries() {
$('.summary_signature').click(function() {
document.location = $(this).find('a').attr('href');
});
}
function keyboardShortcuts() {
if (window.top.frames.main) return;
$(document).keypress(function(evt) {
if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return;
if (
typeof evt.target !== "undefined" &&
(evt.target.nodeName == "INPUT" || evt.target.nodeName == "TEXTAREA")
) return;
switch (evt.charCode) {
case 67: case 99: $('#class_list_link').click(); break; // 'c'
case 77: case 109: $('#method_list_link').click(); break; // 'm'
case 70: case 102: $('#file_list_link').click(); break; // 'f'
default: break;
}
});
}
function summaryToggle() {
$('.summary_toggle').click(function() {
if (localStorage) {
localStorage.summaryCollapsed = $(this).text();
}
$('.summary_toggle').each(function() {
$(this).text($(this).text() == "collapse" ? "expand" : "collapse");
var next = $(this).parent().parent().nextAll('ul.summary').first();
if (next.hasClass('compact')) {
next.toggle();
next.nextAll('ul.summary').first().toggle();
}
else if (next.hasClass('summary')) {
var list = $('<ul class="summary compact" />');
list.html(next.html());
list.find('.summary_desc, .note').remove();
list.find('a').each(function() {
$(this).html($(this).find('strong').html());
$(this).parent().html($(this)[0].outerHTML);
});
next.before(list);
next.toggle();
}
});
StickyHeaders.update();
return false;
});
if (localStorage) {
if (localStorage.summaryCollapsed == "collapse") {
$('.summary_toggle').first().click();
}
else localStorage.summaryCollapsed = "expand";
}
}
function fixOutsideWorldLinks() {
$('a').each(function() {
if (window.location.host != this.host) this.target = '_parent';
});
}
function generateTOC() {
if ($('#filecontents').length === 0) return;
var _toc = $('<ol class="top"></ol>');
var show = false;
var toc = _toc;
var counter = 0;
var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
var i;
if ($('#filecontents h1').length > 1) tags.unshift('h1');
for (i = 0; i < tags.length; i++) { tags[i] = '#filecontents ' + tags[i]; }
var lastTag = parseInt(tags[0][1], 10);
$(tags.join(', ')).each(function() {
if ($(this).parents('.method_details .docstring').length != 0) return;
if (this.id == "filecontents") return;
show = true;
var thisTag = parseInt(this.tagName[1], 10);
if (this.id.length === 0) {
var proposedId = $(this).attr('toc-id');
if (typeof(proposedId) != "undefined") this.id = proposedId;
else {
var proposedId = $(this).text().replace(/[^a-z0-9-]/ig, '_');
if ($('#' + proposedId).length > 0) { proposedId += counter; counter++; }
this.id = proposedId;
}
}
if (thisTag > lastTag) {
for (i = 0; i < thisTag - lastTag; i++) {
var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
}
}
if (thisTag < lastTag) {
for (i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
}
var title = $(this).attr('toc-title');
if (typeof(title) == "undefined") title = $(this).text();
toc.append('<li><a href="#' + this.id + '">' + title + '</a></li>');
lastTag = thisTag;
});
if (!show) return;
html = '<div id="toc"><p class="title"><a class="hide_toc" href="#"><strong>Table of Contents</strong></a> <small>(<a href="#" class="float_toc">left</a>)</small></p></div>';
$('#content').prepend(html);
$('#toc').append(_toc);
$('#toc .hide_toc').toggle(function() {
$('#toc .top').slideUp('fast');
$('#toc').toggleClass('hidden');
$('#toc .title small').toggle();
}, function() {
$('#toc .top').slideDown('fast');
$('#toc').toggleClass('hidden');
$('#toc .title small').toggle();
});
$('#toc .float_toc').toggle(function() {
$(this).text('float');
$('#toc').toggleClass('nofloat');
}, function() {
$(this).text('left');
$('#toc').toggleClass('nofloat');
});
}
function removeDlBoxIfEmpty() {
var $box = $('dl.box')
if (!$box.text().trim()) {
$box.remove();
}
}
function makeHeadersSticky() {
StickyHeaders
.set({
contentContainer: '#main',
stickyHeaderContainer: '#header',
switchOnCollisionWith: 'top',
fillHeadersWith: function (node) {
return $('<h3>').text(node.find('strong').text());
}
})
.add('.method_details > h3')
.activate();
}
function updateStickyHeaders() {
setTimeout(function () {
StickyHeaders.update()
}, 100)
}
$(makeHeadersSticky);
$(createSourceLinks);
$(createDefineLinks);
$(createFullTreeLinks);
$(initSearchFrameLinks);
$(linkSummaries);
$(keyboardShortcuts);
$(summaryToggle);
$(fixOutsideWorldLinks);
$(generateTOC);
$(removeDlBoxIfEmpty);
$(updateStickyHeaders);

View File

@ -0,0 +1 @@
// Override with nothing

4
docs/v5.2.0/js/jquery.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,289 @@
window.StickyHeaders = (function ($) {
var me = {},
body, config, contentContainer, currentHeaderRangeIndex,
currentScrollOffset, elem, headerRanges, headers, isScrolling,
lastScrollOffset, selectors, stickyHeaderContainer;
function init() {
config = {
switchOnCollisionWith: 'top',
copy: 'element'
};
selectors = [];
headers = [];
headerRanges = [];
currentHeaderRangeIndex = -1;
currentScrollOffset = 0;
lastScrollOffset = 0;
isScrolling = false;
createStickyHeader();
}
function createStickyHeader() {
elem = $('<div>').attr('id', 'sticky-header');
}
function setHeaders() {
var elements = [],
stickyHeaderLineHeight = parseCssValue(elem.css('line-height')),
stickyHeaderTopPadding;
headers = [];
$.each(selectors, function (_, selector) {
contentContainer.find(selector).each(function (_, element) {
var $element = $(element),
fontSize = parseCssValue($element.css('font-size')),
topOffset = (
element.offsetTop +
parseFloat($element.css('padding-top'), 10) +
(- ((stickyHeaderLineHeight - fontSize) / 2))
),
height = Math.round($element.height()),
outerHeight = Math.round($element.outerHeight(true)),
bottomOffset = topOffset + outerHeight;
headers.push({
element: element,
$element: $element,
topOffset: topOffset,
bottomOffset: bottomOffset
});
})
})
}
function setHeaderRanges() {
var offsetProp = config.switchOnCollisionWith + 'Offset',
start, end;
headerRanges = [];
for (var i = 0, len = headers.length; i < len; i++) {
start = headers[i][offsetProp];
if (headers[i+1]) {
end = headers[i+1][offsetProp];
} else {
end = null;
}
headerRanges.push({
start: start,
end: end,
element: headers[i].element
});
}
//debugHeaderRanges();
}
function debugHeaderRanges() {
contentContainer.find('.header-range-debug').remove();
$.each(headerRanges, function (i, range) {
var color = 'hsla('+(20*i)+', 100%, 50%, 0.15)',
debug = $('<div>')
.addClass('header-range-debug')
.css({
width: '100%',
position: 'absolute',
top: range.start + 'px',
height: (range.end === null ? '1px' : (range.end - range.start) + 'px'),
backgroundColor: color,
borderTop: '1px solid black'
})
.appendTo(contentContainer)
debug.append(
$('<div>')
.css({
position: 'absolute',
top: 0,
right: 0,
height: '2em',
lineHeight: '2em',
width: '40em',
fontSize: '13px',
backgroundColor: 'black',
color: 'white',
padding: '0 5px'
})
.text(headers[i].$element.text() + ' (#' + i + ')')
)
})
}
function setCurrentHeaderIndex() {
var scrollTop = contentContainer.scrollTop();
for (var i = 0, len = headers.length; i < len; i++) {
if (scrollTop < headers[i].bottomOffset) {
break;
}
currentHeaderIndex = i;
}
}
function render() {
var clonedHeader;
if (currentHeaderRangeIndex < 0 || currentHeaderRangeIndex > headerRanges.length-1) {
elem.removeClass('show');
body.removeClass('has-sticky-header');
}
else {
var realHeader = $(headerRanges[currentHeaderRangeIndex].element);
if (typeof config.fillHeadersWith === 'function') {
elem.html(config.fillHeadersWith(realHeader));
} else if (config.fillHeadersWith === 'content') {
elem.html(realHeader.clone().html());
} else {
elem.html(realHeader.clone());
}
elem.addClass('show');
body.addClass('has-sticky-header');
}
return me;
}
function determineCurrentHeaderRangeIndex(startIndex, direction) {
var index = startIndex;
while (true) {
currentHeaderRange = headerRanges[index];
if (!currentHeaderRange || isWithinRange(currentScrollOffset, currentHeaderRange)) {
break;
} else {
index += direction;
}
}
return index;
}
function onScroll() {
if (!headerRanges.length) {
return;
}
currentScrollOffset = contentContainer.scrollTop();
if (currentScrollOffset > headerRanges[0].start) {
var newCurrentHeaderRangeIndex = currentHeaderRangeIndex;
var currentHeaderRange = headerRanges[newCurrentHeaderRangeIndex];
if (newCurrentHeaderRangeIndex < 0) {
newCurrentHeaderRangeIndex = 0;
}
if (currentScrollOffset < lastScrollOffset) {
// scrolling up
newCurrentHeaderRangeIndex = determineCurrentHeaderRangeIndex(newCurrentHeaderRangeIndex, -1);
} else {
// scrolling down
newCurrentHeaderRangeIndex = determineCurrentHeaderRangeIndex(newCurrentHeaderRangeIndex, +1);
}
} else {
newCurrentHeaderRangeIndex = -1;
}
// only re-render when necessary
if (newCurrentHeaderRangeIndex !== undefined && currentHeaderRangeIndex !== newCurrentHeaderRangeIndex) {
currentHeaderRangeIndex = newCurrentHeaderRangeIndex;
render();
}
lastScrollOffset = currentScrollOffset;
}
function listenToScroll(element, callback, options) {
options = options || {};
if (options.every) {
element.on('scroll', function () {
isScrolling = true;
})
setInterval(function () {
if (isScrolling) {
callback();
isScrolling = false;
}
}, options.every);
}
else {
element.on('scroll', callback);
}
}
function isWithinRange(number, range) {
return (
number >= range.start &&
(
range.end === undefined ||
range.end === null ||
number <= range.end
)
);
}
function parseCssValue(value) {
if (value === null || value === undefined) {
return 0;
} else {
return parseInt(value, 10);
}
}
me.setHeaders = setHeaders;
me.setHeaderRanges = setHeaderRanges;
me.set = function (/* key, value | config */) {
if ($.isPlainObject(arguments[0])) {
$.extend(config, arguments[0]);
} else {
config[arguments[0]] = arguments[1];
}
return me;
}
me.add = function (/* selectors... */) {
selectors.push.apply(selectors, arguments);
return me;
}
me.activate = function () {
body = $('body');
contentContainer = config.contentContainer ? $(config.contentContainer) : body;
stickyHeaderContainer = config.stickyHeaderContainer ? $(config.stickyHeaderContainer) : contentContainer;
stickyHeaderContainer.append(elem);
setHeaders();
setHeaderRanges();
setCurrentHeaderIndex();
return me;
}
me.update = function () {
setHeaders();
setHeaderRanges();
render();
listenToScroll(contentContainer, onScroll);
}
me.getHeaders = function () {
return headers;
}
me.getHeaderRanges = function () {
return headerRanges;
}
init();
return me;
})(jQuery);

6
docs/v5.2.0/js/underscore.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,278 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/solarized.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/global.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
<title>Method List</title>
<base id="base_target" target="_parent" />
</head>
<body>
<div id="content">
<h1 id="full_list_header">Method List</h1>
<ul id="full_list" class="method">
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#accept_nested_attributes_for-instance_method" title="Shoulda::Matchers::ActiveRecord#accept_nested_attributes_for (method)">#accept_nested_attributes_for</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#allow_value-instance_method" title="Shoulda::Matchers::ActiveModel#allow_value (method)">#allow_value</a></span>
<small>(Shoulda::Matchers::ActiveModel)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#belong_to-instance_method" title="Shoulda::Matchers::ActiveRecord#belong_to (method)">#belong_to</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#define_enum_for-instance_method" title="Shoulda::Matchers::ActiveRecord#define_enum_for (method)">#define_enum_for</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/Independent.html#delegate_method-instance_method" title="Shoulda::Matchers::Independent#delegate_method (method)">#delegate_method</a></span>
<small>(Shoulda::Matchers::Independent)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#filter_param-instance_method" title="Shoulda::Matchers::ActionController#filter_param (method)">#filter_param</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_and_belong_to_many-instance_method" title="Shoulda::Matchers::ActiveRecord#have_and_belong_to_many (method)">#have_and_belong_to_many</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_db_column-instance_method" title="Shoulda::Matchers::ActiveRecord#have_db_column (method)">#have_db_column</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_db_index-instance_method" title="Shoulda::Matchers::ActiveRecord#have_db_index (method)">#have_db_index</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_implicit_order_column-instance_method" title="Shoulda::Matchers::ActiveRecord#have_implicit_order_column (method)">#have_implicit_order_column</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_many-instance_method" title="Shoulda::Matchers::ActiveRecord#have_many (method)">#have_many</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_many_attached-instance_method" title="Shoulda::Matchers::ActiveRecord#have_many_attached (method)">#have_many_attached</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_one-instance_method" title="Shoulda::Matchers::ActiveRecord#have_one (method)">#have_one</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_one_attached-instance_method" title="Shoulda::Matchers::ActiveRecord#have_one_attached (method)">#have_one_attached</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_readonly_attribute-instance_method" title="Shoulda::Matchers::ActiveRecord#have_readonly_attribute (method)">#have_readonly_attribute</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_rich_text-instance_method" title="Shoulda::Matchers::ActiveRecord#have_rich_text (method)">#have_rich_text</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#have_secure_password-instance_method" title="Shoulda::Matchers::ActiveModel#have_secure_password (method)">#have_secure_password</a></span>
<small>(Shoulda::Matchers::ActiveModel)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#have_secure_token-instance_method" title="Shoulda::Matchers::ActiveRecord#have_secure_token (method)">#have_secure_token</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#permit-instance_method" title="Shoulda::Matchers::ActionController#permit (method)">#permit</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#redirect_to-instance_method" title="Shoulda::Matchers::ActionController#redirect_to (method)">#redirect_to</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#render_template-instance_method" title="Shoulda::Matchers::ActionController#render_template (method)">#render_template</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#render_with_layout-instance_method" title="Shoulda::Matchers::ActionController#render_with_layout (method)">#render_with_layout</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#rescue_from-instance_method" title="Shoulda::Matchers::ActionController#rescue_from (method)">#rescue_from</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#respond_with-instance_method" title="Shoulda::Matchers::ActionController#respond_with (method)">#respond_with</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#route-instance_method" title="Shoulda::Matchers::ActionController#route (method)">#route</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#serialize-instance_method" title="Shoulda::Matchers::ActiveRecord#serialize (method)">#serialize</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#set_flash-instance_method" title="Shoulda::Matchers::ActionController#set_flash (method)">#set_flash</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#set_session-instance_method" title="Shoulda::Matchers::ActionController#set_session (method)">#set_session</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#use_after_action-instance_method" title="Shoulda::Matchers::ActionController#use_after_action (method)">#use_after_action</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#use_around_action-instance_method" title="Shoulda::Matchers::ActionController#use_around_action (method)">#use_around_action</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActionController.html#use_before_action-instance_method" title="Shoulda::Matchers::ActionController#use_before_action (method)">#use_before_action</a></span>
<small>(Shoulda::Matchers::ActionController)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_absence_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_absence_of (method)">#validate_absence_of</a></span>
<small>(Shoulda::Matchers::ActiveModel)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_acceptance_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_acceptance_of (method)">#validate_acceptance_of</a></span>
<small>(Shoulda::Matchers::ActiveModel)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_confirmation_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_confirmation_of (method)">#validate_confirmation_of</a></span>
<small>(Shoulda::Matchers::ActiveModel)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_exclusion_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_exclusion_of (method)">#validate_exclusion_of</a></span>
<small>(Shoulda::Matchers::ActiveModel)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_inclusion_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_inclusion_of (method)">#validate_inclusion_of</a></span>
<small>(Shoulda::Matchers::ActiveModel)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_length_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_length_of (method)">#validate_length_of</a></span>
<small>(Shoulda::Matchers::ActiveModel)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_numericality_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_numericality_of (method)">#validate_numericality_of</a></span>
<small>(Shoulda::Matchers::ActiveModel)</small>
</li>
<li class="r1 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveModel.html#validate_presence_of-instance_method" title="Shoulda::Matchers::ActiveModel#validate_presence_of (method)">#validate_presence_of</a></span>
<small>(Shoulda::Matchers::ActiveModel)</small>
</li>
<li class="r2 ">
<span class='object_link'><a href="Shoulda/Matchers/ActiveRecord.html#validate_uniqueness_of-instance_method" title="Shoulda::Matchers::ActiveRecord#validate_uniqueness_of (method)">#validate_uniqueness_of</a></span>
<small>(Shoulda::Matchers::ActiveRecord)</small>
</li>
</ul>
</div>
</body>
</html>

View File

@ -0,0 +1,133 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Top Level Namespace
&mdash; Documentation by YARD 0.9.25
</title>
<link rel="stylesheet" href="css/solarized.css" type="text/css" />
<link rel="stylesheet" href="css/bootstrap.css" type="text/css" />
<link rel="stylesheet" href="css/global.css" type="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<link rel="stylesheet" href="css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "";
relpath = '';
</script>
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery.stickyheaders.js"></script>
<script type="text/javascript" charset="utf-8" src="js/underscore.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
</head>
<body>
<div id="header">
<div class="header-row">
<div id="menu">
<span class="title">
<a href="index.html" title="Home">Home</a>
</span> &raquo;
<span class="title">Top Level Namespace</span>
</div>
<div id="search" class="js-search">
<ul>
<li>
<a href="class_list.html">
Class List
</a>
</li>
<li>
<a href="method_list.html">
Method List
</a>
</li>
<li>
<a href="file_list.html">
File List
</a>
</li>
</ul>
<iframe id="search_frame" class="js-search-frame"></iframe>
</div>
<div class="clear"></div>
</div>
</div>
<div id="main">
<div id="content"><h1>Top Level Namespace
</h1>
<dl class="box">
</dl>
<h2>Defined Under Namespace</h2>
<p class="children">
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Shoulda.html" title="Shoulda (module)">Shoulda</a></span>
</p>
</div>
<div id="footer">
Generated on
September 17, 2022
by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">YARD</a>.
</div>
</div>
</body>
</html>