Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace puts calls with Jekyll.logger.info #69

Merged
merged 1 commit into from May 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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