title: Can I use Rspec Expect in a module defined function?
body: <p>I'm trying to move my Cucumber Matcher into a function of a module</p>
  
  <pre><code>Then (/^posted "(.*?)" http response should be returned$/) do |arg1|
    expect($post_result.lines.last.to_i).to eq(arg1.to_i)
  end
  </code></pre>
  
  <p>The module function as below</p>
  
  <pre><code>module AccessFunc
      #  :
      #  : Some require... global variable setting etc
      #  :
    def self.posted_http_response_check(arg1)
      expect($post_result.lines.last.to_i).to eq(arg1.to_i)
    end
  end
  </code></pre>
  
  <p>Running my cucumber test with the cucumber matcher could use the Expect. But I can't use the Expect within my module. I tried using</p>
  
  <pre><code>include ::RSpec::Matchers
  </code></pre>
  
  <p>as per <a href="https://stackoverflow.com/questions/23624655/use-rspecs-expect-etc-outside-a-describe-it-block">Use RSpec&#39;s &quot;expect&quot; etc. outside a describe ... it block</a> but not successful.</p>
  
  <p>The error I got is </p>
  
  <pre><code>undefined method `expect' for AccessFunc:Module (NoMethodError)
  </code></pre>
  
  <p>Could someone shed some light how could I workaround this (e.g. using Expect within a Module.</p>
  
  <p>p/s: I could solve the problem by remove the Module, and define the function <em>posted_http_response_check</em> globally.</p>