Skip to content

Commit

Permalink
👮
Browse files Browse the repository at this point in the history
  • Loading branch information
bibendi committed Nov 7, 2023
1 parent a328e9b commit a50ff5b
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion lib/dip/cli/console.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require "thor"
require_relative "./base"
require_relative "base"
require_relative "../commands/console"

module Dip
Expand Down
2 changes: 1 addition & 1 deletion lib/dip/cli/dns.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require "thor"
require_relative "./base"
require_relative "base"
require_relative "../commands/dns"

module Dip
Expand Down
2 changes: 1 addition & 1 deletion lib/dip/cli/nginx.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require "thor"
require_relative "./base"
require_relative "base"
require_relative "../commands/nginx"

module Dip
Expand Down
2 changes: 1 addition & 1 deletion lib/dip/cli/ssh.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require "thor"
require_relative "./base"
require_relative "base"
require_relative "../commands/ssh"

module Dip
Expand Down
20 changes: 10 additions & 10 deletions spec/lib/dip/commands/compose_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
it { expected_exec("docker-compose", ["run", "--rm", "bash"]) }
end

context "when config contains project_name", config: true do
context "when config contains project_name", :config do
let(:config) { {compose: {project_name: "rocket"}} }

before { cli.start "compose run".shellsplit }

it { expected_exec("docker-compose", ["--project-name", "rocket", "run"]) }
end

context "when config contains project_name with env vars", config: true, env: true do
context "when config contains project_name with env vars", :config, :env do
let(:config) { {compose: {project_name: "rocket-$RAILS_ENV"}} }
let(:env) { {"RAILS_ENV" => "test"} }

Expand All @@ -36,15 +36,15 @@
it { expected_exec("docker-compose", ["--project-name", "rocket-test", "run"]) }
end

context "when config contains project_directory", config: true do
context "when config contains project_directory", :config do
let(:config) { {compose: {project_directory: "/foo/bar"}} }

before { cli.start "compose run".shellsplit }

it { expected_exec("docker-compose", ["--project-directory", "/foo/bar", "run"]) }
end

context "when config contains project_directory with env vars", config: true, env: true do
context "when config contains project_directory with env vars", :config, :env do
let(:config) { {compose: {project_directory: "/foo-$RAILS_ENV"}} }
let(:env) { {"RAILS_ENV" => "test"} }

Expand All @@ -53,7 +53,7 @@
it { expected_exec("docker-compose", ["--project-directory", "/foo-test", "run"]) }
end

context "when compose's config path contains spaces", config: true do
context "when compose's config path contains spaces", :config do
let(:config) { {compose: {files: ["file name.yml"]}} }
let(:file) { fixture_path("empty", "file name.yml") }

Expand All @@ -73,7 +73,7 @@
it { expected_exec("docker-compose", ["--file", Shellwords.escape(file), "run"]) }
end

context "when config contains multiple docker-compose files", config: true do
context "when config contains multiple docker-compose files", :config do
context "and some files are not exist" do
let(:config) { {compose: {files: %w[file1.yml file2.yml file3.yml]}} }
let(:global_file) { fixture_path("empty", "file1.yml") }
Expand All @@ -98,7 +98,7 @@
it { expected_exec("docker-compose", ["--file", global_file, "--file", override_file, "run"]) }
end

context "and a file name contains env var", env: true do
context "and a file name contains env var", :env do
let(:config) { {compose: {files: %w[file1-${DIP_OS}.yml]}} }
let(:file) { fixture_path("empty", "file1-darwin.yml") }
let(:env) { {"DIP_OS" => "darwin"} }
Expand All @@ -120,7 +120,7 @@
end
end

context "when compose command specified in config", config: true do
context "when compose command specified in config", :config do
context "when compose command contains spaces" do
let(:config) { {compose: {command: "foo compose"}} }

Expand All @@ -138,7 +138,7 @@
end
end

context "when DIP_COMPOSE_COMMAND is specified in environment", env: true do
context "when DIP_COMPOSE_COMMAND is specified in environment", :env do
context "when DIP_COMPOSE_COMMAND contains spaces" do
let(:env) { {"DIP_COMPOSE_COMMAND" => "foo compose"} }

Expand All @@ -155,7 +155,7 @@
it { expected_exec("foo-compose", "run") }
end

context "when compose command specified in config", config: true do
context "when compose command specified in config", :config do
let(:config) { {compose: {command: "foo compose"}} }
let(:env) { {"DIP_COMPOSE_COMMAND" => "bar-compose"} }

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/dip/commands/console_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
it { expect { subject }.to output(/unset -f provision/).to_stdout }
end

context "when has provision command", config: true do
context "when has provision command", :config do
let(:config) { {interaction: commands} }
let(:commands) { {bash: {service: "app"}, rails: {service: "app", command: "rails"}} }

Expand Down
6 changes: 3 additions & 3 deletions spec/lib/dip/commands/kubectl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
it { expected_exec("kubectl", ["exec", "app", "--", "ls", "-l"]) }
end

context "when config contains namespace", config: true do
context "when config contains namespace", :config do
let(:config) { {kubectl: {namespace: "rocket"}} }

before { cli.start "ktl get pods".shellsplit }

it { expected_exec("kubectl", ["--namespace", "rocket", "get", "pods"]) }
end

context "when config contains namespace with env vars", config: true, env: true do
context "when config contains namespace with env vars", :config, :env do
let(:config) { {kubectl: {namespace: "rocket-${STAGE}"}} }
let(:env) { {"STAGE" => "test"} }

Expand All @@ -36,7 +36,7 @@
it { expected_exec("kubectl", ["--namespace", "rocket-test", "get", "pods"]) }
end

context "when config contains namespace with empty env vars", config: true, env: true do
context "when config contains namespace with empty env vars", :config, :env do
let(:config) { {kubectl: {namespace: "rocket-${STAGE}"}} }
let(:env) { {"STAGE" => ""} }

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/dip/commands/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require "dip/cli"
require "dip/commands/list"

describe Dip::Commands::List, config: true do
describe Dip::Commands::List, :config do
let(:config) { {interaction: commands} }
let(:commands) do
{
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/dip/commands/provision_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "dip/cli"
require "dip/commands/provision"

describe Dip::Commands::Provision, config: true do
describe Dip::Commands::Provision, :config do
let(:config) { {provision: commands} }
let(:cli) { Dip::CLI }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require "dip/cli"
require "dip/commands/run"

describe Dip::Commands::Runners::DockerComposeRunner, config: true do
describe Dip::Commands::Runners::DockerComposeRunner, :config do
let(:config) { {interaction: commands} }
let(:commands) do
{
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/dip/commands/runners/kubectl_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require "dip/cli"
require "dip/commands/run"

describe Dip::Commands::Runners::KubectlRunner, config: true do
describe Dip::Commands::Runners::KubectlRunner, :config do
let(:config) { {interaction: commands} }
let(:commands) do
{
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/dip/commands/runners/local_runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require "dip/cli"
require "dip/commands/run"

describe Dip::Commands::Runners::LocalRunner, config: true do
describe Dip::Commands::Runners::LocalRunner, :config do
let(:config) { {interaction: commands} }
let(:commands) do
{
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/dip/commands/ssh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let(:cli) { Dip::CLI::SSH }

describe Dip::Commands::SSH::Up do
context "when without arguments", env: true do
context "when without arguments", :env do
let(:env) { {"HOME" => "/user"} }

before { cli.start "up".shellsplit }
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/dip/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
it { is_expected.to be_exist }
end

context "when file doesn't exist", env: true do
context "when file doesn't exist", :env do
let(:env) { {"DIP_FILE" => "no.yml"} }

it { is_expected.not_to be_exist }
Expand All @@ -17,7 +17,7 @@

%i[environment compose interaction provision].each do |key|
describe "##{key}" do
context "when config file doesn't exist", env: true do
context "when config file doesn't exist", :env do
let(:env) { {"DIP_FILE" => "no.yml"} }

it { expect { subject.public_send(key) }.to raise_error(Dip::Error) }
Expand All @@ -35,7 +35,7 @@
end
end

context "when config has override file", env: true do
context "when config has override file", :env do
let(:env) { {"DIP_FILE" => fixture_path("overridden", "dip.yml")} }

it "rewrites an array" do
Expand All @@ -53,7 +53,7 @@
end
end

context "when config located two levels higher and overridden at one level higher", env: true do
context "when config located two levels higher and overridden at one level higher", :env do
subject { described_class.new(fixture_path("cascade", "sub_a", "sub_b")) }

let(:env) { {"DIP_FILE" => nil} }
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/dip/environment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
it { is_expected.to include("FOO" => "foo") }
end

context "and its exist in ENV", env: true do
context "and its exist in ENV", :env do
let(:vars) { {"FOO" => "foo"} }
let(:env) { {"FOO" => "bar"} }

it { is_expected.to include("FOO" => "bar") }
end

context "and some vars were interpolated", env: true do
context "and some vars were interpolated", :env do
let(:vars) { {"BAZ" => "baz", "FOO" => "foo-${BAR}-$BAZ"} }
let(:env) { {"BAR" => "bar"} }

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/dip_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
describe ".debug?" do
it { expect(described_class.debug?).to be false }

context "when debug is running", env: true do
context "when debug is running", :env do
let(:env) { {"DIP_ENV" => "debug"} }

it { expect(described_class.debug?).to be true }
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_contexts/config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

shared_context "dip config", config: true do
shared_context "dip config", :config do
before do
Dip.config.to_h.merge!(config)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_contexts/environment.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

shared_context "replace environment vars", env: true do
shared_context "replace environment vars", :env do
around do |ex|
original = {}

Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_contexts/runner.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

shared_context "dip command", runner: true do
shared_context "dip command", :runner do
let(:exec_program_runner) { spy("exec_program runner") }
let(:exec_subprocess_runner) { spy("exec_subprocess runner") }

Expand Down

0 comments on commit a50ff5b

Please sign in to comment.