35 lines
965 B
Ruby
35 lines
965 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "helper"
|
|
|
|
class TestDataEntry < JekyllUnitTest
|
|
context "Data Entry" do
|
|
setup do
|
|
site = fixture_site
|
|
site.read
|
|
@data_hash = site.site_data
|
|
end
|
|
|
|
should "expose underlying data object es Liquid representation" do
|
|
subject = @data_hash["languages"]
|
|
assert_equal Jekyll::DataEntry, subject.class
|
|
assert_equal subject.data, subject.to_liquid
|
|
end
|
|
|
|
should "respond to `#[](key)` when expected to but raise Exception otherwise" do
|
|
greeting = @data_hash["greetings"]
|
|
assert greeting["foo"]
|
|
|
|
boolean = @data_hash["boolean"] # the value is a Boolean.
|
|
assert_raises(NoMethodError) { boolean["foo"] }
|
|
end
|
|
|
|
should "compare with another instance of same class using underlying data" do
|
|
assert_equal(
|
|
[%w(java ruby), %w(java ruby rust golang)],
|
|
[@data_hash["languages_plus"], @data_hash["languages"]].sort
|
|
)
|
|
end
|
|
end
|
|
end
|