0

Please note I'm new to SitePrism. I'm putting together a Capybara feature test case for editing data. The form's ID is "edit_bears_1", where you can imagine the #1 changes based on the current object's ID.

<form class="form-horizontal validate-form" id="edit_bears_1" action="admin/bears/1" accept-charset="UTF-8" method="post" novalidate="novalidate">

Here is the SitePrism file I created to define the form:

module Pages
  module Admin
    module Bears
      class Edit < SitePrism::Page
        set_url '/admin/bears/edit/:id'
        set_url_matcher %r{/admin/bears/\d+/edit}

        binding.pry
        section :form, Form, "form#edit_bears_1"
      end
    end
  end
end

As you can see I currently have the form's ID hard-coded to #1, but this is likely to change. How can I replace #1 with the some sort of variable that gets evaluated to and is linked to the bear I'm editing? All help is appreciated!

nmadoug
  • 47
  • 4

1 Answers1

0

You could script in something that would re-create it. Or if you feel as if this is something we should be supporting out of the box you could create an issue and request a new feature for it.

GH Link: https://github.com/natritmeyer/site_prism/issues

Script example 5.times { |i| section "form#{i}", Form, "form#edit_bears_#{i}" }

Make sure to give each of the references an index-linked name otherwise they'll self-overwrite.

Luke Hill
  • 460
  • 2
  • 10