Frank Cucumber: app_exec in custom class throwing exception

70 views Asked by At

I am trying to call app_exec from inside a custom class within my launch_steps.rb file but I keep getting this exception:

undefined method `app_exec' for MyJSON:Class (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
1

There are 1 answers

0
BinaryShrub On

The issue was the fact that I was including instead of extending:

class MyJSON
  extend Frank::Cucumber::FrankHelper

I am still not sure why I could not reference it without extending though. Even if I tried the following it would not work:

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