0

When I run my Outline Scenario directly from step_definition it works but if I implement it in the class it doesn't. When I run the class method I get the following error: undefined local variable or method _email' for #<CriaScreenLogin:0x0000016956d426f8> (NameError) ./features/pages/page_login.rb:49:in invalid_login'

See my code from step_defintion work fine
When('to provide {string} or {string} inválids') do |_email, _pswd|
  screen_login.input_user.set(_email).send_keys(:tab)
  screen_login.input_pswd.set(_pswd).send_keys(:tab)
  screen_login. btn_enter.click
end

my code from class (site-prism)
class CreateScreenLogin < SitePrism::Page

  include RSpec::Mocks::ExampleMethods::ExpectHost
  include RSpec::Matchers 

  element :input_user,                        "#usuario"  
  element :input_pswd,                         "#senha"
  element :btn_enter,                        "#btn-submit" 
     
  def invalid_login
     input_user.set(_email).send_keys(:tab)
     input_pswd.set(_pswd).send_keys(:tab)
     btn_enter.click
   end

Screen_login.invalid_login   #error
Tadeu
  • 67
  • 6
  • 1
    In your step definition, `_email` and `_pswd` are defined because they are being passed as block arguments. You could use `def invalid_login(_email, _pswd)` and pass them as arguments when calling the method. – Stefan Dec 06 '21 at 11:26
  • 1
    As an aside the `_variable` syntax is usually (read idiomatically) reserved for unused variables. It is meant to be a communicative placeholder that suggests the the variable is `email` but I won't be using it. This syntax is also used for private/internal method definitions that should not be used publicly `def _method_name` as well as private/internal instance methods `@_private_instance_method` – engineersmnky Dec 06 '21 at 13:02
  • Perfect Thank'u X infinite!!! – Tadeu Dec 06 '21 at 14:30
  • Thank to Stefan and engenheirosmnky... – Tadeu Dec 06 '21 at 14:32

0 Answers0