Skip to content

Commit

Permalink
add builder check to runner
Browse files Browse the repository at this point in the history
  • Loading branch information
onigra committed Dec 19, 2015
1 parent f5d4770 commit 2a52a14
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
7 changes: 7 additions & 0 deletions lib/planaria/generator/builder/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ def initialize(name)
end

def run
check
execute
message
rescue ::Planaria::BuildProjectNotFound
puts "#{@name} not found"
end

private

def check
Checker.new(@name).run
end

def execute
Executer.new(@name).run
end
Expand Down
24 changes: 16 additions & 8 deletions spec/planaria/generator/builder/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@

RSpec.describe Planaria::Generator::Builder::Runner do
let(:project) { "project" }
before { Planaria::Generator::Initializer::Executer.new(project).run }
after { FileUtils.rm_rf "#{APP_ROOT}/#{project}" }

describe "#run" do
let(:message) do
<<-EOS
context "build project exist" do
before { Planaria::Generator::Initializer::Executer.new(project).run }
after { FileUtils.rm_rf "#{APP_ROOT}/#{project}" }

let(:message) do
<<-EOS
Generate #{project}/base.html
EOS
EOS
end

it do
expect { described_class.new(project).run }.to output(message).to_stdout
expect(File.exist?("#{APP_ROOT}/#{project}/base.html")).to be_truthy
end
end

it do
expect { described_class.new(project).run }.to output(message).to_stdout
expect(File.exist?("#{APP_ROOT}/#{project}/base.html")).to be_truthy
context "build project not exist" do
let(:message) { "#{project} not found\n" }
it { expect { described_class.new(project).run }.to output(message).to_stdout }
end
end
end

0 comments on commit 2a52a14

Please sign in to comment.