I'm trying to move my Cucumber Matcher into a function of a module
Then (/^posted "(.*?)" http response should be returned$/) do |arg1|
expect($post_result.lines.last.to_i).to eq(arg1.to_i)
end
The module function as below
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
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
include ::RSpec::Matchers
as per Use RSpec's "expect" etc. outside a describe ... it block but not successful.
The error I got is
undefined method `expect' for AccessFunc:Module (NoMethodError)
Could someone shed some light how could I workaround this (e.g. using Expect within a Module.
p/s: I could solve the problem by remove the Module, and define the function posted_http_response_check globally.