From f67e2483d218020cc0ff0ca647a2a958c0f95861 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 30 Sep 2023 17:00:27 +0400 Subject: [PATCH] Remove old specs for Referator::Script --- spec/lib/referator/script/sub_spec.rb | 72 --------------------------- spec/lib/referator/script_spec.rb | 42 ---------------- 2 files changed, 114 deletions(-) delete mode 100644 spec/lib/referator/script/sub_spec.rb delete mode 100644 spec/lib/referator/script_spec.rb diff --git a/spec/lib/referator/script/sub_spec.rb b/spec/lib/referator/script/sub_spec.rb deleted file mode 100644 index 637f813..0000000 --- a/spec/lib/referator/script/sub_spec.rb +++ /dev/null @@ -1,72 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Referator::Script::Sub do - subject(:sub) { described_class.new vars, template } - - let(:vars) { %i[foo bar car].freeze } - let(:template) { ['qwe', :foo, 'rty', { bar: nil }.freeze].freeze } - - describe '#call' do - subject(:result) { sub.call(**kwargs) } - - let(:kwargs) { { foo: '123', bar: '456', car: '789' }.freeze } - - it { is_expected.to be_instance_of String } - it { is_expected.to be_frozen } - it { is_expected.to eq 'qwe123rty456' } - - context 'when the "vars" array is empty' do - let(:vars) { [].freeze } - let(:template) { %w[qwe rty].freeze } - let(:kwargs) { {}.freeze } - - it { is_expected.to be_instance_of String } - it { is_expected.to be_frozen } - it { is_expected.to eq 'qwerty' } - end - - context 'when template is empty' do - let(:template) { [].freeze } - - it { is_expected.to be_instance_of String } - it { is_expected.to be_frozen } - it { is_expected.to be_empty } - end - - context 'when the "vars" array and template are empty' do - let(:vars) { [].freeze } - let(:template) { [].freeze } - let(:kwargs) { {}.freeze } - - it { is_expected.to be_instance_of String } - it { is_expected.to be_frozen } - it { is_expected.to be_empty } - end - - context 'when template is a String' do - let(:template) { 'qwe' } - - it { is_expected.to be_instance_of String } - it { is_expected.to be_frozen } - it { is_expected.to eq 'qwe' } - end - - context 'when template is a Symbol' do - let(:template) { :foo } - - it { is_expected.to be_instance_of String } - it { is_expected.to be_frozen } - it { is_expected.to eq '123' } - end - - context 'when template is a Hash' do - let(:template) { { foo: nil }.freeze } - - it { is_expected.to be_instance_of String } - it { is_expected.to be_frozen } - it { is_expected.to eq '123' } - end - end -end diff --git a/spec/lib/referator/script_spec.rb b/spec/lib/referator/script_spec.rb deleted file mode 100644 index 71d00aa..0000000 --- a/spec/lib/referator/script_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe Referator::Script do - subject(:script) { described_class.new workdir:, vars:, args:, env:, stdin: } - - let(:workdir) { Pathname.new(__dir__).join('../../..').expand_path.freeze } - let(:vars) { %i[foo bar car].freeze } - - let(:args) { ['echo', :foo, { bar: nil }, :car].freeze } - let(:env) { {}.freeze } - let(:stdin) { [].freeze } - - describe '#call' do - subject(:result) { script.call(**kwargs) } - - let(:kwargs) { { foo: '123', bar: '456', car: '789' }.freeze } - - it { is_expected.to be_instance_of String } - it { is_expected.to be_frozen } - it { is_expected.to eq "123 456 789\n" } - - context 'when it depends on env vars' do - let(:args) { ['sh', '-c', ['echo ', :foo, ' $BAR $CAR'].freeze].freeze } - let(:env) { { BAR: :bar, CAR: [:car].freeze }.freeze } - - it { is_expected.to be_instance_of String } - it { is_expected.to be_frozen } - it { is_expected.to eq "123 456 789\n" } - end - - context 'when it depends on stdin' do - let(:args) { 'cat' } - let(:stdin) { [:foo, "\n", :bar, "\n", :car, "\n"].freeze } - - it { is_expected.to be_instance_of String } - it { is_expected.to be_frozen } - it { is_expected.to eq "123\n456\n789\n" } - end - end -end