Sha256: 22fcd77d71bb184e6c742788984960b0c9473cb71930840f5cac4096dc7dc3c9

Contents?: true

Size: 764 Bytes

Versions: 24

Compression:

Stored size: 764 Bytes

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
  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
end

Version data entries

24 entries across 24 versions & 3 rubygems

Version Path
couch_potato-0.6.0 spec/unit/properties_view_spec_spec.rb
couch_potato-0.5.7 spec/unit/properties_view_spec_spec.rb
couch_potato-rails2-0.5.10 spec/unit/properties_view_spec_spec.rb
couch_potato-rails2-0.5.9 spec/unit/properties_view_spec_spec.rb
couch_potato-rails2-0.5.8 spec/unit/properties_view_spec_spec.rb
couch_potato-rails2-0.5.7 spec/unit/properties_view_spec_spec.rb
couch_potato-rails2-0.5.6 spec/unit/properties_view_spec_spec.rb
couch_potato-0.5.6 spec/unit/properties_view_spec_spec.rb
couch_potato-0.5.5 spec/unit/properties_view_spec_spec.rb
couch_potato-0.5.4 spec/unit/properties_view_spec_spec.rb
couch_potato-0.5.3 spec/unit/properties_view_spec_spec.rb
couch_potato-0.5.2 spec/unit/properties_view_spec_spec.rb
couch_potato-0.5.1 spec/unit/properties_view_spec_spec.rb
couch_potato-0.5.0 spec/unit/properties_view_spec_spec.rb
davber_couch_potato-0.4.0 spec/unit/properties_view_spec_spec.rb
couch_potato-0.4.0 spec/unit/properties_view_spec_spec.rb
couch_potato-0.3.2 spec/unit/properties_view_spec_spec.rb
couch_potato-0.3.1 spec/unit/properties_view_spec_spec.rb
davber_couch_potato-0.3.0 spec/unit/properties_view_spec_spec.rb
couch_potato-0.3.0 spec/unit/properties_view_spec_spec.rb