mr_poole 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +12 -0
- data/README.md +42 -14
- data/Rakefile +7 -1
- data/lib/mr_poole/cli.rb +13 -3
- data/lib/mr_poole/commands.rb +25 -15
- data/lib/mr_poole/config.rb +29 -0
- data/lib/mr_poole/helper.rb +21 -13
- data/lib/mr_poole/version.rb +1 -1
- data/lib/mr_poole.rb +1 -0
- data/spec/cli_spec.rb +148 -188
- data/spec/command_spec.rb +199 -141
- data/spec/config_spec.rb +58 -0
- data/spec/spec_helper.rb +72 -2
- metadata +7 -3
    
        data/spec/cli_spec.rb
    CHANGED
    
    | @@ -1,328 +1,288 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 | 
            -
             | 
| 3 2 | 
             
            require 'mr_poole'
         | 
| 4 | 
            -
            require 'fileutils'
         | 
| 5 | 
            -
            require 'stringio'
         | 
| 6 3 |  | 
| 7 4 | 
             
            module MrPoole
         | 
| 8 5 | 
             
              describe CLI do
         | 
| 9 6 |  | 
| 10 7 | 
             
                context 'should determine jekyll dir correctly' do
         | 
| 11 | 
            -
             | 
| 12 8 | 
             
                  it 'should exit with no _posts directory' do
         | 
| 13 9 | 
             
                    olddir, tmpdir = make_no_jekyll_dir
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                    argv = []
         | 
| 16 | 
            -
                    output = capture_stdout do
         | 
| 17 | 
            -
                      begin
         | 
| 18 | 
            -
                        cli = CLI.new(argv)
         | 
| 19 | 
            -
                      rescue SystemExit => e
         | 
| 20 | 
            -
                        e.should be_instance_of(SystemExit)
         | 
| 21 | 
            -
                      end
         | 
| 22 | 
            -
                    end
         | 
| 23 | 
            -
             | 
| 10 | 
            +
                    expect {capture_stdout { cli = CLI.new([]) }}.to raise_error(SystemExit)
         | 
| 24 11 | 
             
                    clean_tmp_files(tmpdir, olddir)
         | 
| 25 12 | 
             
                  end
         | 
| 26 13 |  | 
| 27 14 | 
             
                  it 'should not exit with _posts directory' do
         | 
| 28 15 | 
             
                    olddir, tmpdir = make_jekyll_dir
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                    argv = []
         | 
| 31 | 
            -
                    lambda { cli = CLI.new(argv) }.should_not raise_error
         | 
| 32 | 
            -
             | 
| 16 | 
            +
                    expect { cli = CLI.new([]) }.not_to raise_error
         | 
| 33 17 | 
             
                    clean_tmp_files(tmpdir, olddir)
         | 
| 34 18 | 
             
                  end
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                end   # end context determine jekyll dir
         | 
| 19 | 
            +
                end   # context determine jekyll dir
         | 
| 37 20 |  | 
| 38 21 | 
             
                describe "action 'post'" do
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                   | 
| 41 | 
            -
                    @olddir, @tmpdir = make_jekyll_dir
         | 
| 42 | 
            -
                  end
         | 
| 43 | 
            -
             | 
| 44 | 
            -
                  after :each do
         | 
| 45 | 
            -
                    clean_tmp_files(@tmpdir, @olddir)
         | 
| 46 | 
            -
                  end
         | 
| 22 | 
            +
                  before(:each) { @olddir, @tmpdir = make_jekyll_dir }
         | 
| 23 | 
            +
                  after(:each) { clean_tmp_files(@tmpdir, @olddir) }
         | 
| 47 24 |  | 
| 48 25 | 
             
                  context 'error handling' do
         | 
| 49 | 
            -
             | 
| 50 26 | 
             
                    it 'should fail with no arguments' do
         | 
| 51 27 | 
             
                      argv = ['post']
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                      expect {
         | 
| 54 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 55 | 
            -
                      }.to raise_error(SystemExit)
         | 
| 28 | 
            +
                      expect { poole_no_stdout(argv).call }.to raise_error(SystemExit)
         | 
| 56 29 | 
             
                    end
         | 
| 57 30 |  | 
| 58 31 | 
             
                    it 'should fail with no title (with slug)' do
         | 
| 59 32 | 
             
                      argv = ['post', '-s', 'post_slug']
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                      expect {
         | 
| 62 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 63 | 
            -
                      }.to raise_error(SystemExit)
         | 
| 33 | 
            +
                      expect { poole_no_stdout(argv).call }.to raise_error(SystemExit)
         | 
| 64 34 | 
             
                    end
         | 
| 65 35 |  | 
| 66 36 | 
             
                    it 'should not fail with a title (no switch)' do
         | 
| 67 37 | 
             
                      argv = ['post', 'Here is a title']
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                      expect {
         | 
| 70 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 71 | 
            -
                      }.not_to raise_error
         | 
| 38 | 
            +
                      expect { poole_no_stdout(argv).call }.not_to raise_error
         | 
| 72 39 | 
             
                    end
         | 
| 73 40 |  | 
| 74 41 | 
             
                    it 'should not fail with a title (long switch)' do
         | 
| 75 42 | 
             
                      argv = ['post', '--title', 'Here is a title']
         | 
| 76 | 
            -
             | 
| 77 | 
            -
                      expect {
         | 
| 78 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 79 | 
            -
                      }.not_to raise_error
         | 
| 43 | 
            +
                      expect { poole_no_stdout(argv).call }.not_to raise_error
         | 
| 80 44 | 
             
                    end
         | 
| 81 45 |  | 
| 82 46 | 
             
                    it 'should not fail with a title (short switch)' do
         | 
| 83 47 | 
             
                      argv = ['post', '-t', 'Here is a title']
         | 
| 84 | 
            -
             | 
| 85 | 
            -
                      expect {
         | 
| 86 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 87 | 
            -
                      }.not_to raise_error
         | 
| 48 | 
            +
                      expect { poole_no_stdout(argv).call }.not_to raise_error
         | 
| 88 49 | 
             
                    end
         | 
| 89 | 
            -
             | 
| 90 50 | 
             
                  end   # context error handling
         | 
| 91 51 |  | 
| 92 52 | 
             
                  context 'exit message' do
         | 
| 93 | 
            -
             | 
| 94 53 | 
             
                    it 'should exit with a usage message' do
         | 
| 95 54 | 
             
                      argv = ['post']
         | 
| 55 | 
            +
                      output = aborted_poole_output(argv).call
         | 
| 56 | 
            +
                      expect(output).to match(/Usage:\s+poole post/)
         | 
| 57 | 
            +
                    end
         | 
| 58 | 
            +
                  end   # context exit message
         | 
| 96 59 |  | 
| 97 | 
            -
             | 
| 98 | 
            -
             | 
| 99 | 
            -
                          poole_with_args(argv).call
         | 
| 100 | 
            -
                        rescue SystemExit => e
         | 
| 101 | 
            -
                          # this will fail, but we want the exit message
         | 
| 102 | 
            -
                        end
         | 
| 103 | 
            -
                      end
         | 
| 60 | 
            +
                  context 'custom layout' do
         | 
| 61 | 
            +
                    let(:layout_path) { write_custom_layout }
         | 
| 104 62 |  | 
| 105 | 
            -
             | 
| 63 | 
            +
                    it 'should use custom layout with --layout' do
         | 
| 64 | 
            +
                      argv = ['post', '--layout', layout_path, '--title', 'title']
         | 
| 65 | 
            +
                      poole_no_stdout(argv).call
         | 
| 66 | 
            +
                      new_file = Dir.glob("_posts/*.md").first
         | 
| 67 | 
            +
                      content = File.open(new_file, 'r').read
         | 
| 68 | 
            +
                      expect(content).to match(/tags: testing/)
         | 
| 106 69 | 
             
                    end
         | 
| 107 70 |  | 
| 108 | 
            -
             | 
| 71 | 
            +
                    it 'should exit with bad layout path' do
         | 
| 72 | 
            +
                      argv = ['post', '--layout', 'bogus_path.md', 'title']
         | 
| 73 | 
            +
                      expect { poole_no_stdout(argv).call }.to raise_error(SystemExit)
         | 
| 74 | 
            +
                    end
         | 
| 75 | 
            +
                  end   # context custom layout
         | 
| 109 76 |  | 
| 110 | 
            -
             | 
| 77 | 
            +
                  context 'default_layout in config file' do
         | 
| 78 | 
            +
                    before(:each) { write_config_file_custom_layout }
         | 
| 111 79 |  | 
| 112 | 
            -
             | 
| 80 | 
            +
                    it 'overrides default layout' do
         | 
| 81 | 
            +
                      argv = ['post', 'post title']
         | 
| 82 | 
            +
                      poole_no_stdout(argv).call
         | 
| 83 | 
            +
                      new_file = Dir.glob("_posts/*.md").first
         | 
| 84 | 
            +
                      content = File.open(new_file, 'r').read
         | 
| 85 | 
            +
                      expect(content).to match(/tags: from_config/)
         | 
| 86 | 
            +
                    end
         | 
| 113 87 |  | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 116 | 
            -
                  end
         | 
| 88 | 
            +
                    it 'is overridden by command-line layout switch' do
         | 
| 89 | 
            +
                      custom_path = write_custom_layout
         | 
| 117 90 |  | 
| 118 | 
            -
             | 
| 119 | 
            -
             | 
| 120 | 
            -
             | 
| 91 | 
            +
                      argv = ['post', '--layout', custom_path, '--title', 'title']
         | 
| 92 | 
            +
                      poole_no_stdout(argv).call
         | 
| 93 | 
            +
                      new_file = Dir.glob("_posts/*.md").first
         | 
| 94 | 
            +
                      content = File.open(new_file, 'r').read
         | 
| 95 | 
            +
                      expect(content).not_to match(/tags: from_config/)
         | 
| 96 | 
            +
                      expect(content).to match(/tags: testing/)
         | 
| 97 | 
            +
                    end
         | 
| 98 | 
            +
                  end   # default layout in config
         | 
| 121 99 |  | 
| 122 | 
            -
             | 
| 100 | 
            +
                end   # end describe post
         | 
| 123 101 |  | 
| 102 | 
            +
                describe "action 'draft'" do
         | 
| 103 | 
            +
                  before(:each) { @olddir, @tmpdir = make_jekyll_dir }
         | 
| 104 | 
            +
                  after(:each) { clean_tmp_files(@tmpdir, @olddir) }
         | 
| 105 | 
            +
             | 
| 106 | 
            +
                  context 'error handling' do
         | 
| 124 107 | 
             
                    it 'should fail with no arguments' do
         | 
| 125 108 | 
             
                      argv = ['draft']
         | 
| 126 | 
            -
             | 
| 127 | 
            -
                      expect {
         | 
| 128 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 129 | 
            -
                      }.to raise_error(SystemExit)
         | 
| 109 | 
            +
                      expect { poole_no_stdout(argv).call }.to raise_error(SystemExit)
         | 
| 130 110 | 
             
                    end
         | 
| 131 111 |  | 
| 132 112 | 
             
                    it 'should fail with no title (with slug)' do
         | 
| 133 113 | 
             
                      argv = ['draft', '-s', 'draft_slug']
         | 
| 134 | 
            -
             | 
| 135 | 
            -
                      expect {
         | 
| 136 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 137 | 
            -
                      }.to raise_error(SystemExit)
         | 
| 114 | 
            +
                      expect { poole_no_stdout(argv).call }.to raise_error(SystemExit)
         | 
| 138 115 | 
             
                    end
         | 
| 139 116 |  | 
| 140 117 | 
             
                    it 'should not fail with a title (no switch)' do
         | 
| 141 118 | 
             
                      argv = ['draft', 'Here is a title']
         | 
| 142 | 
            -
             | 
| 143 | 
            -
                      expect {
         | 
| 144 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 145 | 
            -
                      }.not_to raise_error
         | 
| 119 | 
            +
                      expect { poole_no_stdout(argv).call }.not_to raise_error
         | 
| 146 120 | 
             
                    end
         | 
| 147 121 |  | 
| 148 122 | 
             
                    it 'should not fail with a title (long switch)' do
         | 
| 149 123 | 
             
                      argv = ['draft', '--title', 'Here is a title']
         | 
| 150 | 
            -
             | 
| 151 | 
            -
                      expect {
         | 
| 152 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 153 | 
            -
                      }.not_to raise_error
         | 
| 124 | 
            +
                      expect { poole_no_stdout(argv).call }.not_to raise_error
         | 
| 154 125 | 
             
                    end
         | 
| 155 126 |  | 
| 156 127 | 
             
                    it 'should not fail with a title (short switch)' do
         | 
| 157 128 | 
             
                      argv = ['draft', '-t', 'Here is a title']
         | 
| 158 | 
            -
             | 
| 159 | 
            -
                      expect {
         | 
| 160 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 161 | 
            -
                      }.not_to raise_error
         | 
| 129 | 
            +
                      expect { poole_no_stdout(argv).call }.not_to raise_error
         | 
| 162 130 | 
             
                    end
         | 
| 163 | 
            -
             | 
| 164 131 | 
             
                  end   # context error handling
         | 
| 165 132 |  | 
| 166 133 | 
             
                  context 'exit message' do
         | 
| 167 | 
            -
             | 
| 168 134 | 
             
                    it 'should exit with a usage message' do
         | 
| 169 135 | 
             
                      argv = ['draft']
         | 
| 136 | 
            +
                      output = aborted_poole_output(argv).call
         | 
| 137 | 
            +
                      expect(output).to match(/Usage:\s+poole draft/)
         | 
| 138 | 
            +
                    end
         | 
| 139 | 
            +
                  end   # context exit message
         | 
| 170 140 |  | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
                          poole_with_args(argv).call
         | 
| 174 | 
            -
                        rescue SystemExit
         | 
| 175 | 
            -
                          # this will fail, but we want the exit message
         | 
| 176 | 
            -
                        end
         | 
| 177 | 
            -
                      end
         | 
| 141 | 
            +
                  context 'custom layout' do
         | 
| 142 | 
            +
                    let(:layout_path) { write_custom_layout }
         | 
| 178 143 |  | 
| 179 | 
            -
             | 
| 144 | 
            +
                    it 'should use custom layout with --layout' do
         | 
| 145 | 
            +
                      argv = ['draft', '--layout', layout_path, '--title', 'title']
         | 
| 146 | 
            +
                      poole_no_stdout(argv).call
         | 
| 147 | 
            +
                      content = File.open(layout_path, 'r').read
         | 
| 148 | 
            +
                      expect(content).to match(/tags: testing/)
         | 
| 180 149 | 
             
                    end
         | 
| 181 150 |  | 
| 182 | 
            -
             | 
| 151 | 
            +
                    it 'should exit with bad layout path' do
         | 
| 152 | 
            +
                      argv = ['draft', '--layout', 'bogus_path.md', 'title']
         | 
| 153 | 
            +
                      expect { poole_no_stdout(argv).call }.to raise_error(SystemExit)
         | 
| 154 | 
            +
                    end
         | 
| 155 | 
            +
                  end   # end custom layout
         | 
| 183 156 |  | 
| 184 | 
            -
             | 
| 157 | 
            +
                  context 'default_layout in config file' do
         | 
| 158 | 
            +
                    before(:each) { write_config_file_custom_layout }
         | 
| 185 159 |  | 
| 186 | 
            -
             | 
| 187 | 
            -
             | 
| 188 | 
            -
             | 
| 189 | 
            -
             | 
| 190 | 
            -
             | 
| 191 | 
            -
             | 
| 160 | 
            +
                    it 'overrides default layout' do
         | 
| 161 | 
            +
                      argv = ['draft', 'post title']
         | 
| 162 | 
            +
                      poole_no_stdout(argv).call
         | 
| 163 | 
            +
                      new_file = Dir.glob("_drafts/*.md").first
         | 
| 164 | 
            +
                      content = File.open(new_file, 'r').read
         | 
| 165 | 
            +
                      expect(content).to match(/tags: from_config/)
         | 
| 166 | 
            +
                    end
         | 
| 192 167 |  | 
| 193 | 
            -
             | 
| 194 | 
            -
             | 
| 195 | 
            -
                  end
         | 
| 168 | 
            +
                    it 'is overridden by command-line layout switch' do
         | 
| 169 | 
            +
                      custom_path = write_custom_layout
         | 
| 196 170 |  | 
| 197 | 
            -
             | 
| 171 | 
            +
                      argv = ['draft', '--layout', custom_path, '--title', 'title']
         | 
| 172 | 
            +
                      poole_no_stdout(argv).call
         | 
| 173 | 
            +
                      new_file = Dir.glob("_drafts/*.md").first
         | 
| 174 | 
            +
                      content = File.open(new_file, 'r').read
         | 
| 175 | 
            +
                      expect(content).not_to match(/tags: from_config/)
         | 
| 176 | 
            +
                      expect(content).to match(/tags: testing/)
         | 
| 177 | 
            +
                    end
         | 
| 178 | 
            +
                  end   # default layout in config
         | 
| 179 | 
            +
             | 
| 180 | 
            +
                end   # describe draft
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                describe "action 'publish'" do
         | 
| 183 | 
            +
                  let(:d_path) { Commands.new.draft({title: 'test_draft'}) }
         | 
| 184 | 
            +
                  before(:each) { @olddir, @tmpdir = make_jekyll_dir }
         | 
| 185 | 
            +
                  after(:each) { clean_tmp_files(@tmpdir, @olddir) }
         | 
| 198 186 |  | 
| 187 | 
            +
                  context 'error handling' do
         | 
| 199 188 | 
             
                    it 'should fail with no arguments' do
         | 
| 200 189 | 
             
                      argv = ['publish']
         | 
| 201 | 
            -
             | 
| 202 | 
            -
                      expect {
         | 
| 203 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 204 | 
            -
                      }.to raise_error(SystemExit)
         | 
| 190 | 
            +
                      expect { poole_no_stdout(argv).call }.to raise_error(SystemExit)
         | 
| 205 191 | 
             
                    end
         | 
| 206 192 |  | 
| 207 193 | 
             
                    it 'should fail with a bad path' do
         | 
| 208 194 | 
             
                      argv = ['publish', '_drafts/does_not_exist.md']
         | 
| 209 | 
            -
             | 
| 210 | 
            -
                      expect {
         | 
| 211 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 212 | 
            -
                      }.to raise_error(SystemExit)
         | 
| 195 | 
            +
                      expect { poole_no_stdout(argv).call }.to raise_error(SystemExit)
         | 
| 213 196 | 
             
                    end
         | 
| 214 197 |  | 
| 215 198 | 
             
                    it 'should not fail with a good path' do
         | 
| 216 | 
            -
                      argv = ['publish',  | 
| 217 | 
            -
             | 
| 218 | 
            -
                      expect {
         | 
| 219 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 220 | 
            -
                      }.not_to raise_error
         | 
| 199 | 
            +
                      argv = ['publish', d_path]
         | 
| 200 | 
            +
                      expect { poole_no_stdout(argv).call }.not_to raise_error
         | 
| 221 201 | 
             
                    end
         | 
| 222 | 
            -
             | 
| 223 202 | 
             
                  end   # context error handling
         | 
| 224 203 |  | 
| 225 204 | 
             
                  context 'exit message' do
         | 
| 226 | 
            -
             | 
| 227 205 | 
             
                    it 'should exit with usage with no arguments' do
         | 
| 228 206 | 
             
                      argv = ['publish']
         | 
| 229 | 
            -
             | 
| 230 | 
            -
                      output  | 
| 231 | 
            -
                        begin
         | 
| 232 | 
            -
                          poole_with_args(argv).call
         | 
| 233 | 
            -
                        rescue SystemExit
         | 
| 234 | 
            -
                        end
         | 
| 235 | 
            -
                      end
         | 
| 236 | 
            -
             | 
| 237 | 
            -
                      output.should match(/Usage:\s+poole publish/)
         | 
| 207 | 
            +
                      output = aborted_poole_output(argv).call
         | 
| 208 | 
            +
                      expect(output).to match(/Usage:\s+poole publish/)
         | 
| 238 209 | 
             
                    end
         | 
| 239 210 |  | 
| 240 211 | 
             
                    it 'should exit with a description of bad path' do
         | 
| 241 212 | 
             
                      argv = ['publish', '_drafts/does_not_exist.md']
         | 
| 242 | 
            -
             | 
| 243 | 
            -
                      output  | 
| 244 | 
            -
                        begin
         | 
| 245 | 
            -
                          poole_with_args(argv).call
         | 
| 246 | 
            -
                        rescue SystemExit
         | 
| 247 | 
            -
                        end
         | 
| 248 | 
            -
                      end
         | 
| 249 | 
            -
             | 
| 250 | 
            -
                      output.should match(/Error:\s+could not open/)
         | 
| 213 | 
            +
                      output = aborted_poole_output(argv).call
         | 
| 214 | 
            +
                      expect(output).to match(/Error:\s+could not open/)
         | 
| 251 215 | 
             
                    end
         | 
| 252 216 | 
             
                  end   # context exit message
         | 
| 253 217 |  | 
| 254 218 | 
             
                end
         | 
| 255 219 |  | 
| 256 220 | 
             
                describe "action 'unpublish'" do
         | 
| 257 | 
            -
                   | 
| 258 | 
            -
             | 
| 259 | 
            -
             | 
| 260 | 
            -
                    @p_path = @c.post('test_post')
         | 
| 261 | 
            -
                  end
         | 
| 262 | 
            -
             | 
| 263 | 
            -
                  after :each do
         | 
| 264 | 
            -
                    clean_tmp_files(@tmpdir, @olddir)
         | 
| 265 | 
            -
                  end
         | 
| 221 | 
            +
                  let(:p_path) { Commands.new.post({title: 'test_post'}) }
         | 
| 222 | 
            +
                  before(:each) { @olddir, @tmpdir = make_jekyll_dir }
         | 
| 223 | 
            +
                  after(:each) { clean_tmp_files(@tmpdir, @olddir) }
         | 
| 266 224 |  | 
| 267 225 | 
             
                  context 'error handling' do
         | 
| 268 | 
            -
             | 
| 269 226 | 
             
                    it 'should fail with no arguments' do
         | 
| 270 227 | 
             
                      argv = ['unpublish']
         | 
| 271 | 
            -
             | 
| 272 | 
            -
                      expect {
         | 
| 273 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 274 | 
            -
                      }.to raise_error(SystemExit)
         | 
| 228 | 
            +
                      expect { poole_no_stdout(argv).call }.to raise_error(SystemExit)
         | 
| 275 229 | 
             
                    end
         | 
| 276 230 |  | 
| 277 231 | 
             
                    it 'should fail with a bad path' do
         | 
| 278 232 | 
             
                      argv = ['unpublish', '_posts/does_not_exist.md']
         | 
| 279 | 
            -
             | 
| 280 | 
            -
                      expect {
         | 
| 281 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 282 | 
            -
                      }.to raise_error(SystemExit)
         | 
| 233 | 
            +
                      expect { poole_no_stdout(argv).call }.to raise_error(SystemExit)
         | 
| 283 234 | 
             
                    end
         | 
| 284 235 |  | 
| 285 236 | 
             
                    it 'should not fail with a good path' do
         | 
| 286 | 
            -
                      argv = ['unpublish',  | 
| 287 | 
            -
             | 
| 288 | 
            -
                      expect {
         | 
| 289 | 
            -
                        poole_with_args_no_stdout(argv).call
         | 
| 290 | 
            -
                      }.not_to raise_error
         | 
| 237 | 
            +
                      argv = ['unpublish', p_path]
         | 
| 238 | 
            +
                      expect { poole_no_stdout(argv).call }.not_to raise_error
         | 
| 291 239 | 
             
                    end
         | 
| 292 | 
            -
             | 
| 293 240 | 
             
                  end   # context error handling
         | 
| 294 241 |  | 
| 295 242 | 
             
                  context 'exit message' do
         | 
| 296 | 
            -
             | 
| 297 243 | 
             
                    it 'should exit with usage with no arguments' do
         | 
| 298 244 | 
             
                      argv = ['unpublish']
         | 
| 299 | 
            -
             | 
| 300 | 
            -
                      output  | 
| 301 | 
            -
                        begin
         | 
| 302 | 
            -
                          poole_with_args(argv).call
         | 
| 303 | 
            -
                        rescue SystemExit
         | 
| 304 | 
            -
                        end
         | 
| 305 | 
            -
                      end
         | 
| 306 | 
            -
             | 
| 307 | 
            -
                      output.should match(/Usage:\s+poole unpublish/)
         | 
| 245 | 
            +
                      output = aborted_poole_output(argv).call
         | 
| 246 | 
            +
                      expect(output).to match(/Usage:\s+poole unpublish/)
         | 
| 308 247 | 
             
                    end
         | 
| 309 248 |  | 
| 310 249 | 
             
                    it 'should exit with a description of bad path' do
         | 
| 311 250 | 
             
                      argv = ['unpublish', '_posts/does_not_exist.md']
         | 
| 312 | 
            -
             | 
| 313 | 
            -
                      output  | 
| 314 | 
            -
                        begin
         | 
| 315 | 
            -
                          poole_with_args(argv).call
         | 
| 316 | 
            -
                        rescue SystemExit
         | 
| 317 | 
            -
                        end
         | 
| 318 | 
            -
                      end
         | 
| 319 | 
            -
             | 
| 320 | 
            -
                      output.should match(/Error:\s+could not open/)
         | 
| 251 | 
            +
                      output = aborted_poole_output(argv).call
         | 
| 252 | 
            +
                      expect(output).to match(/Error:\s+could not open/)
         | 
| 321 253 | 
             
                    end
         | 
| 322 254 | 
             
                  end   # context exit message
         | 
| 323 255 |  | 
| 256 | 
            +
                end   # context action unpublish
         | 
| 257 | 
            +
             | 
| 258 | 
            +
                context 'with default extension in config file' do
         | 
| 259 | 
            +
                  before(:each) { @olddir, @tmpdir = make_jekyll_dir }
         | 
| 260 | 
            +
                  before(:each) { write_config_file_custom_extension }
         | 
| 261 | 
            +
                  after(:each) { clean_tmp_files(@tmpdir, @olddir) }
         | 
| 262 | 
            +
             | 
| 263 | 
            +
                  it 'should override default extension for post' do
         | 
| 264 | 
            +
                    argv = ['post', 'post title']
         | 
| 265 | 
            +
                    poole_no_stdout(argv).call
         | 
| 266 | 
            +
                    fn = Dir.glob("_posts/*").first
         | 
| 267 | 
            +
                    expect(fn).to match(/textile$/)
         | 
| 268 | 
            +
                  end
         | 
| 269 | 
            +
             | 
| 270 | 
            +
                  it 'should not override if command-line layout given' do
         | 
| 271 | 
            +
                    layout_path = write_custom_layout
         | 
| 272 | 
            +
                    argv = ['post', '--layout', layout_path, '-t', 'title']
         | 
| 273 | 
            +
                    poole_no_stdout(argv).call
         | 
| 274 | 
            +
                    fn = Dir.glob("_posts/*").first
         | 
| 275 | 
            +
                    expect(fn).to match(/md$/)
         | 
| 276 | 
            +
                  end
         | 
| 324 277 |  | 
| 325 | 
            -
             | 
| 278 | 
            +
                  it 'should override default extension for draft' do
         | 
| 279 | 
            +
                    argv = ['draft', 'post title']
         | 
| 280 | 
            +
                    poole_no_stdout(argv).call
         | 
| 281 | 
            +
                    fn = Dir.glob("_drafts/*").first
         | 
| 282 | 
            +
                    expect(fn).to match(/textile$/)
         | 
| 283 | 
            +
                  end
         | 
| 284 | 
            +
             | 
| 285 | 
            +
                end
         | 
| 326 286 |  | 
| 327 287 | 
             
              end
         | 
| 328 288 | 
             
            end
         |