hinthealth / behave

Front-end testing helpers
MIT License
1 stars 0 forks source link

find vs findall vs tryfind #12

Open melcher opened 10 years ago

melcher commented 10 years ago

Proposed functionality for find/findAll:

  // Find an element
  // -- throws an exception unless results.length !== 1
  find('string') 

  // Find any/all elements
  // -- finds any number of elements (including 0)
  // -- could be used by the find function
  findAll('string') 

  // Find a specific number of elements
  // -- throws an exception unless results.length == number
  find(3, 'string')
  // alternatively
  find('string', {length: 3})

I believe this would remove the necessity for tryfind, as you could just do a findAll. This loosely borrows it's behavior/syntax from ActiveRecord, where find() will throw an exception or return 1 element and find_all just returns any number of elements and doesn't throw an exception in any case.

melcher commented 10 years ago

@EpiphanyMachine @bwest87 @khempenius thoughts?