Sha256: 78c20a877f9d24ac2ed28e177f56b648554269cf7e401feab6f538c019704500

Contents?: true

Size: 1.14 KB

Versions: 38

Compression:

Stored size: 1.14 KB

Contents

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

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
muck-engine-3.5.0 lib/test/muck_test_methods.rb
muck-engine-3.4.0 lib/test/muck_test_methods.rb
muck-engine-3.3.18 lib/test/muck_test_methods.rb
muck-engine-3.3.17 lib/test/muck_test_methods.rb
muck-engine-3.3.16 lib/test/muck_test_methods.rb
muck-engine-3.3.15 lib/test/muck_test_methods.rb
muck-engine-3.3.14 lib/test/muck_test_methods.rb
muck-engine-3.3.13 lib/test/muck_test_methods.rb
muck-engine-3.3.12 lib/test/muck_test_methods.rb
muck-engine-3.3.11 lib/test/muck_test_methods.rb
muck-engine-3.3.10 lib/test/muck_test_methods.rb
muck-engine-3.3.9 lib/test/muck_test_methods.rb
muck-engine-3.3.8 lib/test/muck_test_methods.rb
muck-engine-3.3.7 lib/test/muck_test_methods.rb
muck-engine-3.3.6 lib/test/muck_test_methods.rb
muck-engine-3.3.5 lib/test/muck_test_methods.rb
muck-engine-3.3.4 lib/test/muck_test_methods.rb
muck-engine-3.3.3 lib/test/muck_test_methods.rb
muck-engine-3.3.2 lib/test/muck_test_methods.rb
muck-engine-3.3.1 lib/test/muck_test_methods.rb