Sha256: 144931df77c91e584bbeef20f4fbad882cd55858d8a3d349882a1ed02af7444a
Contents?: true
Size: 1.24 KB
Versions: 39
Compression:
Stored size: 1.24 KB
Contents
module MuckTestMethods def login_as(user) success = UserSession.create(user) if !success errors = user.errors.full_messages.to_sentence message = 'User has not been activated' if !user.active? raise "could not login as #{user.to_param}. Please make sure the user is valid. #{message} #{errors}" end UserSession.find end def assure_logout user_session = UserSession.find user_session.destroy if user_session end def ensure_flash(val) assert_contains flash.values, val, ", Flash: #{flash.inspect}" end def ensure_flash_contains(val) flash.values.each do |flv| return true if flv.include?(val) end false end # Add more helper methods to be used for testing xml def assert_xml_tag(xml, conditions) doc = HTML::Document.new(xml) assert doc.find(conditions), "expected tag, but no tag found matching #{conditions.inspect} in:\n#{xml.inspect}" end def assert_no_xml_tag(xml, conditions) doc = HTML::Document.new(xml) assert !doc.find(conditions), "expected no tag, but found tag matching #{conditions.inspect} in:\n#{xml.inspect}" end def make_parent_params(parent) { :parent_id => parent.id, :parent_type => parent.class.to_s } end end
Version data entries
39 entries across 39 versions & 1 rubygems