0

We currently define a jQuery UI slider with:

/ Search implementation
$("input#price-range").slider({
  from:1,
  to:200,
  step:5,
  round:0,
  scale:[1, '|', 50, '|', 100, '|', 150, '|', 200],
  dimension:"$",
  skin:"round",
  callback: do_search
});

What I am trying to do is test that the effects of the moving the slider and the results of the callback function. Live, the code works but testing it with Capybara/Cucumber has proven to be difficult.

I have tried

page.execute_script("$('#price-range').slider('value',#{price});")

to set a value but the callbacks don't seem to be called this way. Any idea how I could set the value and get the callbacks to fire in my cucumber test?

JustNeph
  • 761
  • 3
  • 10
  • 25

1 Answers1

0

I don't believe that jQueryUI Slider implements a 'callback' option. At least, it's not listed here: http://api.jqueryui.com/slider/, and not evident in the code here: http://code.google.com/p/jquery-ui/source/browse/tags/1.8.2/ui/jquery.ui.slider.js. I suppose it could be defined further up the inheritance hierarchy.

Inside the source code for the slider, you can see that the value method calls _change, which will trigger a 'change' event. So, it might work better if you pass your callback function in like so:

/ Search implementation
$("input#price-range").slider({
  from:1,
  to:200,
  step:5,
  round:0,
  scale:[1, '|', 50, '|', 100, '|', 150, '|', 200],
  dimension:"$",
  skin:"round",
  change: do_search
}); 
Benjamin Cox
  • 6,090
  • 21
  • 19