Check the last inserted record with Cucumber
When testing complex forms interactions it may be useful checking that fields are written correctly into the db.
With ActiveRecord, create a database.yml as usual and map the classes:
require 'active_record'
require 'mysql2'
dbconfig = YAML::load(File.open('database.yml'))
ActiveRecord::Base.establish_connection(dbconfig)
class Domain < ActiveRecord::Base
end
Now you can access data and test if the field registrar has been written in the last insertion:
Then /^the last inserted domain must be valid$/ do
registrar = Domain.last.registrar
registrar.should_not eq(nil)
end
Written by Fabrizio Soppelsa
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#