Closed yatsan closed 11 years ago
In the example above you are not returning anything of value from the routes method. The puts statement is the last statement and it does not return the value. Perhaps this is causing the problem. What error were you getting prior to updating the two methods?
I agree that changing to global is never a good idea.
If I reset my changes it will give: undefined method `[]' for nil:NilClass (NoMethodError)
navigate_all
this is because of include PageNavigation in env.rb. Fixed by removing it.
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:
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.