0

我正在尝试从我的 launch_steps.rb 文件中的自定义类内部调用 app_exec,但我不断收到此异常:

MyJSON:Class (NoMethodError) 的未定义方法“app_exec”

Then (/^I check the json/) do
  MyJSON.requestJson
  puts MyJSON.json
  # If I put app_exec here, it will work fine
  # app_exec( "getJsonMessages:", true )
end

class MyJSON
  include Frank::Cucumber::FrankHelper

  @json = nil
  @flush = true;

  def self.requestJson
    @json=app_exec( "getJsonMessages:", true ) #undefined method even with the inclusion of FrankHelper
    if @json.count==0
      @json = nil
      raise "No Data Returned From Application"
    end
  end

  def self.json
    @json
  end

end
4

1 回答 1

0

问题是我包含而不是扩展:

class MyJSON
  extend Frank::Cucumber::FrankHelper

我仍然不确定为什么我不能在不扩展的情况下引用它。即使我尝试了以下方法也行不通:

class MyJSON
  include Frank::Cucumber::FrankHelper

  @json = nil
  @flush = true;

  def self.requestJson
    @json=Frank::Cucumber::FrankHelper.app_exec( "getJsonMessages:", true ) #undefined method even with the inclusion of FrankHelper
    if @json.count==0
      @json = nil
      raise "No Data Returned From Application"
    end
  end
于 2014-06-20T20:55:12.183 回答