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

Version Path
muck-engine-0.4.34 lib/test/muck_test_methods.rb
muck-engine-0.4.33 lib/test/muck_test_methods.rb
muck-engine-0.4.32 lib/test/muck_test_methods.rb
muck-engine-0.4.31 lib/test/muck_test_methods.rb
muck-engine-0.4.30 lib/test/muck_test_methods.rb
muck-engine-0.4.29 lib/test/muck_test_methods.rb
muck-engine-0.4.27 lib/test/muck_test_methods.rb
muck-engine-0.4.26 lib/test/muck_test_methods.rb
muck-engine-0.4.25 lib/test/muck_test_methods.rb
muck-engine-0.4.24 lib/test/muck_test_methods.rb
muck-engine-0.4.23 lib/test/muck_test_methods.rb
muck-engine-0.4.21 lib/test/muck_test_methods.rb
muck-engine-0.4.17 lib/test/muck_test_methods.rb
muck-engine-0.4.16 lib/test/muck_test_methods.rb
muck-engine-0.4.15 lib/test/muck_test_methods.rb
muck-engine-0.4.14 lib/test/muck_test_methods.rb
muck-engine-0.4.13 lib/test/muck_test_methods.rb
muck-engine-0.4.12 lib/test/muck_test_methods.rb
muck-engine-0.4.11 lib/test/muck_test_methods.rb
muck-engine-0.4.10 lib/test/muck_test_methods.rb