|
67 | 67 | }).to raise_error("You must specify a draft path.") |
68 | 68 | end |
69 | 69 |
|
70 | | - it "errors if no file exists at given path" do |
| 70 | + it "outputs a warning and returns if no file exists at given path" do |
71 | 71 | weird_path = "_drafts/i-do-not-exist.markdown" |
72 | | - expect(lambda { |
73 | | - capture_stdout { described_class.process [weird_path] } |
74 | | - }).to raise_error("There was no draft found at '_drafts/i-do-not-exist.markdown'.") |
| 72 | + output = capture_stdout { described_class.process [weird_path] } |
| 73 | + expect(output).to include("There was no draft found at '_drafts/i-do-not-exist.markdown'.") |
| 74 | + expect(draft_path).to exist |
| 75 | + expect(post_path).to_not exist |
75 | 76 | end |
76 | 77 |
|
77 | 78 | context "when the post already exists" do |
|
81 | 82 | FileUtils.touch post_path |
82 | 83 | end |
83 | 84 |
|
84 | | - it "raises an error" do |
85 | | - expect(lambda { |
86 | | - capture_stdout { described_class.process(args) } |
87 | | - }).to raise_error("A post already exists at _posts/#{post_filename}") |
| 85 | + it "outputs a warning and returns" do |
| 86 | + output = capture_stdout { described_class.process(args) } |
| 87 | + expect(output).to include("A post already exists at _posts/#{post_filename}") |
88 | 88 | expect(draft_path).to exist |
89 | 89 | expect(post_path).to exist |
90 | 90 | end |
91 | 91 |
|
92 | 92 | it "overwrites if --force is given" do |
93 | | - expect(lambda { |
94 | | - capture_stdout { described_class.process(args, "force" => true) } |
95 | | - }).not_to raise_error |
| 93 | + output = capture_stdout { described_class.process(args, "force" => true) } |
| 94 | + expect(output).to_not include("A post already exists at _posts/#{post_filename}") |
96 | 95 | expect(draft_path).not_to exist |
97 | 96 | expect(post_path).to exist |
98 | 97 | end |
|
0 commit comments