Sha256: 1b5a203f2603c39a6eab8c855cdd501be9525b965e36768612c23e73b9c38781

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

require "rails_helper"

RSpec.describe "Liquid custom variables", type: :feature do
  let(:site) { create(:site) }
  let(:resource) do
    create(:page, site: site,
                  slug: "amazing",
                  title: "Amazing Page Title",
                  content: resource_content,
                  published_at: "2019-04-22 03:09:40 UTC")
  end

  let(:resource_content) do
    %(
      Page ID: {{ page.id }}
      Page Title: {{ page.title }}
      Page Permalink: {{ page.permalink }}
      Page Published At: {{ page.published_at }}
      Page Unknown: >{{ page.unknown_variable }}<
    )
  end

  before { resource }

  describe "for `page` variable object" do
    it "knows the `page` title property" do
      visit "/amazing"

      expect(page).to have_content("Page Title: Amazing Page Title")
    end

    it "knows the `page` id property" do
      visit "/amazing"

      expect(page).to have_content("Page ID: #{resource.id}")
    end

    it "knows the `page` permalink property" do
      visit "/amazing"

      expect(page).to have_content("Page Permalink: /amazing")
    end

    it "knows the `page` published_at property" do
      visit "/amazing"

      expect(page).to have_content("Page Published At: 2019-04-22 03:09:40 UTC")
    end

    it "returns blank value for unknown `page` properties" do
      visit "/amazing"

      expect(page).to have_content("Page Unknown: ><")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.4.0 spec/features/frontend/liquid/variables/page_spec.rb