Sha256: 6ad41050956bd006c3fa527e324e4329e868eb7f959ddf1b38469d58824abc04
Contents?: true
Size: 1.29 KB
Versions: 1
Compression:
Stored size: 1.29 KB
Contents
# -*- coding: utf-8 -*- require 'test_helper' class CsvRails::ArrayTest < ActiveSupport::TestCase setup do I18n.locale = :ja @csv_rails_scope = {name: "名前", age: "年齢"} @human_scope = {sex: '性別'} I18n.backend.store_translations(:ja, :csv_rails => @csv_rails_scope, :human => @human_scope) end teardown do I18n.locale = :en end test ".to_csv with header option" do header = ['foo', 'bar'] assert_equal header.join(','), [].to_csv(:header => header).chomp end test ".to_csv using I18n csv_rails scope and accept i18n_scope option" do translations = @csv_rails_scope.merge(@human_scope) fields = translations.keys assert_equal translations.values.join(','), [].to_csv(:fields => fields, :i18n_scope => :human).chomp end test ".to_csv not stored i18n" do fields = [:sum, :max] assert_equal fields.join(','), [].to_csv(:fields => fields).chomp end test ".to_csv accept encoding" do name = "名前" assert_equal name.encode('SJIS'), [].to_csv(:header => [name], :encoding => 'SJIS').chomp end test ".to_csv only it includes ActiveRecord instance" do assert_nothing_raised do [User.create(:name => 'satomicchy')].to_csv end end test ".to_csv using empty array" do assert_equal "", [].to_csv end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
csv_rails-0.5.2 | test/csv_rails/array_test.rb |