Sha256: b2bc769535e18819c437c8070d1708eab24836cb105bb7fc0b8379f8e94eee16
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
require 'spec_helper' if defined? DataMapper describe Comma, 'generating CSV from an DataMapper object' do # rubocop:disable Metrics/BlockLength class Person include DataMapper::Resource property :id, Serial property :name, String property :age, Integer def self.teenagers all(:age.gte => 13) & all(:age.lte => 19) end comma do name age end end DataMapper.finalize before(:all) do DataMapper.setup(:default, 'sqlite::memory:') DataMapper.auto_migrate! end after(:all) do end describe "case" do before do @person = Person.new(:age => 18, :name => 'Junior') @person.save end it 'should extend 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comma-4.2.0 | spec/comma/rails/data_mapper_collection_spec.rb |