I'm currently trying to test my rails app using rspec and watir. But i'm
having problems filling out rails generated form fields. When I try to set
the field (using both set and value ==) I get the following error:
undefined method `set' for #<ActiveSupport::SafeBuffer:0x572aaf8>. I also
get a similar error when trying to do when_present or flash.
I've setup my tests within the apps spec folder. When the test runs it's
starting up the test server. I'm using the following gems: rspec-rails,
waitr-rspec, watir-rails.
the html of the field i'm trying to set is :
<input id="trip_type_name" name="trip_type[name" size="30" type="text">
This is my spec:
require 'spec_helper'
describe "TripTypes" do
before :all do
goto "/"
end
it 'loads the form after clicking the "Add Type" Button' do
link(:id, "add-trip-type").when_present.click
form(:id, "new_trip_type").should be_visible
end
context "with Variable Options" do
before :all do
@type_name = Faker::Lorem.sentence(2)
@field_one = Faker::Lorem.word
@field_two = Faker::Lorem.word
end
it "fills in the trip type name" do
text_field(:index, 0).set @type_name
end
it "adds the first field" do
link(:id, "add-field").click
tr(:index, 1).text_field(:index, 0).set @field_one
end
it "adds the variable field" do
link(:id, "add-field").click
tr(:index, 2).text_field(:index, 0).set @field_two
end
it "clicks Create Trip Type" do
button(:id, "create-trip-type").click
end
it "displays the trip type in the trip types table" do
div(:class, /alert-success/).should be_visible
div(:class, /alert-success/).text.should include "Successfully
created trip type."
table(:id, "trip-types-table").tr(:index, 1).td(:index,
0).text.should == @type_name
end
end
end
The first test is failing. The other two fields fill in tests are passing.
Both of the fields i can set are created using a jquery add_fields
function.
Also when i try to manually set the field on the standard rails server
:3000 it works fine.
i'm not sure what's going on.
--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.