|
4 | 4 | let(:drafts_dir) { Pathname.new source_dir("_drafts") } |
5 | 5 | let(:posts_dir) { Pathname.new source_dir("_posts") } |
6 | 6 | let(:draft_to_publish) { "a-test-post.md" } |
| 7 | + let(:timestamp) { Time.now.strftime(Jekyll::Compose::DEFAULT_TIMESTAMP_FORMAT) } |
7 | 8 | let(:datestamp) { Time.now.strftime(Jekyll::Compose::DEFAULT_DATESTAMP_FORMAT) } |
8 | 9 | let(:post_filename) { "#{datestamp}-#{draft_to_publish}" } |
9 | 10 | let(:args) { ["_drafts/#{draft_to_publish}"] } |
|
19 | 20 | before(:each) do |
20 | 21 | FileUtils.mkdir_p drafts_dir unless File.directory? drafts_dir |
21 | 22 | FileUtils.mkdir_p posts_dir unless File.directory? posts_dir |
22 | | - FileUtils.touch draft_path |
| 23 | + File.write(draft_path, "---\nlayout: post\n---\n") |
23 | 24 | end |
24 | 25 |
|
25 | 26 | after(:each) do |
|
34 | 35 | expect(draft_path).to exist |
35 | 36 | capture_stdout { described_class.process(args) } |
36 | 37 | expect(post_path).to exist |
| 38 | + expect(draft_path).not_to exist |
| 39 | + expect(File.read(post_path)).to include("date: #{timestamp}") |
37 | 40 | end |
38 | 41 |
|
39 | 42 | it "publishes with a specified date" do |
40 | 43 | path = posts_dir.join "2012-03-04-#{draft_to_publish}" |
41 | 44 | expect(path).not_to exist |
42 | 45 | capture_stdout { described_class.process(args, "date"=>"2012-3-4") } |
43 | 46 | expect(path).to exist |
| 47 | + expect(draft_path).not_to exist |
| 48 | + expect(File.read(path)).to include("date: 2012-03-04") |
44 | 49 | end |
45 | 50 |
|
46 | 51 | it "writes a helpful message on success" do |
|
53 | 58 | path = posts_dir.join "2012-03-04-a-test-post.md" |
54 | 59 | capture_stdout { described_class.process(args, "date" => "2012-3-4") } |
55 | 60 | expect(path).to exist |
| 61 | + expect(draft_path).not_to exist |
| 62 | + expect(File.read(path)).to include("date: 2012-03-04") |
56 | 63 | end |
57 | 64 |
|
58 | 65 | it "creates the posts folder if necessary" do |
|
94 | 101 | expect(output).to_not include("A post already exists at _posts/#{post_filename}") |
95 | 102 | expect(draft_path).not_to exist |
96 | 103 | expect(post_path).to exist |
| 104 | + expect(File.read(post_path)).to include("date: #{timestamp}") |
97 | 105 | end |
98 | 106 | end |
99 | 107 |
|
|
0 commit comments