0

I am just trying to find out why i need to define it as instance variable? Why not local? I know @home can be shared across all step def methods. Without this is there any other specific reason? Please help me out to understand the reason other than what i know.

When /^I navigate to the google home page$/ do
  @home = Home.new
  @home.load
end

Here's the link URL: https://github.com/natritmeyer/site_prism

Eugene S
  • 6,709
  • 8
  • 57
  • 91
ASM
  • 709
  • 2
  • 8
  • 27

2 Answers2

1

The only reason is for sharing between steps. If the object is only needed in the one step then it can be a local variable. If @home is not used in any other step your example could just become

When /^I navigate to the google home page$/ do
  Home.new.load
end
Thomas Walpole
  • 48,548
  • 5
  • 64
  • 78
0

The reason they are used in the examples in SitePrism as instance variables is because that example uses Cucumber and all instance variables are accessible in the single World context.

Luke Hill
  • 460
  • 2
  • 10