whenever 0.9.2 → 0.9.3
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/.travis.yml +1 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +0 -5
- data/README.md +3 -1
- data/lib/whenever.rb +10 -11
- data/lib/whenever/capistrano/v3/tasks/whenever.rake +2 -2
- data/lib/whenever/command_line.rb +9 -9
- data/lib/whenever/cron.rb +11 -11
- data/lib/whenever/job.rb +2 -2
- data/lib/whenever/job_list.rb +18 -7
- data/lib/whenever/numeric_seconds.rb +54 -0
- data/lib/whenever/tasks/whenever.rake +2 -2
- data/lib/whenever/version.rb +1 -1
- data/test/functional/command_line_test.rb +221 -224
- data/test/functional/output_at_test.rb +188 -249
- data/test/functional/output_default_defined_jobs_test.rb +214 -290
- data/test/functional/output_defined_job_test.rb +65 -91
- data/test/functional/output_env_test.rb +22 -26
- data/test/functional/output_jobs_for_roles_test.rb +46 -66
- data/test/functional/output_redirection_test.rb +231 -309
- data/test/test_case.rb +39 -0
- data/test/test_helper.rb +33 -14
- data/test/unit/capistrano_support_test.rb +126 -148
- data/test/unit/cron_test.rb +188 -215
- data/test/unit/job_test.rb +111 -121
- data/whenever.gemspec +0 -2
- metadata +15 -41
| @@ -1,345 +1,269 @@ | |
| 1 | 
            -
            require  | 
| 1 | 
            +
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            class OutputDefaultDefinedJobsTest <  | 
| 3 | 
            +
            class OutputDefaultDefinedJobsTest < Whenever::TestCase
         | 
| 4 4 |  | 
| 5 5 | 
             
              # command
         | 
| 6 6 |  | 
| 7 | 
            -
               | 
| 8 | 
            -
                 | 
| 9 | 
            -
             | 
| 10 | 
            -
                   | 
| 11 | 
            -
             | 
| 12 | 
            -
                     | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
                  file
         | 
| 16 | 
            -
                end
         | 
| 7 | 
            +
              test "A plain command with the job template set to nil" do
         | 
| 8 | 
            +
                output = Whenever.cron \
         | 
| 9 | 
            +
                <<-file
         | 
| 10 | 
            +
                  set :job_template, nil
         | 
| 11 | 
            +
                  every 2.hours do
         | 
| 12 | 
            +
                    command "blahblah"
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                file
         | 
| 17 15 |  | 
| 18 | 
            -
                 | 
| 19 | 
            -
                  assert_match /^.+ .+ .+ .+ blahblah$/, @output
         | 
| 20 | 
            -
                end
         | 
| 16 | 
            +
                assert_match /^.+ .+ .+ .+ blahblah$/, output
         | 
| 21 17 | 
             
              end
         | 
| 22 18 |  | 
| 23 | 
            -
               | 
| 24 | 
            -
                 | 
| 25 | 
            -
             | 
| 26 | 
            -
                   | 
| 27 | 
            -
                     | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
                  file
         | 
| 31 | 
            -
                end
         | 
| 19 | 
            +
              test "A plain command with no job template set" do
         | 
| 20 | 
            +
                output = Whenever.cron \
         | 
| 21 | 
            +
                <<-file
         | 
| 22 | 
            +
                  every 2.hours do
         | 
| 23 | 
            +
                    command "blahblah"
         | 
| 24 | 
            +
                  end
         | 
| 25 | 
            +
                file
         | 
| 32 26 |  | 
| 33 | 
            -
                 | 
| 34 | 
            -
                  assert_match /^.+ .+ .+ .+ \/bin\/bash -l -c 'blahblah'$/, @output
         | 
| 35 | 
            -
                end
         | 
| 27 | 
            +
                assert_match /^.+ .+ .+ .+ \/bin\/bash -l -c 'blahblah'$/, output
         | 
| 36 28 | 
             
              end
         | 
| 37 29 |  | 
| 38 | 
            -
               | 
| 39 | 
            -
                 | 
| 40 | 
            -
             | 
| 41 | 
            -
                   | 
| 42 | 
            -
             | 
| 43 | 
            -
                     | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
                 | 
| 49 | 
            -
             | 
| 50 | 
            -
                should "output the command using that job_template" do
         | 
| 51 | 
            -
                  assert_match /^.+ .+ .+ .+ \/bin\/bash -l -c 'cd \/tmp \&\& blahblah'$/, @output
         | 
| 52 | 
            -
                end
         | 
| 30 | 
            +
              test "A plain command with a job_template using a normal parameter" do
         | 
| 31 | 
            +
                output = Whenever.cron \
         | 
| 32 | 
            +
                <<-file
         | 
| 33 | 
            +
                  set :job_template, "/bin/bash -l -c 'cd :path && :job'"
         | 
| 34 | 
            +
                  every 2.hours do
         | 
| 35 | 
            +
                    set :path, "/tmp"
         | 
| 36 | 
            +
                    command "blahblah"
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
                file
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                assert_match /^.+ .+ .+ .+ \/bin\/bash -l -c 'cd \/tmp \&\& blahblah'$/, output
         | 
| 53 41 | 
             
              end
         | 
| 54 42 |  | 
| 43 | 
            +
              test "A plain command that overrides the job_template set" do
         | 
| 44 | 
            +
                output = Whenever.cron \
         | 
| 45 | 
            +
                <<-file
         | 
| 46 | 
            +
                  set :job_template, "/bin/bash -l -c ':job'"
         | 
| 47 | 
            +
                  every 2.hours do
         | 
| 48 | 
            +
                    command "blahblah", :job_template => "/bin/sh -l -c ':job'"
         | 
| 49 | 
            +
                  end
         | 
| 50 | 
            +
                file
         | 
| 55 51 |  | 
| 56 | 
            -
              context "A plain command that overrides the job_template set" do
         | 
| 57 | 
            -
                setup do
         | 
| 58 | 
            -
                  @output = Whenever.cron \
         | 
| 59 | 
            -
                  <<-file
         | 
| 60 | 
            -
                    set :job_template, "/bin/bash -l -c ':job'"
         | 
| 61 | 
            -
                    every 2.hours do
         | 
| 62 | 
            -
                      command "blahblah", :job_template => "/bin/sh -l -c ':job'"
         | 
| 63 | 
            -
                    end
         | 
| 64 | 
            -
                  file
         | 
| 65 | 
            -
                end
         | 
| 66 52 |  | 
| 67 | 
            -
                 | 
| 68 | 
            -
             | 
| 69 | 
            -
                  assert_no_match /bash/, @output
         | 
| 70 | 
            -
                end
         | 
| 53 | 
            +
                assert_match /^.+ .+ .+ .+ \/bin\/sh -l -c 'blahblah'$/, output
         | 
| 54 | 
            +
                assert_no_match /bash/, output
         | 
| 71 55 | 
             
              end
         | 
| 72 56 |  | 
| 73 | 
            -
               | 
| 74 | 
            -
                 | 
| 75 | 
            -
             | 
| 76 | 
            -
                   | 
| 77 | 
            -
             | 
| 78 | 
            -
                     | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
                  file
         | 
| 83 | 
            -
                end
         | 
| 57 | 
            +
              test "A plain command that overrides the job_template set using a parameter" do
         | 
| 58 | 
            +
                output = Whenever.cron \
         | 
| 59 | 
            +
                <<-file
         | 
| 60 | 
            +
                  set :job_template, "/bin/bash -l -c 'cd :path && :job'"
         | 
| 61 | 
            +
                  every 2.hours do
         | 
| 62 | 
            +
                    set :path, "/tmp"
         | 
| 63 | 
            +
                    command "blahblah", :job_template => "/bin/sh -l -c 'cd :path && :job'"
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
                file
         | 
| 84 66 |  | 
| 85 | 
            -
                should "output the command using that job_template" do
         | 
| 86 | 
            -
                  assert_match /^.+ .+ .+ .+ \/bin\/sh -l -c 'cd \/tmp && blahblah'$/, @output
         | 
| 87 | 
            -
                  assert_no_match /bash/, @output
         | 
| 88 | 
            -
                end
         | 
| 89 | 
            -
              end
         | 
| 90 67 |  | 
| 91 | 
            -
             | 
| 92 | 
            -
                 | 
| 93 | 
            -
                  Whenever.expects(:path).at_least_once.returns('/what/you/want')
         | 
| 94 | 
            -
                  @output = Whenever.cron \
         | 
| 95 | 
            -
                  <<-file
         | 
| 96 | 
            -
                    set :job_template, nil
         | 
| 97 | 
            -
                    if environment == 'production' && path == '/what/you/want'
         | 
| 98 | 
            -
                      every 2.hours do
         | 
| 99 | 
            -
                        command "blahblah"
         | 
| 100 | 
            -
                      end
         | 
| 101 | 
            -
                    end
         | 
| 102 | 
            -
                  file
         | 
| 103 | 
            -
                end
         | 
| 104 | 
            -
             | 
| 105 | 
            -
                should "output the command" do
         | 
| 106 | 
            -
                  assert_match /blahblah/, @output
         | 
| 107 | 
            -
                end
         | 
| 68 | 
            +
                assert_match /^.+ .+ .+ .+ \/bin\/sh -l -c 'cd \/tmp && blahblah'$/, output
         | 
| 69 | 
            +
                assert_no_match /bash/, output
         | 
| 108 70 | 
             
              end
         | 
| 109 71 |  | 
| 110 | 
            -
               | 
| 111 | 
            -
             | 
| 112 | 
            -
             | 
| 113 | 
            -
                 | 
| 114 | 
            -
                   | 
| 115 | 
            -
                   | 
| 116 | 
            -
                    set :job_template, nil
         | 
| 117 | 
            -
                    set :path, '/my/path'
         | 
| 72 | 
            +
              test "A plain command that is conditional on default environent and path" do
         | 
| 73 | 
            +
                Whenever.expects(:path).at_least_once.returns('/what/you/want')
         | 
| 74 | 
            +
                output = Whenever.cron \
         | 
| 75 | 
            +
                <<-file
         | 
| 76 | 
            +
                  set :job_template, nil
         | 
| 77 | 
            +
                  if environment == 'production' && path == '/what/you/want'
         | 
| 118 78 | 
             
                    every 2.hours do
         | 
| 119 | 
            -
                       | 
| 79 | 
            +
                      command "blahblah"
         | 
| 120 80 | 
             
                    end
         | 
| 121 | 
            -
                   | 
| 122 | 
            -
                 | 
| 81 | 
            +
                  end
         | 
| 82 | 
            +
                file
         | 
| 123 83 |  | 
| 124 | 
            -
                 | 
| 125 | 
            -
                  assert_match two_hours + %( cd /my/path && script/runner -e production 'blahblah'), @output
         | 
| 126 | 
            -
                end
         | 
| 84 | 
            +
                assert_match /blahblah/, output
         | 
| 127 85 | 
             
              end
         | 
| 128 86 |  | 
| 129 | 
            -
               | 
| 130 | 
            -
                setup do
         | 
| 131 | 
            -
                  @output = Whenever.cron \
         | 
| 132 | 
            -
                  <<-file
         | 
| 133 | 
            -
                    set :job_template, nil
         | 
| 134 | 
            -
                    set :path, '/my/path'
         | 
| 135 | 
            -
                    every 2.hours do
         | 
| 136 | 
            -
                      runner "blahblah", :path => '/some/other/path'
         | 
| 137 | 
            -
                    end
         | 
| 138 | 
            -
                  file
         | 
| 139 | 
            -
                end
         | 
| 87 | 
            +
              # runner
         | 
| 140 88 |  | 
| 141 | 
            -
             | 
| 142 | 
            -
             | 
| 143 | 
            -
                 | 
| 89 | 
            +
              test "A runner with path set" do
         | 
| 90 | 
            +
                output = Whenever.cron \
         | 
| 91 | 
            +
                <<-file
         | 
| 92 | 
            +
                  set :job_template, nil
         | 
| 93 | 
            +
                  set :path, '/my/path'
         | 
| 94 | 
            +
                  every 2.hours do
         | 
| 95 | 
            +
                    runner 'blahblah'
         | 
| 96 | 
            +
                  end
         | 
| 97 | 
            +
                file
         | 
| 98 | 
            +
             | 
| 99 | 
            +
                assert_match two_hours + %( cd /my/path && script/runner -e production 'blahblah'), output
         | 
| 144 100 | 
             
              end
         | 
| 145 101 |  | 
| 146 | 
            -
               | 
| 147 | 
            -
                 | 
| 148 | 
            -
             | 
| 149 | 
            -
                   | 
| 150 | 
            -
                   | 
| 151 | 
            -
                   | 
| 152 | 
            -
                     | 
| 153 | 
            -
             | 
| 154 | 
            -
             | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 157 | 
            -
                end
         | 
| 158 | 
            -
             | 
| 159 | 
            -
                should "use a script/rails runner job by default" do
         | 
| 160 | 
            -
                  assert_match two_hours + %( cd /my/path && bin/rails runner -e production 'blahblah'), @output
         | 
| 161 | 
            -
                end
         | 
| 102 | 
            +
              test "A runner that overrides the path set" do
         | 
| 103 | 
            +
                output = Whenever.cron \
         | 
| 104 | 
            +
                <<-file
         | 
| 105 | 
            +
                  set :job_template, nil
         | 
| 106 | 
            +
                  set :path, '/my/path'
         | 
| 107 | 
            +
                  every 2.hours do
         | 
| 108 | 
            +
                    runner "blahblah", :path => '/some/other/path'
         | 
| 109 | 
            +
                  end
         | 
| 110 | 
            +
                file
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                assert_match two_hours + %( cd /some/other/path && script/runner -e production 'blahblah'), output
         | 
| 162 113 | 
             
              end
         | 
| 163 114 |  | 
| 164 | 
            -
               | 
| 165 | 
            -
                 | 
| 166 | 
            -
             | 
| 167 | 
            -
             | 
| 168 | 
            -
             | 
| 169 | 
            -
                   | 
| 170 | 
            -
             | 
| 171 | 
            -
                     | 
| 172 | 
            -
             | 
| 173 | 
            -
             | 
| 174 | 
            -
             | 
| 175 | 
            -
                 | 
| 115 | 
            +
              test "A runner for an app with bin/rails" do
         | 
| 116 | 
            +
                Whenever.expects(:path).at_least_once.returns('/my/path')
         | 
| 117 | 
            +
                Whenever.expects(:bin_rails?).returns(true)
         | 
| 118 | 
            +
                output = Whenever.cron \
         | 
| 119 | 
            +
                <<-file
         | 
| 120 | 
            +
                  set :job_template, nil
         | 
| 121 | 
            +
                  every 2.hours do
         | 
| 122 | 
            +
                    runner 'blahblah'
         | 
| 123 | 
            +
                  end
         | 
| 124 | 
            +
                file
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                assert_match two_hours + %( cd /my/path && bin/rails runner -e production 'blahblah'), output
         | 
| 127 | 
            +
              end
         | 
| 176 128 |  | 
| 177 | 
            -
             | 
| 178 | 
            -
             | 
| 179 | 
            -
                 | 
| 129 | 
            +
              test "A runner for an app with script/rails" do
         | 
| 130 | 
            +
                Whenever.expects(:path).at_least_once.returns('/my/path')
         | 
| 131 | 
            +
                Whenever.expects(:script_rails?).returns(true)
         | 
| 132 | 
            +
                output = Whenever.cron \
         | 
| 133 | 
            +
                <<-file
         | 
| 134 | 
            +
                  set :job_template, nil
         | 
| 135 | 
            +
                  every 2.hours do
         | 
| 136 | 
            +
                    runner 'blahblah'
         | 
| 137 | 
            +
                  end
         | 
| 138 | 
            +
                file
         | 
| 139 | 
            +
             | 
| 140 | 
            +
                assert_match two_hours + %( cd /my/path && script/rails runner -e production 'blahblah'), output
         | 
| 180 141 | 
             
              end
         | 
| 181 142 |  | 
| 182 143 | 
             
              # rake
         | 
| 183 144 |  | 
| 184 | 
            -
               | 
| 185 | 
            -
                 | 
| 186 | 
            -
             | 
| 187 | 
            -
                   | 
| 188 | 
            -
             | 
| 189 | 
            -
             | 
| 190 | 
            -
                     | 
| 191 | 
            -
             | 
| 192 | 
            -
             | 
| 193 | 
            -
             | 
| 194 | 
            -
                 | 
| 195 | 
            -
             | 
| 196 | 
            -
                should "output the rake command using that path" do
         | 
| 197 | 
            -
                  assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec rake blahblah --silent', @output
         | 
| 198 | 
            -
                end
         | 
| 145 | 
            +
              test "A rake command with path set" do
         | 
| 146 | 
            +
                output = Whenever.cron \
         | 
| 147 | 
            +
                <<-file
         | 
| 148 | 
            +
                  set :job_template, nil
         | 
| 149 | 
            +
                  set :path, '/my/path'
         | 
| 150 | 
            +
                  every 2.hours do
         | 
| 151 | 
            +
                    rake "blahblah"
         | 
| 152 | 
            +
                  end
         | 
| 153 | 
            +
                file
         | 
| 154 | 
            +
             | 
| 155 | 
            +
                assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec rake blahblah --silent', output
         | 
| 199 156 | 
             
              end
         | 
| 200 157 |  | 
| 201 | 
            -
               | 
| 202 | 
            -
                 | 
| 203 | 
            -
             | 
| 204 | 
            -
             | 
| 205 | 
            -
             | 
| 206 | 
            -
                   | 
| 207 | 
            -
             | 
| 208 | 
            -
                     | 
| 209 | 
            -
             | 
| 210 | 
            -
             | 
| 211 | 
            -
             | 
| 212 | 
            -
                 | 
| 213 | 
            -
             | 
| 214 | 
            -
                should "not use invoke through bundler" do
         | 
| 215 | 
            -
                  assert_match two_hours + ' cd /my/path && RAILS_ENV=production rake blahblah --silent', @output
         | 
| 216 | 
            -
                end
         | 
| 158 | 
            +
              test "A rake for a non-bundler app" do
         | 
| 159 | 
            +
                Whenever.expects(:path).at_least_once.returns('/my/path')
         | 
| 160 | 
            +
                Whenever.expects(:bundler?).returns(false)
         | 
| 161 | 
            +
                output = Whenever.cron \
         | 
| 162 | 
            +
                <<-file
         | 
| 163 | 
            +
                  set :job_template, nil
         | 
| 164 | 
            +
                  every 2.hours do
         | 
| 165 | 
            +
                    rake 'blahblah'
         | 
| 166 | 
            +
                  end
         | 
| 167 | 
            +
                file
         | 
| 168 | 
            +
             | 
| 169 | 
            +
                assert_match two_hours + ' cd /my/path && RAILS_ENV=production rake blahblah --silent', output
         | 
| 217 170 | 
             
              end
         | 
| 218 171 |  | 
| 219 | 
            -
               | 
| 220 | 
            -
                 | 
| 221 | 
            -
             | 
| 222 | 
            -
                   | 
| 223 | 
            -
             | 
| 224 | 
            -
             | 
| 225 | 
            -
                     | 
| 226 | 
            -
             | 
| 227 | 
            -
             | 
| 228 | 
            -
             | 
| 229 | 
            -
                 | 
| 230 | 
            -
             | 
| 231 | 
            -
                should "output the rake command using that path" do
         | 
| 232 | 
            -
                  assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production bundle exec rake blahblah --silent', @output
         | 
| 233 | 
            -
                end
         | 
| 172 | 
            +
              test "A rake command that overrides the path set" do
         | 
| 173 | 
            +
                output = Whenever.cron \
         | 
| 174 | 
            +
                <<-file
         | 
| 175 | 
            +
                  set :job_template, nil
         | 
| 176 | 
            +
                  set :path, '/my/path'
         | 
| 177 | 
            +
                  every 2.hours do
         | 
| 178 | 
            +
                    rake "blahblah", :path => '/some/other/path'
         | 
| 179 | 
            +
                  end
         | 
| 180 | 
            +
                file
         | 
| 181 | 
            +
             | 
| 182 | 
            +
                assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production bundle exec rake blahblah --silent', output
         | 
| 234 183 | 
             
              end
         | 
| 235 184 |  | 
| 236 | 
            -
               | 
| 237 | 
            -
                 | 
| 238 | 
            -
             | 
| 239 | 
            -
                   | 
| 240 | 
            -
             | 
| 241 | 
            -
             | 
| 242 | 
            -
             | 
| 243 | 
            -
                     | 
| 244 | 
            -
             | 
| 245 | 
            -
             | 
| 246 | 
            -
             | 
| 247 | 
            -
                 | 
| 248 | 
            -
             | 
| 249 | 
            -
                should "output the rake command using that environment variable" do
         | 
| 250 | 
            -
                  assert_match two_hours + ' cd /my/path && RAKE_ENV=production bundle exec rake blahblah --silent', @output
         | 
| 251 | 
            -
                end
         | 
| 185 | 
            +
              test "A rake command that sets the environment variable" do
         | 
| 186 | 
            +
                output = Whenever.cron \
         | 
| 187 | 
            +
                <<-file
         | 
| 188 | 
            +
                  set :job_template, nil
         | 
| 189 | 
            +
                  set :path, '/my/path'
         | 
| 190 | 
            +
                  set :environment_variable, 'RAKE_ENV'
         | 
| 191 | 
            +
                  every 2.hours do
         | 
| 192 | 
            +
                    rake "blahblah"
         | 
| 193 | 
            +
                  end
         | 
| 194 | 
            +
                file
         | 
| 195 | 
            +
             | 
| 196 | 
            +
                assert_match two_hours + ' cd /my/path && RAKE_ENV=production bundle exec rake blahblah --silent', output
         | 
| 252 197 | 
             
              end
         | 
| 253 198 |  | 
| 254 | 
            -
               | 
| 255 | 
            -
                 | 
| 256 | 
            -
             | 
| 257 | 
            -
                   | 
| 258 | 
            -
             | 
| 259 | 
            -
             | 
| 260 | 
            -
             | 
| 261 | 
            -
                     | 
| 262 | 
            -
             | 
| 263 | 
            -
             | 
| 264 | 
            -
             | 
| 265 | 
            -
                 | 
| 266 | 
            -
             | 
| 267 | 
            -
                should "output the rake command using that environment variable" do
         | 
| 268 | 
            -
                  assert_match two_hours + ' cd /my/path && SOME_ENV=production bundle exec rake blahblah --silent', @output
         | 
| 269 | 
            -
                end
         | 
| 199 | 
            +
              test "A rake command that overrides the environment variable" do
         | 
| 200 | 
            +
                output = Whenever.cron \
         | 
| 201 | 
            +
                <<-file
         | 
| 202 | 
            +
                  set :job_template, nil
         | 
| 203 | 
            +
                  set :path, '/my/path'
         | 
| 204 | 
            +
                  set :environment_variable, 'RAKE_ENV'
         | 
| 205 | 
            +
                  every 2.hours do
         | 
| 206 | 
            +
                    rake "blahblah", :environment_variable => 'SOME_ENV'
         | 
| 207 | 
            +
                  end
         | 
| 208 | 
            +
                file
         | 
| 209 | 
            +
             | 
| 210 | 
            +
                assert_match two_hours + ' cd /my/path && SOME_ENV=production bundle exec rake blahblah --silent', output
         | 
| 270 211 | 
             
              end
         | 
| 271 212 |  | 
| 272 213 | 
             
                # script
         | 
| 273 214 |  | 
| 274 | 
            -
               | 
| 275 | 
            -
                 | 
| 276 | 
            -
             | 
| 277 | 
            -
                   | 
| 278 | 
            -
             | 
| 279 | 
            -
             | 
| 280 | 
            -
                     | 
| 281 | 
            -
             | 
| 282 | 
            -
             | 
| 283 | 
            -
             | 
| 284 | 
            -
                 | 
| 285 | 
            -
             | 
| 286 | 
            -
                should "output the script command using that path" do
         | 
| 287 | 
            -
                  assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec script/blahblah', @output
         | 
| 288 | 
            -
                end
         | 
| 215 | 
            +
              test "A script command with path set" do
         | 
| 216 | 
            +
                output = Whenever.cron \
         | 
| 217 | 
            +
                <<-file
         | 
| 218 | 
            +
                  set :job_template, nil
         | 
| 219 | 
            +
                  set :path, '/my/path'
         | 
| 220 | 
            +
                  every 2.hours do
         | 
| 221 | 
            +
                    script "blahblah"
         | 
| 222 | 
            +
                  end
         | 
| 223 | 
            +
                file
         | 
| 224 | 
            +
             | 
| 225 | 
            +
                assert_match two_hours + ' cd /my/path && RAILS_ENV=production bundle exec script/blahblah', output
         | 
| 289 226 | 
             
              end
         | 
| 290 227 |  | 
| 291 | 
            -
               | 
| 292 | 
            -
                 | 
| 293 | 
            -
             | 
| 294 | 
            -
             | 
| 295 | 
            -
             | 
| 296 | 
            -
                   | 
| 297 | 
            -
             | 
| 298 | 
            -
                     | 
| 299 | 
            -
             | 
| 300 | 
            -
             | 
| 301 | 
            -
             | 
| 302 | 
            -
                 | 
| 303 | 
            -
             | 
| 304 | 
            -
                should "not use invoke through bundler" do
         | 
| 305 | 
            -
                  assert_match two_hours + ' cd /my/path && RAILS_ENV=production script/blahblah', @output
         | 
| 306 | 
            -
                end
         | 
| 228 | 
            +
              test "A script command for a non-bundler app" do
         | 
| 229 | 
            +
                Whenever.expects(:path).at_least_once.returns('/my/path')
         | 
| 230 | 
            +
                Whenever.expects(:bundler?).returns(false)
         | 
| 231 | 
            +
                output = Whenever.cron \
         | 
| 232 | 
            +
                <<-file
         | 
| 233 | 
            +
                  set :job_template, nil
         | 
| 234 | 
            +
                  every 2.hours do
         | 
| 235 | 
            +
                    script 'blahblah'
         | 
| 236 | 
            +
                  end
         | 
| 237 | 
            +
                file
         | 
| 238 | 
            +
             | 
| 239 | 
            +
                assert_match two_hours + ' cd /my/path && RAILS_ENV=production script/blahblah', output
         | 
| 307 240 | 
             
              end
         | 
| 308 241 |  | 
| 309 | 
            -
               | 
| 310 | 
            -
                 | 
| 311 | 
            -
             | 
| 312 | 
            -
                   | 
| 313 | 
            -
             | 
| 314 | 
            -
             | 
| 315 | 
            -
             | 
| 316 | 
            -
                     | 
| 317 | 
            -
             | 
| 318 | 
            -
             | 
| 319 | 
            -
             | 
| 320 | 
            -
                 | 
| 321 | 
            -
             | 
| 322 | 
            -
                should "output the script command using that path" do
         | 
| 323 | 
            -
                  assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production bundle exec script/blahblah >> /log/file 2>&1', @output
         | 
| 324 | 
            -
                end
         | 
| 242 | 
            +
              test "A script command that uses output" do
         | 
| 243 | 
            +
                output = Whenever.cron \
         | 
| 244 | 
            +
                <<-file
         | 
| 245 | 
            +
                  set :job_template, nil
         | 
| 246 | 
            +
                  set :output, '/log/file'
         | 
| 247 | 
            +
                  set :path, '/my/path'
         | 
| 248 | 
            +
                  every 2.hours do
         | 
| 249 | 
            +
                    script "blahblah", :path => '/some/other/path'
         | 
| 250 | 
            +
                  end
         | 
| 251 | 
            +
                file
         | 
| 252 | 
            +
             | 
| 253 | 
            +
                assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production bundle exec script/blahblah >> /log/file 2>&1', output
         | 
| 325 254 | 
             
              end
         | 
| 326 255 |  | 
| 327 | 
            -
               | 
| 328 | 
            -
                 | 
| 329 | 
            -
             | 
| 330 | 
            -
                   | 
| 331 | 
            -
             | 
| 332 | 
            -
             | 
| 333 | 
            -
             | 
| 334 | 
            -
                     | 
| 335 | 
            -
             | 
| 336 | 
            -
             | 
| 337 | 
            -
             | 
| 338 | 
            -
                 | 
| 339 | 
            -
             | 
| 340 | 
            -
                should "output the script command using that environment variable" do
         | 
| 341 | 
            -
                  assert_match two_hours + ' cd /my/path && RAKE_ENV=production bundle exec script/blahblah', @output
         | 
| 342 | 
            -
                end
         | 
| 256 | 
            +
              test "A script command that uses an environment variable" do
         | 
| 257 | 
            +
                output = Whenever.cron \
         | 
| 258 | 
            +
                <<-file
         | 
| 259 | 
            +
                  set :job_template, nil
         | 
| 260 | 
            +
                  set :environment_variable, 'RAKE_ENV'
         | 
| 261 | 
            +
                  set :path, '/my/path'
         | 
| 262 | 
            +
                  every 2.hours do
         | 
| 263 | 
            +
                    script "blahblah"
         | 
| 264 | 
            +
                  end
         | 
| 265 | 
            +
                file
         | 
| 266 | 
            +
             | 
| 267 | 
            +
                assert_match two_hours + ' cd /my/path && RAKE_ENV=production bundle exec script/blahblah', output
         | 
| 343 268 | 
             
              end
         | 
| 344 | 
            -
             | 
| 345 269 | 
             
            end
         |