push
github
Allow use of methods for has_many and has_many_ordered What? ===== This introduces functionality from 5ef0fd2c0 for has_many and has_many_ordered macros, allowing methods to be dynamically generated in those cases. A simple example: ```ruby class TodosList < PageEz::Page has_many_ordered :items do has_one :name, "[data-role='title']" has_one :checkbox, "input[type='checkbox']" end def items(state:) "li[data-state='#{state}']" end end ``` With the following markup: ```html <ul> <li data-state="complete"> <input type="checkbox" name="todos[1]" data-action="mark-incomplete" checked> <span data-role="title">Buy milk</span> </li> <li data-state="incomplete"> <input type="checkbox" name="todos[2]" data-action="mark-complete"> <span data-role="title">Buy eggs</span> </li> <li data-state="incomplete"> <input type="checkbox" name="todos[3]" data-action="mark-complete"> <span data-role="title">Buy onions</span> </li> </ul> ``` All of these assertions will work as expected: ```ruby todos = TodosList.new expect(todos.items(state: "complete")).to have_count_of(1) expect(todos.items(state: "incomplete")).to have_count_of(2) expect(todos).to have_item_at(0, state: "complete") expect(todos).not_to have_item_at(1, state: "complete") expect(todos).to have_item_at(0, state: "incomplete") expect(todos).to have_item_at(1, state: "incomplete") expect(todos).not_to have_item_at(2, state: "incomplete") expect(todos.item_at(0, state: "complete")).to have_name(text: "Buy milk") expect(todos.item_at(0, state: "complete").checkbox).to be_checked expect(todos.item_at(0, state: "incomplete")).to have_name(text: "Buy eggs") expect(todos.item_at(1, state: "incomplete")).to have_name(text: "Buy onions") ```
58 of 58 new or added lines in 4 files covered. (100.0%)
616 of 618 relevant lines covered (99.68%)
418.07 hits per line