Sha256: 3caaf1fbf12d50747407e59f89b7c9e683d53c06875ec5f1c8e8dd8f49e4f037

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

require "test_helper"
require "minitest/spec"
require "minitest/autorun"

describe Concen::User do
  before do
    DatabaseCleaner.clean
  end

  it "can create user" do
    user = Fabricate "concen/user"
    user.id.wont_be_nil
  end

  it "has password_digest" do
    user = Fabricate "concen/user"
    user.password_digest.wont_be_nil
  end

  it "has auth_token" do
    user = Fabricate "concen/user"
    user.auth_token.wont_be_nil
  end

  it "has username" do
    user = Fabricate.build "concen/user", :username => nil
    lambda { user.save! }.must_raise(Mongoid::Errors::Validations)
    user.errors[:username].first.must_equal "can't be blank"
  end

  it "has email" do
    user = Fabricate.build "concen/user", :email => nil
    lambda { user.save! }.must_raise(Mongoid::Errors::Validations)
    user.errors[:email].first.must_equal "can't be blank"
  end

  it "has full_name" do
    user = Fabricate.build("concen/user", :full_name => nil)
    lambda { user.save! }.must_raise(Mongoid::Errors::Validations)
    user.errors[:full_name].first.must_equal "can't be blank"
  end

  it "must authenticate user" do
    password = {:password => "newpassword", :password_confirmation => "newpassword"}
    user = Fabricate "concen/user", password
    authenticated_user = user.authenticate("newpassword")
    authenticated_user.wont_equal false
    authenticated_user.must_be_instance_of Concen::User
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
concen-0.2.6 test/unit/user_test.rb
concen-0.2.5 test/unit/user_test.rb
concen-0.2.4 test/unit/user_test.rb
concen-0.2.3 test/unit/user_test.rb