Sha256: 82ebc4200b69d58bdd79483c5292d004b5dbc25d4a6b2ee5748203c99bc88326
Contents?: true
Size: 862 Bytes
Versions: 9
Compression:
Stored size: 862 Bytes
Contents
# -*- coding: utf-8 -*- require 'spec_helper' if defined? Mongoid describe Comma, 'generating CSV from an Mongoid object' do class Person include Mongoid::Document field :name, :type => String field :age, :type => Integer scope :teenagers, between(:age => 13..19) comma do name age end end after(:all) do Mongoid.purge! end describe "case" do before do @person = Person.new(:age => 18, :name => 'Junior') @person.save end it 'should extend ActiveRecord::NamedScope::Scope to add a #to_comma method which will return CSV content for objects within the scope' do Person.teenagers.to_comma.should == "Name,Age\nJunior,18\n" end it 'should find in batches' do Person.teenagers.to_comma end end end end
Version data entries
9 entries across 9 versions & 1 rubygems