Skip to content

Commit

Permalink
本体からテスト用の処理を削除し、テストに処理を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
koi-chan committed Jul 24, 2019
1 parent 80d9885 commit 59523d0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 4 additions & 5 deletions lib/rgrb/plugin_base/generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,25 @@ module Generator
# ロガー
# @return [Lumberjack::Logger]
attr_accessor :logger

# インスタンスの初期化
#
# 設定関連のメソッドが動作するように変数を設定する。
def initialize
class_name_tree = self.class.name.split('::')
@plugin_name_underscore = class_name_tree[-2].underscore
@logger = Lumberjack::Logger.new($stdout, progname: self.class.to_s)
end

# RGRB のルートパスを設定する
# @param [String] root_path RGRB のルートパス
# @return [String] RGRB のルートパス
def root_path=(root_path)
@root_path = root_path
@data_path = "#{root_path}/data/#{@plugin_name_underscore}"

root_path
end

# 設定データを解釈してプラグインの設定を行う
#
# 標準では何も行わない。
Expand Down
2 changes: 2 additions & 0 deletions spec/rgrb/plugin/random_generator/generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

require_relative '../../../spec_helper'
require 'date'
require 'lumberjack'
require 'rgrb/plugin/random_generator/generator'

describe RGRB::Plugin::RandomGenerator::Generator do
let(:generator) do
obj = described_class.new
obj.send(:load_data, "#{__dir__}/data/*.yaml")
obj.send(:logger=, Lumberjack::Logger.new($stdout, progname: self.class.to_s))

obj
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
}

let(:mail_generator) {
described_class.new.configure(logger: null_logger)
obj = described_class.new
obj.send(:logger=, Lumberjack::Logger.new($stdout, progname: self.class.to_s))

obj
}

describe '#initialize' do
Expand Down

0 comments on commit 59523d0

Please sign in to comment.