簡體   English   中英

Frank Cucumber:自定義類中的app_exec拋出異常

[英]Frank Cucumber: app_exec in custom class throwing exception

我正在嘗試從launch_steps.rb文件中的自定義類內部調用app_exec,但我不斷收到此異常:

MyJSON:Class的未定義方法`app_exec'(NoMethodError)

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

問題是我包括而不是擴展:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM