Sha256: ba929e8fae8131e5151a94c3fa8f170f14df71b4118fe1ef2849809cb0d14a1d

Contents?: true

Size: 906 Bytes

Versions: 4

Compression:

Stored size: 906 Bytes

Contents

module TestHelpers
  def valid_attributes(attributes={})
    { :username => "usertest",
      :email => generate_unique_email,
      :password => '12345678',
      :password_confirmation => '12345678' }.update(attributes)
  end

  email_count = 0
  define_method :generate_unique_email do
    email_count += 1
    "test#{email_count}@example.com"
  end

  def new_user(attributes={})
    User.new(valid_attributes(attributes))
  end

  def create_user(attributes={})
    User.create!(valid_attributes(attributes))
  end

  def new_user_with_mailer(attributes={})
    UserWithMailer.new(valid_attributes(attributes))
  end

  def create_user_with_mailer(attributes={})
    UserWithMailer.create!(valid_attributes(attributes))
  end

  def new_admin(attributes={})
    Admin.new(valid_attributes(attributes))
  end

  def create_admin(attributes={})
    Admin.create!(valid_attributes(attributes))
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise-async-0.10.2 test/support/test_helpers.rb
devise-async-0.10.1 test/support/test_helpers.rb
devise-async-0.10.1.alpha test/support/test_helpers.rb
devise-async-0.9.0 test/support/test_helpers.rb