title: Rspec Test for Regular Expression
body: <p>*I am still very new to testing</p>
  
  <p>Code (simply returns a number if it's three digits or less)</p>
  
  <p>File name: example.rb</p>
  
  <pre><code>def separate_comma(number)
    str_array_length &lt;= 3 ? (return number) : (return false)
  end
  </code></pre>
  
  <p>Rspec</p>
  
  <p>File name: spec_example.rb</p>
  
  <pre><code>require_relative "example"
  require 'rspec'
  
  def random_num(min, max)
     rand(max - min + 1) + min
  end
  
  describe "separate_comma" do
     it "returns no comma, when the integer is smaller than 1000" do
       expect(separate_comma(random_num(0, 999))).to match(/^\d{1,3}$/)
     end
  end
  </code></pre>
  
  <p>Whenever I run this, I get the error:</p>
  
  <pre><code>./spec_example.rb:10:in `block (2 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <p>Any suggestions? I believe something is wrong with the regular expression, so I tried match(/\d{13}/) and that failed too.</p>