Sha256: d1b63d6fce89275f180e7ec0bf81b42ef9b1747059d7e1f330e0cb9f751a5f33

Contents?: true

Size: 1.93 KB

Versions: 3

Compression:

Stored size: 1.93 KB

Contents

require 'spec_helper'

describe Noumenon do
  describe "accessing the content repository" do
    it "can be set" do
      Noumenon.content_repository = Noumenon::ContentRepository.new
    end

    it "can be retrieved" do
      repo = Noumenon::ContentRepository.new
      Noumenon.content_repository = repo
      Noumenon.content_repository.should == repo
    end
  end
  
  describe "accessing the asset repository" do
    it "returns the content repository if it has not been set" do
      Noumenon.content_repository = Noumenon::ContentRepository.new
      Noumenon.asset_repository.should === Noumenon.content_repository
    end

    it "returns the set asset repository if one has been set" do
      content = Noumenon::ContentRepository.new
      assets = Noumenon::ContentRepository.new

      Noumenon.content_repository = content
      Noumenon.asset_repository = assets
      Noumenon.asset_repository.should === assets
    end
  end

  describe "setting the theme" do
    context "when assigning with a Theme object" do
      it "sets the theme directly" do
        theme = Noumenon::Theme.new("/tmp")
        Noumenon.theme = theme
        Noumenon.theme.should == theme
      end
    end

    context "when assigning a theme name" do
      around do |example|
        with_temporary_theme(name: "Example Theme") do
          example.run
        end
      end
      
      it "sets the theme if it has been registered" do
        Noumenon::Theme.load(theme_path)

        Noumenon.theme = "Example Theme"
        Noumenon.theme.should == Noumenon::Theme.themes["Example Theme"]
      end

      it "raises an ArgumentError if it has not been registered" do
        error_raised = false

        begin
          Noumenon.theme = "Unloaded Theme"
        rescue ArgumentError => e
          error_raised = true
          e.to_s.should == "The theme 'Unloaded Theme' has not been loaded."
        end

        error_raised.should be_true
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
noumenon-0.2.2 spec/noumenon_spec.rb
noumenon-0.2.1 spec/noumenon_spec.rb
noumenon-0.2.0 spec/noumenon_spec.rb