-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to access instance variables from custom placeholders #236
Comments
@gongo, maybe you can help me out ? Thank you ! |
I've been able to place a placeholder inside a module by including |
Nice thanks for the comment ! I'll try that 👍 |
Well i can now indeed put a custom placeholder into a module but instance variables are still nil inside it... |
Hi @Tyflomate. Sorry for the late reply.
It impossible because placeholders are defined outside each step (module).
1️⃣ Declare with a global variable: placeholder :right do
match /admin/ do
$user.rights.find_by(admin: true)
end
match /visitor/ do
$user.rights.find_by(visitor: true)
end
match /member/ do
$user.rights.find_by(member: true)
end
end 2️⃣ Use module Right
step 'set user' do
# examples..
@user = {
admin: 'admin',
visitor: 'visitor',
member: 'member',
}
end
step 'displayed :name' do |name|
@right.should eq(name)
end
end
steps_for :admin do
include Right
step 'get right' do
@right = @user[:admin]
end
end
steps_for :visitor do
include Right
step 'get right' do
@right = @user[:visitor]
end
end Feature: Steps for a feature
Background:
Given set user
@admin
Scenario: Admin
Given get right
Then displayed "admin"
@visitor
Scenario: Visitor
Given get right
Then displayed "visitor" |
Hello ! I have a problem that is mentioned in #62 but this issue is pretty old so I decided to create a new one.
I would like to access an instance variable inside a place holder to do for example something like this:
@user
is initialized in an other step file. For now, I tried implementing my steps outside a module but then@user
was nil in my placeholder so I tried to move everything into the same module to counter this but now I have the error:undefined method
placeholder' for #Module:0x00007fa2f6ad3c98::Steps`.So my question is: is it possible to access instance variables into placeholders ? How could I manage to make this work ?
Thanks a lot guys !
The text was updated successfully, but these errors were encountered: