Working on a Cucumber/Watir test to test that a image rotator/cycle is working. My strategy is to the grab the active image in the rotator by css class and dump that in to a variable. Then I click the next button and grab the active image (which should now be a new image) in the rotator by css class and dump it into a second variable. Then I should be able to say img_rot_1 != img_rot_2 and have the test return true or false. This is the part were I am having trouble.

I am new to Ruby so I may be missing something simple. Here is the test.

2 Answers
2

I think you have to use instance variables if you want to access variable that is created in one step from another step.

Something like:

When /^I click the next image button$/ do
# more code here
@img_rot_1 = test_setup.b.li(:class => 'flex-active-slide').img.src
end
Then /^the rotator should move to the next image$/ do
img_rot_2 = test_setup.b.li(:class => 'flex-active-slide').img.src
@img_rot_1.should_not == img_rot_2
end