Sha256: 0e1e6f2f51a9e7c86fbfd5daf4e48b2f2df70323a7ef7d1ae9138ae0f025c1bb
Contents?: true
Size: 904 Bytes
Versions: 1
Compression:
Stored size: 904 Bytes
Contents
require 'spec_helper' describe Comma, 'generating CSV from an ActiveRecord object' do class Person < ActiveRecord::Base scope :teenagers, lambda { where(:age => 13..19) } comma do name age end end before(:all) do #Setup AR model in memory ActiveRecord::Base.connection.create_table :people, :force => true do |table| table.column :name, :string table.column :age, :integer end Person.reset_column_information 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
comma-3.0.6 | spec/comma/rails/active_record_spec.rb |