Remove old specs for Referator::Script

This commit is contained in:
Alex Kotov 2023-09-30 17:00:27 +04:00
parent dbda041877
commit f67e2483d2
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
2 changed files with 0 additions and 114 deletions

View file

@ -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

View file

@ -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