Sha256: 6d32424103e1ad947b4c72c4decad4dd9c61e4660fce81b7410496c187f5adb4

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

require 'test_helper'

class Superstore::CoreTest < Superstore::TestCase
  test 'initialize' do
    issue = Issue.new

    assert issue.new_record?
    assert !issue.destroyed?
  end

  test 'equality of new records' do
    assert_not_equal Issue.new, Issue.new
  end

  test 'equality' do
    first_issue = Issue.create
    second_issue = Issue.create

    assert_equal first_issue, first_issue
    assert_equal first_issue, Issue.find(first_issue.id)
    assert_not_equal first_issue, second_issue
  end

  test 'to_param' do
    issue = Issue.new
    assert_equal issue.id, issue.to_param
  end

  test 'hash' do
    issue = Issue.create
    issue2 = Issue.create
    refute_equal issue.hash, issue2.hash

    issue3 = Issue.new(id: issue.id)
    assert_equal issue.hash, issue3.hash

    user = User.new(id: issue.id)
    refute_equal issue.hash, user.hash
  end

  test 'inspect' do
    issue = Issue.create
    assert issue.inspect =~ /^#<Issue id: \"\w+\", description: \".+\", created_at: \".+\", updated_at: \".+\">$/
  end

  test 'inspect class' do
    expected = "Issue(id: string, description: string, title: string, parent_issue_id: string, comments: json, created_at: time, updated_at: time)"
    assert_equal expected, Issue.inspect
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
superstore-3.0.0 test/unit/core_test.rb