Skip to content

Commit

Permalink
Modify spec
Browse files Browse the repository at this point in the history
  • Loading branch information
toshimaru committed Oct 7, 2018
1 parent 37355c5 commit a653e4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
3 changes: 0 additions & 3 deletions spec/fixtures/_config.yml

This file was deleted.

20 changes: 11 additions & 9 deletions spec/post_spec.rb
Expand Up @@ -8,7 +8,6 @@
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 @@ -50,13 +49,6 @@
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 Expand Up @@ -121,15 +113,25 @@
expect(path).to exist
end

context "auto_open editor is set" do
context "configuration is set" do
let(:posts_dir) { Pathname.new source_dir("_posts") }
let(:config_data) do
%(
jekyll_compose:
auto_open: true
post_default_front_matter:
description: my description
category:
)
end

it "creates post with the specified config" do
capture_stdout { described_class.process(args) }
post = File.read(path)
expect(post).to match(%r!description: my description!)
expect(post).to match(%r!category: !)
end

context "env variable EDITOR is set up" do
before { ENV["EDITOR"] = "vim" }

Expand Down

0 comments on commit a653e4a

Please sign in to comment.