<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Joey Cheng</title>
    <description>The latest articles on DEV Community by Joey Cheng (@jooeycheng).</description>
    <link>https://dev.to/jooeycheng</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F106031%2F88afc734-61da-4c79-a786-33e252892499.jpeg</url>
      <title>DEV Community: Joey Cheng</title>
      <link>https://dev.to/jooeycheng</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jooeycheng"/>
    <language>en</language>
    <item>
      <title>FactoryBot .find_or_create_by</title>
      <dc:creator>Joey Cheng</dc:creator>
      <pubDate>Mon, 18 Mar 2019 05:59:58 +0000</pubDate>
      <link>https://dev.to/jooeycheng/factorybot-findorcreateby-3h8k</link>
      <guid>https://dev.to/jooeycheng/factorybot-findorcreateby-3h8k</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;TL;DR&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="ss"&gt;:country&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;to_create&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_or_create_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;name: &lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;code: &lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;code&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;
    &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reload&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;How did I come up with that solution? See below.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There seems to be no clear documentation on how to go about this. So, here's what I tried.&lt;/p&gt;

&lt;p&gt;Before we begin, let's prepare our test environment, we will be using a &lt;code&gt;Country&lt;/code&gt; model, with attributes &lt;code&gt;name&lt;/code&gt; and &lt;code&gt;code&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# models/country.rb&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Country&lt;/span&gt;
  &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;presence: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;
  &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;presence: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;length: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;is: &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="ss"&gt;uniqueness: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;case_sensitive: &lt;/span&gt;&lt;span class="kp"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="c1"&gt;# ISO-3166-ALPHA-2&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# spec/factories/countries.rb&lt;/span&gt;

&lt;span class="no"&gt;FactoryBot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="ss"&gt;:country&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="nb"&gt;name&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'Canada'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'CA'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now, we're all good engineers and good engineers write unit tests. This will make verifying results easier. &lt;a href="https://gist.github.com/jooeycheng/a09c4701d1dfb68bdc9d3cc6028c9e24#the-rspec"&gt;The RSpec&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Attempt 1. Overriding the &lt;code&gt;initialize_with&lt;/code&gt; block
&lt;/h3&gt;

&lt;p&gt;This is the most voted answer on a &lt;a href="https://stackoverflow.com/a/11799674/3956879"&gt;question&lt;/a&gt; posted on StackOverflow. We can override a factory's default initialization behavior with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="ss"&gt;:country&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;initialize_with&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="no"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_or_create_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;name: &lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;code: &lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;While the solution does work, it &lt;em&gt;breaks the factory&lt;/em&gt;. Calling &lt;code&gt;build(:country)&lt;/code&gt; will now create a record in database if it does not exist.&lt;/p&gt;

&lt;p&gt;Looking at the comments section, we see a &lt;a href="https://stackoverflow.com/questions/7145256/find-or-create-record-through-factory-girl-association#comment51187522_11799674"&gt;suggestion&lt;/a&gt; to use &lt;code&gt;.find_or_initialize_by&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="ss"&gt;:country&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;initialize_with&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="no"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_or_initialize_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;name: &lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;code: &lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This partially restores behaviour of &lt;code&gt;build&lt;/code&gt; as it does not create a record anymore. However, it still returns a persisted record if found.&lt;/p&gt;

&lt;p&gt;This approach breaks the original behaviour of &lt;code&gt;build&lt;/code&gt;, which is to only &lt;em&gt;initialize a record&lt;/em&gt;, and not return a persisted record. There is also a performance cost of accessing the database to perform a &lt;code&gt;Country.find_by&lt;/code&gt;. An ideal solution would be to only access the database on &lt;code&gt;create&lt;/code&gt;, to create the record. We should not need to read or write to database on &lt;code&gt;build&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/jooeycheng/a09c4701d1dfb68bdc9d3cc6028c9e24#attempt-1"&gt;RSpec Results&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Attempt 2. Overriding the &lt;code&gt;to_create&lt;/code&gt; block (v1)
&lt;/h3&gt;

&lt;p&gt;Digging into FactoryBot documentation, we see a section on &lt;strong&gt;&lt;a href="https://www.rubydoc.info/gems/factory_bot/file/GETTING_STARTED.md#Custom_Methods_to_Persist_Objects"&gt;Custom Methods to Persist Objects&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By default, creating a record will call &lt;code&gt;save!&lt;/code&gt; on the instance; since this may not always be ideal, you can override that behavior by defining &lt;code&gt;to_create&lt;/code&gt; on the factory&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's try it out:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="ss"&gt;:country&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;to_create&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="no"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_or_create_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;name: &lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;code: &lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://gist.github.com/jooeycheng/a09c4701d1dfb68bdc9d3cc6028c9e24#attempt-2"&gt;RSpec Results&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the results, we see that &lt;code&gt;build&lt;/code&gt; and &lt;code&gt;create&lt;/code&gt; works as expected.&lt;br&gt;
However, &lt;code&gt;create&lt;/code&gt; seems to return the &lt;em&gt;factory-pre-save instance&lt;/em&gt; instead of the &lt;em&gt;created instance&lt;/em&gt;, which explains why the &lt;code&gt;country.id&lt;/code&gt; is &lt;code&gt;nil&lt;/code&gt;, but &lt;code&gt;Country.count&lt;/code&gt; increased. 🤔&lt;/p&gt;

&lt;p&gt;Alright, we're close. All we need is a way to set the attributes back to it's own instance after calling the &lt;code&gt;.find_or_create_by&lt;/code&gt; so it can assume identity of the found-or-created object.&lt;/p&gt;
&lt;h3&gt;
  
  
  Attempt 3. Overriding the &lt;code&gt;to_create&lt;/code&gt; block (v2)
&lt;/h3&gt;

&lt;p&gt;Now, we know the &lt;code&gt;instance&lt;/code&gt; in &lt;code&gt;to_create { |instance| ... }&lt;/code&gt; is the model object itself, which is an ActiveRecord model. Hence, we should be able to sort-of-force-update-the-attributes like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="ss"&gt;:country&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;to_create&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;attributes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_or_create_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;name: &lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;code: &lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;code&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;attributes&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;a href="https://gist.github.com/jooeycheng/a09c4701d1dfb68bdc9d3cc6028c9e24#attempt-31"&gt;RSpec Results&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Oh 💩it worked. But one last hurdle - &lt;code&gt;country.persisted?&lt;/code&gt; returns false. Easiest way to fix this is by &lt;code&gt;.reload&lt;/code&gt;-ing the instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="ss"&gt;:country&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;to_create&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;attributes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_or_create_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;name: &lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;code: &lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;code&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;attributes&lt;/span&gt;
    &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reload&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Yay, all green! 🚦&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/jooeycheng/a09c4701d1dfb68bdc9d3cc6028c9e24#attempt-32"&gt;RSpec Results&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But, &lt;code&gt;#reload&lt;/code&gt; is not the ideal solution, as it performs an unnecessary &lt;a href="https://apidock.com/rails/v4.2.7/ActiveRecord/Persistence/reload"&gt;database read&lt;/a&gt;, when all we want is for &lt;code&gt;#persisted?&lt;/code&gt; to behave correctly. Looking at the &lt;a href="https://apidock.com/rails/ActiveRecord/Persistence/persisted%3F"&gt;Rails documentation&lt;/a&gt;, we find that &lt;code&gt;#persisted?&lt;/code&gt; is the inverse of &lt;code&gt;#new_record?&lt;/code&gt;, which takes its value from instance variable &lt;code&gt;@new_record&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Which means, we could possibly do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="ss"&gt;:country&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;to_create&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;attributes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Country&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find_or_create_by&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;name: &lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;code: &lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;code&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;attributes&lt;/span&gt;
    &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;instance_variable_set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'@new_record'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kp"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Damn it worked 😎&lt;/p&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/jooeycheng/a09c4701d1dfb68bdc9d3cc6028c9e24#attempt-33"&gt;RSpec Results&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, I agree this is &lt;em&gt;hacky&lt;/em&gt;. Probably should just stick to &lt;code&gt;.reload&lt;/code&gt; to be safe. If this is not relevant to you, probably could just ignore the &lt;code&gt;.reload&lt;/code&gt; altogether.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cover image by &lt;a href="https://www.freepik.com/free-photos-vectors/abstract"&gt;Freepik&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>rspec</category>
      <category>ruby</category>
      <category>rails</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
