Sha256: 14d4a3e132e71e81a3af75f6c24007a909094cef36db706f723fa436b72aeef6

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require 'test_helper'

class MetaBuildTest < ActiveSupport::TestCase
  
  test "building single instance" do
    user = UserBuilder.user!
    assert user.valid?
    assert user.persisted?
  end

  test "building unpersisted instance" do
    user = UserBuilder.user

    assert user.valid?
    assert !user.persisted?
  end

  test "building many valid instances" do
    many_users = UserBuilder.user! qty: 50

    assert many_users.all?(&:valid?)
    assert many_users.all?(&:persisted?)
  end

  test "building many unpersisted instances" do
    many_users = UserBuilder.user qty: 50

    assert many_users.all?(&:valid?)
    assert many_users.all?{|u| !u.persisted?}
  end

  test "passing arguments to builders" do
    custom_user = UserBuilder.customUser params: {name: 'foo', email: 'bar@foobar.com'}, save: true

    assert_equal custom_user.name, 'foo', msg: "Failed user name assertion"
    assert_equal custom_user.email, 'bar@foobar.com', msg: "Failed user name assertion"
    assert custom_user.valid?, msg: "User is not valid"
    assert custom_user.persisted?, msg: "User hasn't been persisted"
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bob-builder-0.1.1 test/meta_build_test.rb
bob-builder-0.1.0 test/meta_build_test.rb