Sha256: 2388d8f68e578e35facfad14c71b694a68f92f49c466ff55cd8f112c4a0cb1d3

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe Daigaku::Storeable do

  it "responds to ::key" do
    expect(Daigaku::Storeable).to respond_to :key
  end

  describe '::key' do
    it "creates a store key from the given string" do
      key = Daigaku::Storeable.key('1-_Raw content-Title')
      expect(key).to eq 'raw_content_title'
    end

    it "creates a cleaned up store key from a given path string" do
      key = Daigaku::Storeable.key('path/to/the/1-_Raw content string')
      expect(key).to eq 'path/to/the/raw_content_string'
    end

    it "creates a prefixed key when a prefix option is given" do
      key = Daigaku::Storeable.key('1-_Raw content-Title', prefix: 'courses')
      expect(key).to eq 'courses/raw_content_title'
    end

    it "creates a suffixed key if a suffix option is given" do
      key = Daigaku::Storeable.key('1-_Raw content-Title', suffix: '1-author')
      expect(key).to eq 'raw_content_title/author'
    end

    it "creates a multi suffixed key if a suffixes option is given" do
      key = Daigaku::Storeable.key('1-_Raw content-Title', suffixes: ['meta', '1-author'] )
      expect(key).to eq 'raw_content_title/meta/author'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
daigaku-0.3.0 spec/daigaku/storeable_spec.rb
daigaku-0.2.0 spec/daigaku/storeable_spec.rb
daigaku-0.1.1 spec/daigaku/storeable_spec.rb
daigaku-0.1.0 spec/daigaku/storeable_spec.rb