ruby - Putting Faker Gem Values to a Hash -



ruby - Putting Faker Gem Values to a Hash -

i'm writing automated tests using cucumber, capybara, webdriver, siteprism, , faker. new , need help.

i have next steps..

given (/^i have created new active product$/) @page = adminproductcreationpage.new @page.should be_displayed @page.producttitle.set faker::name.title @page.product_sku.set faker::number.number(8) click @page.product_save @page.should have_growl text: 'save successful.' end when (/^i navigate product detail page) pending end (/^all info should match entered$/) pending end

in config/env_config.rb have set empty hash...

before # empty container sharing info between step definitions @verify = {} end

now want hash value generated faker in "given" step can validate saved in "when" step. want come in value generated faker in script below search field.

@page.producttitle.set faker::name.title how force values generated faker @verify has? how pull value , insert text field? how pull value verify save value equals value generated faker?

1. how force values generated faker @verify has?

a hash dictionary of key-value pairs, can set hash[key] = value.

the key can string @verify['new_product_name'] = faker::name.title

the key can symbol @verify[:new_product_name] = faker::name.title

since value generate may used multiple times within step definition (once storing in @verify hash, , 1 time setting field value) prefer first store in local variable, , reference needed.

new_product_title = faker::name.title @verify[:new_product_title] = new_product_title

2. how pull value , insert text field?

you can reference values key. after have stored value in hash, @page.producttitle.set @verify[:new_product_name]

or if stored in local variable suggested above, this

@page.producttitle.set new_product_name

3. how pull value verify save value equals value generated faker?

similarly, can assert field value equals you've stored in hash. illustration @page.producttitle.value.should == @verify[:new_product_name]

putting together:

given (/^i have created new active product$/) @page = adminproductcreationpage.new @page.should be_displayed # create new title new_product_title = faker::name.title # store title in hash verification @verify[:new_product_title] = new_product_title # set input value our new title @page.producttitle.set new_product_title @page.product_sku.set faker::number.number(8) click @page.product_save @page.should have_growl text: 'save successful.' end when (/^i navigate product detail page) pending end (/^all info should match entered$/) @page.producttitle.value.should == @verify[:new_product_title] end

ruby hash cucumber capybara faker

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -