Sha256: 4589a90c7424550cf7877b5b28a01b17526290736d344c1a98947b4ed87088a5

Contents?: true

Size: 879 Bytes

Versions: 4

Compression:

Stored size: 879 Bytes

Contents

# frozen_string_literal: true

require "test_helper"

class NodeModelLabelsTest < Minitest::Test
  include TestHelpers

  GRAPH = Redgraph::Graph.new("movies", url: $REDIS_URL)

  def setup
    @graph = GRAPH
  end

  def teardown
    @graph.delete
  end

  # test classes
  #

  class Actor
    include Redgraph::NodeModel
    self.graph = GRAPH
    attribute :name
  end

  class Artist
    include Redgraph::NodeModel
    self.label = "_artist"
  end

  class Painter < Artist
  end

  class Pianist < Artist
    self.label = "pianist"
  end

  # tests
  #

  def test_label
    assert_equal("actor", Actor.label)
  end

  def test_custom_label
    assert_equal("_artist", Artist.label)
  end

  def test_default_label_when_inherited
    assert_equal("painter", Painter.label)
  end

  def test_custom_label_when_inherited
    assert_equal("pianist", Pianist.label)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redgraph-0.2.3 test/node_model_labels_test.rb
redgraph-0.2.2 test/node_model_labels_test.rb
redgraph-0.2.1 test/node_model_labels_test.rb
redgraph-0.2.0 test/node_model_labels_test.rb