Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
toshimaru committed Oct 7, 2018
1 parent 5c4289d commit 8195ded
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/post_spec.rb
Expand Up @@ -8,6 +8,7 @@
let(:timestamp) { Time.now.strftime(Jekyll::Compose::DEFAULT_TIMESTAMP_FORMAT) }
let(:filename) { "#{datestamp}-a-test-post.md" }
let(:path) { posts_dir.join(filename) }
let(:jekyll_config) { YAML.load_file('../fixtures/_config.yml') }

before(:all) do
FileUtils.mkdir_p source_dir unless File.directory? source_dir
Expand Down Expand Up @@ -49,6 +50,13 @@
expect(File.read(path)).to match(%r!layout: other-layout!)
end

it 'creates a new page with the specified config' do
expect(Jekyll).to receive(:configuration).and_return(jekyll_config)
capture_stdout { described_class.process(args) }
expect(File.read(path)).to match(/description: my description/)
expect(File.read(path)).to match(/category: /)
end

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

0 comments on commit 8195ded

Please sign in to comment.