Sha256: 6fb538f041a08071f95f6dafb724b4b19570b9bd1915f6540899ed4f05684397

Contents?: true

Size: 1.1 KB

Versions: 12

Compression:

Stored size: 1.1 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
    Contract.by_date.should 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
    Contract.by_date.should reduce(
      ['1', {"date" => "2010-01-01"}], ['2', {"date" => "2010-01-02"}]
    ).to(2)
  end

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

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
couch_potato-1.4.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.3.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.2.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.1.4 spec/unit/properties_view_spec_spec.rb
couch_potato-1.1.2 spec/unit/properties_view_spec_spec.rb
couch_potato-1.1.1 spec/unit/properties_view_spec_spec.rb
couch_potato-1.1.0 spec/unit/properties_view_spec_spec.rb
couch_potato-1.0.1 spec/unit/properties_view_spec_spec.rb
couch_potato-1.0.0 spec/unit/properties_view_spec_spec.rb
couch_potato-0.7.1 spec/unit/properties_view_spec_spec.rb
couch_potato-0.7.0 spec/unit/properties_view_spec_spec.rb
couch_potato-0.7.0.pre.1 spec/unit/properties_view_spec_spec.rb