Hello!
I'm receiving NoMethodError: undefined method `[]' for nil:NilClass error for:
Given(/^the app is added to Favourites$/) do
navigate_all
end
env.rb:
require 'rspec-expectations'
require 'page-object'
require 'page-object/page_factory'
require 'fig_newton'
require 'require_all'
require 'watir-webdriver'
require 'data_magic'
require 'page_navigation'
require_relative 'helper'
require_rel 'pages'
include WebApp
include DataMagic
include Helper
include PageNavigation
World(PageObject::PageFactory)
PageObject::PageFactory.routes = {
:default => [[LoginPage, :login_to_system_if_needed],
[BrowseAppsPage, :myapps_operations, false]]]
}
It seems, that in routes.rb file @routes variable looses it's value and becomes Nil. So if to change:
def routes
@routes
puts '!!!!!!!!!!!!!!'
puts @routes
end
def routes=(routes)
raise("You must provide a :default route") unless routes[:default]
@routes = routes
puts '@@@@@@@@@@@@@@'
puts @routes
end
I get =>
C:\Ruby\bin\ruby.exe -EUTF-8 -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/Ruby/bin/cucumber C:/HOME/Ruby/test/features/sanity/test/test.feature --format Teamcity::Cucumber::Formatter --expand --color -r features
Testing started at 7:34 PM ...
@@@@@@@@@@@@@@
{:default=>[[LoginPage, :login_to_system_if_needed], [BrowseAppsPage, :myapps_operations], [MyAppsPage, :add_to_favourites]]}
Tags: @@Amo, @@resource_myapps
!!!!!!!!!!!!!!
NoMethodError: undefined method `[]' for nil:NilClass
So I've corrected it by changing @routes variable in routes.rb to $routes but I don't think that it's a good idea.