test/models/deploy_spec_test.rb in shipit-engine-0.19.0 vs test/models/deploy_spec_test.rb in shipit-engine-0.20.0
- old
+ new
@@ -316,18 +316,45 @@
assert_equal 1, @spec.deploy_variables.size
variable_definition = @spec.deploy_variables.first
assert_equal 'SAFETY_DISABLED', variable_definition.name
end
- test "task definitions prepend bundle exec if necessary" do
+ test "task definitions prepend bundle exec by default" do
@spec.expects(:load_config).returns('tasks' => {'restart' => {'steps' => %w(foo)}})
@spec.expects(:bundler?).returns(true).at_least_once
+ assert_deprecated(/Automatically prepending `bundle exec`/) do
+ definition = @spec.find_task_definition('restart')
+ assert_equal ['bundle exec foo'], definition.steps
+ end
+ end
+
+ test "task definitions prepend bundle exec if enabled" do
+ Shipit.expects(:automatically_prepend_bundle_exec).returns(true).at_least_once
+ @spec.expects(:load_config).returns('tasks' => {'restart' => {'steps' => %w(foo)}})
+ @spec.expects(:bundler?).returns(true).at_least_once
definition = @spec.find_task_definition('restart')
assert_equal ['bundle exec foo'], definition.steps
end
+ test "task definitions do not prepend bundle exec if disabled" do
+ Shipit.expects(:automatically_prepend_bundle_exec).returns(false).at_least_once
+ @spec.expects(:load_config).returns('tasks' => {'restart' => {'steps' => %w(foo)}})
+ definition = @spec.find_task_definition('restart')
+
+ assert_equal ['foo'], definition.steps
+ end
+
+ test "task definitions do not prepend bundle exec if the task already does" do
+ Shipit.expects(:automatically_prepend_bundle_exec).returns(true).at_least_once
+ @spec.expects(:load_config).returns('tasks' => {'restart' => {'steps' => ['bundle exec foo']}})
+ @spec.stubs(:bundler?).returns(true)
+ definition = @spec.find_task_definition('restart')
+
+ assert_equal ['bundle exec foo'], definition.steps
+ end
+
test "task definitions do not prepend bundle exec if depedency step is overridden" do
@spec.expects(:load_config).returns(
'dependencies' => {'override' => []},
'tasks' => {'restart' => {'steps' => %w(foo)}},
)
@@ -336,10 +363,10 @@
assert_equal ['foo'], definition.steps
end
test "task definitions prepend bundle exec before serialization" do
- @spec.expects(:load_config).returns('tasks' => {'restart' => {'steps' => %w(foo)}})
+ @spec.expects(:discover_task_definitions).returns('restart' => {'steps' => %w(foo)})
@spec.expects(:bundler?).returns(true).at_least_once
cached_spec = DeploySpec.load(DeploySpec.dump(@spec))
definition = cached_spec.find_task_definition('restart')
assert_equal ['bundle exec foo'], definition.steps