+++ /dev/null
--# encoding: UTF-8\r
--# This file is auto-generated from the current state of the database. Instead\r
--# of editing this file, please use the migrations feature of Active Record to\r
--# incrementally modify your database, and then regenerate this schema definition.\r
--#\r
--# Note that this schema.rb definition is the authoritative source for your\r
--# database schema. If you need to create the application database on another\r
--# system, you should be using db:schema:load, not running all the migrations\r
--# from scratch. The latter is a flawed and unsustainable approach (the more migrations\r
--# you'll amass, the slower it'll run and the greater likelihood for issues).\r
--#\r
--# It's strongly recommended to check this file into your version control system.\r
--\r
- ActiveRecord::Schema.define(:version => 20120617061753) do\r
-ActiveRecord::Schema.define(:version => 20120619100752) do\r
--\r
-- create_table "admins", :force => true do |t|\r
-- t.string "email", :default => "", :null => false\r
-- t.string "encrypted_password", :limit => 128, :default => "", :null => false\r
-- t.string "reset_password_token"\r
-- t.datetime "reset_password_sent_at"\r
-- t.datetime "remember_created_at"\r
-- t.integer "sign_in_count", :default => 0\r
-- t.datetime "current_sign_in_at"\r
-- t.datetime "last_sign_in_at"\r
-- t.string "current_sign_in_ip"\r
-- t.string "last_sign_in_ip"\r
-- t.string "confirmation_token"\r
-- t.datetime "confirmed_at"\r
-- t.datetime "confirmation_sent_at"\r
-- t.string "authentication_token"\r
-- t.integer "approve", :default => 0, :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- add_index "admins", ["authentication_token"], :name => "index_admins_on_authentication_token", :unique => true\r
-- add_index "admins", ["confirmation_token"], :name => "index_admins_on_confirmation_token", :unique => true\r
-- add_index "admins", ["email"], :name => "index_admins_on_email", :unique => true\r
-- add_index "admins", ["reset_password_token"], :name => "index_admins_on_reset_password_token", :unique => true\r
--\r
-- create_table "artists", :force => true do |t|\r
-- t.string "email"\r
-- t.string "name"\r
-- t.string "homepage_url"\r
-- t.string "api_url"\r
-- t.integer "default_license_id", :default => 0, :null => false\r
-- t.datetime "crowled_at"\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- t.integer "author_id"\r
-- end\r
--\r
-- create_table "authors", :force => true do |t|\r
-- t.string "name"\r
-- t.integer "user_id", :default => 0, :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- add_index "authors", ["user_id"], :name => "index_authors_on_user_id", :unique => true\r
--\r
-- create_table "balloons", :force => true do |t|\r
-- t.integer "speech_balloon_id", :null => false\r
-- t.integer "system_picture_id", :null => false\r
-- t.integer "x", :null => false\r
-- t.integer "y", :null => false\r
-- t.integer "width", :null => false\r
-- t.integer "height", :null => false\r
-- t.string "caption"\r
-- t.string "settings"\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- add_index "balloons", ["speech_balloon_id"], :name => "index_balloons_on_speech_balloon_id"\r
--\r
-- create_table "comics", :force => true do |t|\r
-- t.string "title", :limit => 100, :null => false\r
-- t.integer "width", :null => false\r
-- t.integer "height", :null => false\r
-- t.integer "visible", :default => 0, :null => false\r
-- t.integer "editable", :default => 0, :null => false\r
-- t.integer "author_id", :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- add_index "comics", ["author_id"], :name => "index_comics_on_author_id"\r
--\r
-- create_table "common_licenses", :force => true do |t|\r
-- t.integer "license_id", :null => false\r
-- t.string "name", :null => false\r
-- t.string "url", :null => false\r
-- t.integer "cc_by", :default => 0, :null => false\r
-- t.integer "cc_sa", :default => 0, :null => false\r
-- t.integer "cc_nd", :default => 0, :null => false\r
-- t.integer "cc_nc", :default => 0, :null => false\r
-- t.integer "no_resize", :default => 0, :null => false\r
-- t.integer "no_flip", :default => 0, :null => false\r
-- t.integer "no_convert", :default => 0, :null => false\r
-- t.integer "keep_aspect_ratio", :default => 0, :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
- create_table "license_groups", :force => true do |t|\r
- t.string "name", :limit => 50, :null => false\r
- t.string "classname", :limit => 50, :null => false\r
- t.string "caption", :limit => 30, :null => false\r
- t.string "url", :null => false\r
- create_table "imports", :force => true do |t|\r
- t.integer "a"\r
- t.string "b", :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- create_table "licenses", :force => true do |t|\r
- t.integer "license_group_id", :default => 0, :null => false\r
- t.string "name", :limit => 50, :default => "Default", :null => false\r
- t.string "classname", :limit => 50, :default => "Default", :null => false\r
- t.string "caption", :limit => 30, :default => "no name", :null => false\r
- t.string "url", :null => false\r
- t.string "name", :null => false\r
- t.string "url", :null => false\r
- t.integer "cc_by", :default => 0, :null => false\r
- t.integer "cc_sa", :default => 0, :null => false\r
- t.integer "cc_nd", :default => 0, :null => false\r
- t.integer "cc_nc", :default => 0, :null => false\r
- t.integer "no_resize", :default => 0, :null => false\r
- t.integer "no_flip", :default => 0, :null => false\r
- t.integer "no_convert", :default => 0, :null => false\r
- t.integer "keep_aspect_ratio", :default => 0, :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
- add_index "licenses", ["name"], :name => "index_licenses_on_name", :unique => true\r
- add_index "licenses", ["url"], :name => "index_licenses_on_url", :unique => true\r
--\r
-- create_table "original_licenses", :force => true do |t|\r
-- t.integer "license_id", :null => false\r
-- t.string "name", :null => false\r
-- t.string "url", :null => false\r
-- t.integer "cc_by", :default => 0, :null => false\r
-- t.integer "cc_sa", :default => 0, :null => false\r
-- t.integer "cc_nd", :default => 0, :null => false\r
-- t.integer "cc_nc", :default => 0, :null => false\r
-- t.integer "no_resize", :default => 0, :null => false\r
-- t.integer "no_flip", :default => 0, :null => false\r
-- t.integer "no_convert", :default => 0, :null => false\r
-- t.integer "keep_aspect_ratio", :default => 0, :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- create_table "original_pictures", :force => true do |t|\r
-- t.string "ext", :null => false\r
-- t.integer "width", :null => false\r
-- t.integer "height", :null => false\r
-- t.integer "filesize", :null => false\r
-- t.integer "artist_id", :default => 0, :null => false\r
-- t.integer "license_id", :default => 0, :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- add_index "original_pictures", ["artist_id"], :name => "index_original_pictures_on_artist_id"\r
--\r
-- create_table "panel_pictures", :force => true do |t|\r
-- t.integer "panel_id", :null => false\r
-- t.integer "resource_picture_id", :null => false\r
-- t.string "link", :limit => 200\r
-- t.integer "x", :null => false\r
-- t.integer "y", :null => false\r
-- t.integer "z", :null => false\r
-- t.integer "t", :null => false\r
-- t.integer "width", :null => false\r
-- t.integer "height", :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- add_index "panel_pictures", ["panel_id", "t"], :name => "panel_pictures_idt", :unique => true\r
--\r
-- create_table "panels", :force => true do |t|\r
-- t.integer "comic_id"\r
-- t.integer "width", :default => 200, :null => false\r
-- t.integer "height", :default => 80, :null => false\r
-- t.integer "border", :default => 1, :null => false\r
-- t.integer "x"\r
-- t.integer "y"\r
-- t.integer "z"\r
-- t.integer "t", :null => false\r
-- t.integer "author_id", :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- add_index "panels", ["author_id"], :name => "index_panels_on_author_id"\r
- \r
- create_table "resource_picture_licenses", :force => true do |t|\r
- t.integer "resource_picture_id", :null => false\r
- t.integer "license_id", :null => false\r
- t.string "artist_name", :null => false\r
- t.string "credit"\r
- t.string "settings"\r
- t.datetime "created_at"\r
- t.datetime "updated_at"\r
- end\r
--\r
-- create_table "resource_pictures", :force => true do |t|\r
-- t.string "ext", :null => false\r
-- t.integer "width", :null => false\r
-- t.integer "height", :null => false\r
-- t.integer "filesize", :null => false\r
-- t.integer "artist_id", :default => 0, :null => false\r
-- t.integer "license_id", :default => 0, :null => false\r
-- t.integer "original_picture_id", :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- create_table "speech_balloon_templates", :force => true do |t|\r
-- t.string "name", :limit => 50, :null => false\r
-- t.string "classname", :limit => 50, :null => false\r
-- t.string "caption", :limit => 30, :null => false\r
-- t.integer "t", :default => 0, :null => false\r
-- t.string "settings", :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- add_index "speech_balloon_templates", ["name"], :name => "speech_balloon_templates_name", :unique => true\r
-- add_index "speech_balloon_templates", ["t"], :name => "speech_balloon_templates_t", :unique => true\r
--\r
-- create_table "speech_balloons", :force => true do |t|\r
-- t.integer "panel_id", :null => false\r
-- t.integer "speech_balloon_template_id", :null => false\r
-- t.string "classname", :limit => 50, :null => false\r
-- t.integer "z", :null => false\r
-- t.integer "t", :null => false\r
-- t.string "settings"\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- add_index "speech_balloons", ["panel_id"], :name => "index_speech_balloons_on_panel_id"\r
--\r
-- create_table "speeches", :force => true do |t|\r
-- t.integer "speech_balloon_id", :null => false\r
-- t.string "content"\r
-- t.integer "x", :null => false\r
-- t.integer "y", :null => false\r
-- t.integer "width", :null => false\r
-- t.integer "height", :null => false\r
-- t.string "settings"\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- add_index "speeches", ["speech_balloon_id"], :name => "index_speeches_on_speech_balloon_id"\r
--\r
-- create_table "system_pictures", :force => true do |t|\r
-- t.string "ext", :null => false\r
-- t.integer "width", :null => false\r
-- t.integer "height", :null => false\r
-- t.integer "filesize", :null => false\r
-- t.string "md5", :limit => 32, :null => false\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- create_table "users", :force => true do |t|\r
-- t.string "email", :default => "", :null => false\r
-- t.string "encrypted_password", :limit => 128, :default => "", :null => false\r
-- t.string "reset_password_token"\r
-- t.datetime "reset_password_sent_at"\r
-- t.datetime "remember_created_at"\r
-- t.integer "sign_in_count", :default => 0\r
-- t.datetime "current_sign_in_at"\r
-- t.datetime "last_sign_in_at"\r
-- t.string "current_sign_in_ip"\r
-- t.string "last_sign_in_ip"\r
-- t.string "authentication_token"\r
-- t.string "confirmation_token"\r
-- t.datetime "confirmed_at"\r
-- t.datetime "confirmation_sent_at"\r
-- t.datetime "created_at"\r
-- t.datetime "updated_at"\r
-- end\r
--\r
-- add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true\r
-- add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true\r
-- add_index "users", ["email"], :name => "index_users_on_email", :unique => true\r
-- add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true\r
--\r
--end\r
--- /dev/null
+# -*- encoding: utf-8 -*-
+#ライセンスグループ
+require 'spec_helper'
+
+describe LicenseGroup do
+ before do
+ #テストデータを用意してね
+ @f = Rails.root + 'spec/json/license_group.json'
+ @t = File.open(@f, 'r').read
+ @j = JSON.parse @t
+ end
+ describe '検証に於いて' do
+ before do
+ end
+
+ it 'オーソドックスなデータなら通る' do
+ @lg = Factory.build :license_group
+ @lg.should be_valid
+ end
+
+ context 'nameを検証するとき' do
+ before do
+ @lg = Factory.build :license_group
+ end
+ it 'テストデータの確認' do
+ @lg.name = 'a'*50
+ @lg.should be_valid
+ end
+ it 'nullなら失敗する' do
+ @lg.name = ''
+ @lg.should_not be_valid
+ end
+ it '51文字以上なら失敗する' do
+ @lg.name = 'a'*51
+ @lg.should_not be_valid
+ end
+ it '重複していたら失敗する' do
+ l = Factory :license_group
+ @lg.should_not be_valid
+ end
+ end
+ context 'classnameを検証するとき' do
+ before do
+ @lg = Factory.build :license_group
+ end
+ it 'テストデータの確認' do
+ @lg.classname = 'a'*50
+ @lg.should be_valid
+ end
+ it 'nullなら失敗する' do
+ @lg.classname = ''
+ @lg.should_not be_valid
+ end
+ it '51文字以上なら失敗する' do
+ @lg.classname = 'a'*51
+ @lg.should_not be_valid
+ end
+ end
+ context 'captionを検証するとき' do
+ before do
+ @lg = Factory.build :license_group
+ end
+ it 'テストデータの確認' do
+ @lg.caption = 'a'*30
+ @lg.should be_valid
+ end
+ it 'nullなら失敗する' do
+ @lg.caption = ''
+ @lg.should_not be_valid
+ end
+ it '51文字以上なら失敗する' do
+ @lg.caption = 'a'*51
+ @lg.should_not be_valid
+ end
+ end
+ context 'urlを検証するとき' do
+ before do
+ @lg = Factory.build :license_group
+ end
+ it 'テストデータの確認' do
+ @lg.url = 'http://test.com/'
+ @lg.should be_valid
+ end
+ it 'nullなら失敗する' do
+ @lg.url = ''
+ @lg.should_not be_valid
+ end
+ it '201文字以上なら失敗する' do
+ @lg.url = 'a'*201
+ @lg.should_not be_valid
+ end
+ it 'url形式でないなら失敗する' do
+ @lg.url = 'aaaaaaa'
+ @lg.should_not be_valid
+ end
+ end
+ end
+
++ describe 'インポートに於いて' do
++ before do
++ end
++ context 'つつがなく終わるとき' do
++ it 'テキストインポートを依頼する' do
++ CommonLicense.should_receive(:parse).with(any_args).exactly(1)
++ CommonLicense.stub(:parse).with(any_args).and_return(@j)
++ CommonLicense.import(@t)
++ end
++ it 'ライセンスグループ更新を一回依頼する' do
++ CommonLicense.stub(:store).with(any_args).and_return(CommonLicense.new)
++ CommonLicense.any_instance.stub(:valid?).with(any_args).and_return(true)
++ CommonLicense.should_receive(:store).with(any_args).exactly(1)
++ CommonLicense.import(@t)
++ end
++ it 'ライセンスグループが追加される' do
++ lambda {
++ CommonLicense.import(@t)
++ }.should change CommonLicense, :count
++ end
++ it '[]を返す' do
++ CommonLicense.import(@t).should eq []
++ end
++ end
++ context '複数データがつつがなく終わるとき' do
++ it 'ライセンスグループ更新を二回依頼する' do
++ CommonLicense.stub(:store).with(any_args).and_return(CommonLicense.new)
++ CommonLicense.any_instance.stub(:valid?).with(any_args).and_return(true)
++ CommonLicense.should_receive(:store).with(any_args).exactly(2)
++ CommonLicense.import(@ts)
++ end
++ it 'ライセンスグループが二個追加される' do
++ lambda {
++ CommonLicense.import(@ts)
++ }.should change(CommonLicense, :count).by 2
++ end
++ it '[]を返す' do
++ CommonLicense.import(@ts).should eq []
++ end
++ end
++ context 'コモンライセンス作成に失敗したとき' do
++ before do
++ CommonLicense.any_instance.stub(:save).with(any_args).and_return(false)
++ CommonLicense.any_instance.stub(:valid?).with(any_args).and_return(false)
++ end
++ it 'コモンライセンスの数に変化がない' do
++ lambda {
++ CommonLicense.import(@t)
++ }.should_not change CommonLicense, :count
++ end
++ it '配列を返す' do
++ r = CommonLicense.import(@t)
++ r.is_a?(Array).should be_true
++ end
++ it '配列の中身は一件' do
++ r = CommonLicense.import(@t)
++ r.should have(1).items
++ end
++ it 'コモンライセンスオブジェクトが入っている' do
++ r = CommonLicense.import(@t)
++ r.first.is_a?(CommonLicense).should be_true
++ end
++ end
++ context '複数のコモンライセンス作成に失敗したとき' do
++ #三件中、二件の失敗、一件を成功させ、成功データは戻り値に含まないことを確認する
++ it 'コモンライセンスの数に変化がない' do
++ lambda {
++ CommonLicense.import(@tes)
++ }.should_not change CommonLicense, :count
++ end
++ it '途中で保存に失敗しても全件更新依頼する' do
++ CommonLicense.stub(:store).with(any_args).and_return(CommonLicense.new)
++ CommonLicense.should_receive(:store).with(any_args).exactly(3)
++ CommonLicense.import(@tes)
++ end
++ it '配列を返す' do
++ r = CommonLicense.import(@tes)
++ r.is_a?(Array).should be_true
++ end
++ it '配列の中身は2件' do
++ r = CommonLicense.import(@tes)
++ r.should have(2).items
++ end
++ it '配列の中身は失敗したコモンライセンスオブジェクトが入っている' do
++ r = CommonLicense.import(@tes)
++ r[0].is_a?(CommonLicense).should be_true
++ r[0]["name"].should eq 'fail1'
++ r[1].is_a?(CommonLicense).should be_true
++ r[1]["name"].should eq 'fail2'
++ end
++ end
++ end
++
+end
+++ /dev/null
--# -*- encoding: utf-8 -*-
--require 'spec_helper'
--require File.expand_path(File.dirname(__FILE__) + '/import')\r
--#インポート処理
--
--describe Import do
-- before do
-- @t = '{"1": {"a": 1, "b": "Z"}}'
-- @j = JSON.parse @t
-- @ts = '{"1": {"a": 1, "b": "Z"}, "2": {"a": 2, "b": "Z"}}'
-- @js = JSON.parse @ts
-- @tes = '{"1": {"a": 0}, "2": {"a": 0}, "3": {"a": 2, "b": "Z"}}'
-- @jes = JSON.parse @tes
-- @f = File.expand_path(File.dirname(__FILE__) + '/import.json')
-- end
--
-- describe '繰り返し処理に於いて' do
-- before do
-- end
-- context '単体データを渡されたとき' do
-- it '一回処理' do
-- r = []
-- Import.each_import @j do |n, i|
-- r << i
-- end
-- r.size.should eq 1
-- end
-- it '一回処理' do
-- r = []
-- Import.each_import @j do |n, i|
-- r << n
-- end
-- r.first.should eq "1"
-- end
-- it '一回処理' do
-- r = []
-- Import.each_import @j do |n, i|
-- r << i
-- end
-- r.first["a"].should eq 1
-- r.first["b"].should eq "Z"
-- end
-- end
-- context '複数を渡されたとき' do
-- it '二回処理' do
-- r = []
-- Import.each_import @js do |n, i|
-- r << i
-- end
-- r.size.should eq 2
-- end
-- end
-- end
--
-- describe 'テキスト取り込みに於いて' do
-- #成功でTrue、パース失敗でFalse、失敗は保存エラーのモデルを配列で返す
-- before do
-- end
-- context 'つつがなく終わるとき' do
-- it 'Json解析を依頼する' do
-- JSON.should_receive(:parse_no_except).with(any_args).exactly(1)
-- JSON.stub(:parse_no_except).with(any_args).and_return(@j)
- Import.import(@t) {|name, attr| Import.new(attr)}
- Import.import_text(@t) {|name, attr| Import.new(attr)}
-- end
-- it '更新を一回依頼する' do
-- JSON.stub(:parse_no_except).with(any_args).and_return(@j)
-- Import.any_instance.stub(:valid?).with(any_args).and_return(true)
-- #newでスタブを作るとインスタンス生成ができないので、テスト用スタブで
-- Import.should_receive(:etest).with(any_args).exactly(1)
- Import.import(@t) {|name, attr| Import.etest ; Import.new(attr) }
- Import.import_text(@t) {|name, attr| Import.etest ; Import.new(attr) }
-- end
-- it '[]を返す' do
-- JSON.stub(:parse_no_except).with(any_args).and_return(@j)
-- Import.any_instance.stub(:valid?).with(any_args).and_return(true)
- Import.import(@t) {|name, attr| Import.new(attr)}.should eq []
- Import.import_text(@t) {|name, attr| Import.new(attr)}.should eq []
-- end
-- end
-- context '複数データがつつがなく終わるとき' do
-- it 'ライセンス更新を二回依頼する' do
-- JSON.stub(:parse_no_except).with(any_args).and_return(@js)
-- Import.any_instance.stub(:valid?).with(any_args).and_return(true)
-- #newでスタブを作るとインスタンス生成ができないので、テスト用スタブで
-- Import.should_receive(:etest).with(any_args).exactly(2)
- Import.import(@ts) {|name, attr| Import.etest ; Import.new(attr)}.should eq []
- Import.import_text(@ts) {|name, attr| Import.etest ; Import.new(attr)}.should eq []
-- end
-- it '[]を返す' do
- Import.import(@ts) {|name, attr| Import.new(attr)}.should eq []
- Import.import_text(@ts) {|name, attr| Import.new(attr)}.should eq []
-- end
-- end
-- #例外ケース
-- context 'Json解析に失敗したとき' do
-- before do
-- JSON.stub(:parse_no_except).with(any_args).and_return(false)
-- end
-- it 'Falseを返す' do
- Import.import(@t){|name, attr| Import.new(attr)}.should be_false
- Import.import_text(@t){|name, attr| Import.new(attr)}.should be_false
-- end
-- end
-- context '作成に失敗したとき' do
-- before do
-- Import.any_instance.stub(:valid?).with(any_args).and_return(false)
-- end
-- it '配列を返す' do
- r = Import.import(@t){|name, attr| Import.new(attr)}
- r = Import.import_text(@t){|name, attr| Import.new(attr)}
-- r.is_a?(Array).should be_true
-- end
-- it '配列の中身は一件' do
- r = Import.import(@t){|name, attr| Import.new(attr)}
- r = Import.import_text(@t){|name, attr| Import.new(attr)}
-- r.should have(1).items
-- end
-- it 'オブジェクトが入っている' do
- r = Import.import(@t){|name, attr| Import.new(attr)}
- r = Import.import_text(@t){|name, attr| Import.new(attr)}
-- r.first.is_a?(Import).should be_true
-- end
-- end
-- context '複数の作成に失敗したとき' do
-- #三件中、二件の失敗、一件を成功させ、成功データは戻り値に含まないことを確認する
-- it '途中で保存に失敗しても全件更新依頼する' do
- Import.import(@tes){|name, attr| Import.create(attr)}
- Import.import_text(@tes){|name, attr| Import.create(attr)}
-- end
-- it '配列を返す' do
- r = Import.import(@tes){|name, attr| Import.create(attr)}
- r = Import.import_text(@tes){|name, attr| Import.create(attr)}
-- r.is_a?(Array).should be_true
-- end
-- it '配列の中身は2件' do
- r = Import.import(@tes){|name, attr| Import.create(attr)}
- r = Import.import_text(@tes){|name, attr| Import.create(attr)}
-- r.should have(2).items
-- end
-- it '配列の中身は失敗したオブジェクトが入っている' do
- r = Import.import(@tes){|name, attr| Import.create(attr)}
- r = Import.import_text(@tes){|name, attr| Import.create(attr)}
-- r[0].is_a?(Import).should be_true
-- r[0]["a"].should eq 0
-- r[1].is_a?(Import).should be_true
-- r[1]["a"].should eq 0
-- end
-- end
-- end
--
-- describe 'インポートエラーの表示に於いて' do
-- end
--
-- describe 'ファイル取り込みに於いて' do
-- before do
-- Import.stub(:import).with(any_args).and_return(true)
-- end
-- context 'つつがなく終わるとき' do
-- before do
-- Import.stub(:import).with(any_args).and_return(true)
-- end
-- it 'ファイルを開いてテキストを読む' do
-- File.should_receive(:open).with(@f, 'r').exactly(1)
- Import.import_file(@f)
- Import.import_file(@f){|name, attr| Import.new(attr) }
-- end
-- it 'テキスト取り込みを依頼する' do
- Import.should_receive(:import).with(any_args).exactly(1)
- Import.import_file(@f)
- Import.should_receive(:import_text).with(any_args).exactly(1)
- Import.import_file(@f){|name, attr| Import.new(attr) }
-- end
-- it 'ブロックがあるとき更新を一回依頼する' do
-- Import.any_instance.stub(:valid?).with(any_args).and_return(true)
-- #newでスタブを作るとインスタンス生成ができないので、テスト用スタブで
-- Import.should_receive(:etest).with(any_args).exactly(1)
-- Import.import_file(@f) {|name, attr| Import.etest ; Import.new(attr) }
-- end
-- #テキスト取り込み成功でTrueが返る
-- it 'Trueを返す' do
- Import.import_file(@f).should be_true
- Import.import_file(@f){|name, attr| Import.new(attr) }.should be_true
-- end
-- end
-- context 'ファイルが開けないとき' do
-- before do
-- File.stub(:open).with(any_args).and_raise('StandardError')
-- end
-- it 'ファイルエラーのメッセージを出力する' do
-- pending
-- end
-- it 'Falseを返す' do
- Import.import_file(@f).should be_false
- Import.import_file(@f){|name, attr| Import.new(attr) }.should be_false
-- end
-- end
-- #失敗したときは、失敗したライセンスが配列で返る
-- context 'テキスト取り込みが失敗したとき' do
-- before do
- Import.stub(:import).with(any_args).and_return(false)
- Import.stub(:import_text).with(any_args).and_return(false)
-- end
-- it '各コモンライセンスのエラーメッセージを出力する' do
-- pending
-- end
-- it 'Falseを返す' do
- Import.import_file(@f).should be_false
- Import.import_file(@f) {|name, attr| Import.new(attr) }.should be_false
-- end
-- end
-- end
--
--end
--