Skip to content

Commit

Permalink
Fix depends_on setter
Browse files Browse the repository at this point in the history
  • Loading branch information
ngan committed Sep 27, 2023
1 parent bd8b246 commit 5570e14
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 4.4.0
* Fix multiple arguments for `depends_on`.

### 4.3.0
* Remove the `DependsOn` helper module since it doesn't do anything additive.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.3.0
4.4.0
1 change: 1 addition & 0 deletions lib/buildkite/pipelines/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Helpers
ATTRIBUTE_HELPERS = {
block: :Block,
command: :Command,
depends_on: :DependsOn,
key: :Key,
label: :Label,
plugins: :Plugins,
Expand Down
13 changes: 13 additions & 0 deletions lib/buildkite/pipelines/helpers/depends_on.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module Buildkite
module Pipelines
module Helpers
module DependsOn
def depends_on(*values)
values.any? ? super(values) : super()
end
end
end
end
end
33 changes: 33 additions & 0 deletions spec/buildkite/pipelines/helpers/depends_on_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

RSpec.describe Buildkite::Pipelines::Helpers::DependsOn do
let(:step_klass) do
Class.new do
include Buildkite::Pipelines::Attributes

attribute :depends_on, append: true
end
end

let(:step) { step_klass.new }

describe '#depends_on' do
it 'flatterns the value' do
step.depends_on([:foo, [:bar, :baz, [:daz]]])

expect(step.get(:depends_on)).to eq([:foo, :bar, :baz, :daz])
end

it 'allows multiple arguments' do
step.depends_on(:foo, :bar, :baz)

expect(step.get(:depends_on)).to eq([:foo, :bar, :baz])
end

it 'acts as getter when there are no values' do
step.depends_on(:foo, :bar, :baz)

expect(step.depends_on).to eq([:foo, :bar, :baz])
end
end
end

0 comments on commit 5570e14

Please sign in to comment.