Skip to content

Commit

Permalink
Replace puts calls with Jekyll.logger.info (#69)
Browse files Browse the repository at this point in the history
Merge pull request 69
  • Loading branch information
ashmaroli authored and jekyllbot committed May 1, 2018
1 parent 63ee1c0 commit 08eb88e
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/jekyll-compose/file_creator.rb
Expand Up @@ -37,7 +37,7 @@ def write_file
f.puts(file.content)
end

puts "New #{file.resource_type} created at #{file_path}."
Jekyll.logger.info "New #{file.resource_type} created at #{file_path}."
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll-compose/file_mover.rb
Expand Up @@ -40,7 +40,7 @@ def validate_should_write!

def move_file
FileUtils.mv(from, to)
puts "#{resource_type_from.capitalize} #{from} was moved to #{to}"
Jekyll.logger.info "#{resource_type_from.capitalize} #{from} was moved to #{to}"
end

private
Expand Down
2 changes: 1 addition & 1 deletion spec/draft_spec.rb
Expand Up @@ -27,7 +27,7 @@

it "writes a helpful success message" do
output = capture_stdout { described_class.process(args) }
expect(output).to eql("New draft created at _drafts/a-test-post.md.\n")
expect(output).to include("New draft created at _drafts/a-test-post.md.")
end

it "errors with no arguments" do
Expand Down
2 changes: 1 addition & 1 deletion spec/page_spec.rb
Expand Up @@ -35,7 +35,7 @@

it "should write a helpful message when successful" do
output = capture_stdout { described_class.process(args) }
expect(output).to eql("New page created at #{filename}.\n")
expect(output).to include("New page created at #{filename}.")
end

it "errors with no arguments" do
Expand Down
2 changes: 1 addition & 1 deletion spec/post_spec.rb
Expand Up @@ -51,7 +51,7 @@

it "should write a helpful message when successful" do
output = capture_stdout { described_class.process(args) }
expect(output).to eql("New post created at _posts/#{filename}.\n")
expect(output).to include("New post created at _posts/#{filename}.")
end

it "errors with no arguments" do
Expand Down
2 changes: 1 addition & 1 deletion spec/publish_spec.rb
Expand Up @@ -46,7 +46,7 @@
it "writes a helpful message on success" do
expect(draft_path).to exist
output = capture_stdout { described_class.process(args) }
expect(output).to eql("Draft _drafts/#{draft_to_publish} was moved to _posts/#{post_filename}\n")
expect(output).to include("Draft _drafts/#{draft_to_publish} was moved to _posts/#{post_filename}")
end

it "publishes a draft on the specified date" do
Expand Down
13 changes: 7 additions & 6 deletions spec/spec_helper.rb
Expand Up @@ -49,13 +49,14 @@ def fixture_site
))
end

def capture_stdout
$old_stdout = $stdout
$stdout = StringIO.new
def capture_stdout(level = :debug)
buffer = StringIO.new
Jekyll.logger = Logger.new(buffer)
Jekyll.logger.log_level = level
yield
$stdout.rewind
return $stdout.string
buffer.rewind
buffer.string.to_s
ensure
$stdout = $old_stdout
Jekyll.logger = Logger.new(StringIO.new, :error)
end
end
2 changes: 1 addition & 1 deletion spec/unpublish_spec.rb
Expand Up @@ -37,7 +37,7 @@
it "writes a helpful message on success" do
expect(post_path).to exist
output = capture_stdout { described_class.process(args) }
expect(output).to eql("Post _posts/#{post_filename} was moved to _drafts/#{post_name}\n")
expect(output).to include("Post _posts/#{post_filename} was moved to _drafts/#{post_name}")
end

it "creates the drafts folder if necessary" do
Expand Down

0 comments on commit 08eb88e

Please sign in to comment.