I am trying to get best in place's test helpers working in my app. I am using Capybara with Test::Unit I have written a test like this.
class CompaniesTest < ActionDispatch::IntegrationTest
include BestInPlace::TestHelpers
def setup
@company = companies(:public)
end
test "should have best in place fields on show" do
get company_path(@company)
assert_response :success
assert_match @company.name, response.body
bip_text( @company, :name, "new name" )
end
end
I am getting an error like this
Capybara::ElementNotFound: Unable to find css "#best_in_place_company_1001664029_name"
I tried adding a sleep(0.5) before bip_text to see if it is a timing issue this did not change the error.
EDIT:
<span data-bip-type="input"
data-bip-attribute="name"
data-bip-object="company"
data-bip-original-content="Lightbulbs Corp."
data-bip-skip-blur="false"
data-bip-url="/companies/1001664029"
data-bip-value="Lightbulbs Corp."
class="best_in_place"
id="best_in_place_company_1001664029_name">Lightbulbs Corp.</span>
Here is what the css element for the page in the test env looks like. It looks like the id is correct. Any help would be appreciated.
I just reread your question and noticed you're using get
. That's not a Capybara method and you can't mix the two different APIs and expect things to work. To implement what you're doing using Capybara it would be something like
test "should have best in place fields on show" do
visit company_path(@company)
assert_text @company.name
bip_text( @company, :name, "new name" )
end