Sha256: 17ee9ba347d8bcf29c304bc8acde0ffe87e09fa60cbf31bbf82275e5f3be287a

Contents?: true

Size: 793 Bytes

Versions: 2

Compression:

Stored size: 793 Bytes

Contents

require 'spec_helper'
require 'fileutils'

describe Neoid::ModelConfig do
  context 'config on a model' do
    it 'stores stored_fields based on blocks' do
      article = Article.create!(title: 'Hello', year: 2012)
      expect(article.neo_node.title_length).to eq(article.title.length)
    end

    describe '.search_options' do
      subject(:search_options) { Article.neoid_config.search_options }

      it { should_not be_nil }
      its('index_fields.keys') { should match_array([:title, :body, :year]) }
    end

    describe '.stored_fields' do
      subject(:stored_fields) { Article.neoid_config.stored_fields }
      it { should_not be_nil }
      its(:keys) { should match_array([:title, :year, :title_length]) }
      its([:title_length]) { should be_a(Proc) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
neoid-0.2.1 spec/neoid/model_config_spec.rb
neoid-0.2.0 spec/neoid/model_config_spec.rb