Sha256: 200658e0773c5dcefa12e80fdde0a9b6752196ea5296f552eb8f08eedb0800d9

Contents?: true

Size: 1.11 KB

Versions: 17

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'
require 'couch_potato/rspec'

class Contract
  include CouchPotato::Persistence

  property :date
  property :terms

  view :by_date, :type => :properties, :key => :_id, :properties => [:date]
end

describe CouchPotato::View::PropertiesViewSpec do
  before(:each) do
    @default_language = CouchPotato::Config.default_language
  end

  after(:each) do
    CouchPotato::Config.default_language = @default_language
  end

  it "should map the given properties" do
    expect(Contract.by_date).to map(
      Contract.new(:date => '2010-01-01', :_id => '1')
    ).to(['1', {"date" => "2010-01-01"}])
  end

  it "should reduce to the number of documents" do
    expect(Contract.by_date).to reduce(
      ['1', {"date" => "2010-01-01"}], ['2', {"date" => "2010-01-02"}]
    ).to(2)
  end

  it "should rereduce the number of documents" do
    expect(Contract.by_date).to rereduce(
      nil, [12, 13]
    ).to(25)
  end

  it 'always uses javascript' do
    CouchPotato::Config.default_language = :erlang
    expect(CouchPotato::View::PropertiesViewSpec.new(Contract, 'all', {}, {}).language).to eq(:javascript)
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
couch_potato-1.18.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.17.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.16.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.15.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.14.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.13.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.12.1 spec/unit/properties_view_spec_spec.rb
couch_potato-1.12.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.11.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.10.1 spec/unit/properties_view_spec_spec.rb
couch_potato-1.10.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.9.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.7.1 spec/unit/properties_view_spec_spec.rb
couch_potato-1.7.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.6.5 spec/unit/properties_view_spec_spec.rb
couch_potato-1.6.4 spec/unit/properties_view_spec_spec.rb
couch_potato-1.6.3 spec/unit/properties_view_spec_spec.rb