ruby on rails - Explain what respond_to? :should in cucumber? -


i using ruby on rails , cucumber first time. trying define step definitions , hope explain following code found in steps definitions me:

then /^(?:|i )should see movies: "([^\"]*)"/ |movie_list| #handles text containing text list of movies check     if page.respond_to? :should         page.should have_content(movie) #checks if movie appears on page     else     assert page.has_content?(text)     end end 

my scenario is:

scenario: ratings selected given on rottenpotatoes home page should see movies 

and trying test if items database being displayed. supposed use .should , assert on rows of database. hint got assert rows.should == value, can't work because don't understand it!

so upon further understanding, produced follow method handle above scenario:

then /^i should see movies$/   count = movie.count   assert rows.should == count unless !(rows.respond_to? :should) end 

but cucumber still failing scenario. suggestion?

here's explanation, line line:

then /^(?:|i )should see movies: "([^\"]*)"/ |movie_list| #handles text containing text list of movies check   # page respond should method? if does, rspec loaded, ,   # can use methods (especially should method,   # others)   if page.respond_to? :should     # page contain string movie variable refers to?     # i'm not sure variable being defined - perhaps mean     # movie_list?     page.should have_content(movie) #checks if movie appears on page   else     # rspec not installed, let's use testunit syntax instead, checking     # same thing - it's checking against variable 'text' - movie_list     # again? or else?     assert page.has_content?(text)   end end 

with in mind - when you're writing own steps, use rspec approach (if you're using rspec) or testunit approach. don't need if page.respond_to? :should everywhere in step definitions.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -