Refactor specs
This commit is contained in:
parent
52e8338a7d
commit
52dcfcedd3
@ -4,7 +4,7 @@ module Producer::Core
|
|||||||
module Actions
|
module Actions
|
||||||
describe Echo, :env do
|
describe Echo, :env do
|
||||||
let(:text) { 'hello' }
|
let(:text) { 'hello' }
|
||||||
subject(:echo) { Echo.new(env, text) }
|
subject(:echo) { described_class.new(env, text) }
|
||||||
|
|
||||||
it_behaves_like 'action'
|
it_behaves_like 'action'
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ module Producer::Core
|
|||||||
let(:path) { 'some_path' }
|
let(:path) { 'some_path' }
|
||||||
let(:content) { 'some content' }
|
let(:content) { 'some content' }
|
||||||
let(:added_content) { ' added' }
|
let(:added_content) { ' added' }
|
||||||
subject(:action) { FileAppend.new(env, path, added_content) }
|
subject(:action) { described_class.new(env, path, added_content) }
|
||||||
|
|
||||||
it_behaves_like 'action'
|
it_behaves_like 'action'
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ module Producer::Core
|
|||||||
let(:pattern) { 'content' }
|
let(:pattern) { 'content' }
|
||||||
let(:replacement) { 'other content' }
|
let(:replacement) { 'other content' }
|
||||||
let(:content) { 'some content' }
|
let(:content) { 'some content' }
|
||||||
subject(:action) { FileReplaceContent.new(env, path, pattern, replacement) }
|
subject(:action) { described_class.new(env, path, pattern, replacement) }
|
||||||
|
|
||||||
it_behaves_like 'action'
|
it_behaves_like 'action'
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ module Producer::Core
|
|||||||
describe FileWriter, :env do
|
describe FileWriter, :env do
|
||||||
let(:path) { 'some_path' }
|
let(:path) { 'some_path' }
|
||||||
let(:content) { 'some_content' }
|
let(:content) { 'some_content' }
|
||||||
subject(:writer) { FileWriter.new(env, path, content) }
|
subject(:writer) { described_class.new(env, path, content) }
|
||||||
|
|
||||||
it_behaves_like 'action'
|
it_behaves_like 'action'
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when a mode was given' do
|
context 'when a mode was given' do
|
||||||
subject(:writer) { FileWriter.new(env, path, content, 0600) }
|
subject(:writer) { described_class.new(env, path, content, 0600) }
|
||||||
|
|
||||||
it 'specifies the given mode' do
|
it 'specifies the given mode' do
|
||||||
expect(remote_fs)
|
expect(remote_fs)
|
||||||
@ -44,7 +44,7 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when a mode was given' do
|
context 'when a mode was given' do
|
||||||
subject(:writer) { FileWriter.new(env, path, content, 0600) }
|
subject(:writer) { described_class.new(env, path, content, 0600) }
|
||||||
|
|
||||||
it 'returns the mode' do
|
it 'returns the mode' do
|
||||||
expect(writer.mode).to eq 0600
|
expect(writer.mode).to eq 0600
|
||||||
|
@ -4,7 +4,7 @@ module Producer::Core
|
|||||||
module Actions
|
module Actions
|
||||||
describe Mkdir, :env do
|
describe Mkdir, :env do
|
||||||
let(:path) { 'some_path' }
|
let(:path) { 'some_path' }
|
||||||
subject(:mkdir) { Mkdir.new(env, path) }
|
subject(:mkdir) { described_class.new(env, path) }
|
||||||
|
|
||||||
it_behaves_like 'action'
|
it_behaves_like 'action'
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when a mode was given' do
|
context 'when a mode was given' do
|
||||||
subject(:mkdir) { Mkdir.new(env, path, 0700) }
|
subject(:mkdir) { described_class.new(env, path, 0700) }
|
||||||
|
|
||||||
it 'changes the directory with given mode' do
|
it 'changes the directory with given mode' do
|
||||||
expect(remote_fs).to receive(:chmod).with(path, 0700)
|
expect(remote_fs).to receive(:chmod).with(path, 0700)
|
||||||
|
@ -5,7 +5,7 @@ module Producer::Core
|
|||||||
describe ShellCommand, :env do
|
describe ShellCommand, :env do
|
||||||
let(:command_args) { 'hello from remote host' }
|
let(:command_args) { 'hello from remote host' }
|
||||||
let(:command) { "echo #{command_args}" }
|
let(:command) { "echo #{command_args}" }
|
||||||
subject(:sh) { ShellCommand.new(env, command) }
|
subject(:sh) { described_class.new(env, command) }
|
||||||
|
|
||||||
it_behaves_like 'action'
|
it_behaves_like 'action'
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ module Producer::Core
|
|||||||
before { described_class.define_test(:some_test, some_test) }
|
before { described_class.define_test(:some_test, some_test) }
|
||||||
|
|
||||||
it 'returns an evaluated condition' do
|
it 'returns an evaluated condition' do
|
||||||
expect(condition).to be_a Condition
|
expect(condition).to be_a described_class
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'evaluates the condition tests' do
|
it 'evaluates the condition tests' do
|
||||||
|
@ -4,7 +4,7 @@ module Producer::Core
|
|||||||
describe Prompter do
|
describe Prompter do
|
||||||
let(:input) { StringIO.new }
|
let(:input) { StringIO.new }
|
||||||
let(:output) { StringIO.new }
|
let(:output) { StringIO.new }
|
||||||
subject(:prompter) { Prompter.new(input, output) }
|
subject(:prompter) { described_class.new(input, output) }
|
||||||
|
|
||||||
describe '#initialize' do
|
describe '#initialize' do
|
||||||
it 'assigns the given input' do
|
it 'assigns the given input' do
|
||||||
|
@ -5,7 +5,7 @@ module Producer::Core
|
|||||||
describe FS do
|
describe FS do
|
||||||
let(:sftp_file) { double 'sftp_file' }
|
let(:sftp_file) { double 'sftp_file' }
|
||||||
let(:sftp) { double('sftp', file: sftp_file) }
|
let(:sftp) { double('sftp', file: sftp_file) }
|
||||||
subject(:fs) { FS.new(sftp) }
|
subject(:fs) { described_class.new(sftp) }
|
||||||
|
|
||||||
describe '#initialize' do
|
describe '#initialize' do
|
||||||
it 'assigns the sftp session' do
|
it 'assigns the sftp session' do
|
||||||
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Remote do
|
describe Remote do
|
||||||
let(:hostname) { 'some_host.example' }
|
let(:hostname) { 'some_host.example' }
|
||||||
subject(:remote) { Remote.new(hostname) }
|
subject(:remote) { described_class.new(hostname) }
|
||||||
|
|
||||||
describe '#initialize' do
|
describe '#initialize' do
|
||||||
it 'assigns the given hostname' do
|
it 'assigns the given hostname' do
|
||||||
|
@ -4,7 +4,7 @@ require 'producer/core/testing'
|
|||||||
module Producer::Core
|
module Producer::Core
|
||||||
module Testing
|
module Testing
|
||||||
describe MockRemote do
|
describe MockRemote do
|
||||||
subject(:remote) { MockRemote.new('some_host.example') }
|
subject(:remote) { described_class.new('some_host.example') }
|
||||||
|
|
||||||
it 'is a remote' do
|
it 'is a remote' do
|
||||||
expect(remote).to be_a Remote
|
expect(remote).to be_a Remote
|
||||||
|
@ -5,7 +5,7 @@ module Producer::Core
|
|||||||
describe FileContains, :env do
|
describe FileContains, :env do
|
||||||
let(:filepath) { 'some_file' }
|
let(:filepath) { 'some_file' }
|
||||||
let(:content) { 'some_content' }
|
let(:content) { 'some_content' }
|
||||||
subject(:test) { FileContains.new(env, filepath, content) }
|
subject(:test) { described_class.new(env, filepath, content) }
|
||||||
|
|
||||||
it_behaves_like 'test'
|
it_behaves_like 'test'
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ module Producer::Core
|
|||||||
describe FileEq, :env do
|
describe FileEq, :env do
|
||||||
let(:filepath) { 'some_file' }
|
let(:filepath) { 'some_file' }
|
||||||
let(:content) { 'some content' }
|
let(:content) { 'some content' }
|
||||||
subject(:test) { FileEq.new(env, filepath, content) }
|
subject(:test) { described_class.new(env, filepath, content) }
|
||||||
|
|
||||||
it_behaves_like 'test'
|
it_behaves_like 'test'
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ module Producer::Core
|
|||||||
module Tests
|
module Tests
|
||||||
describe HasDir, :env do
|
describe HasDir, :env do
|
||||||
let(:path) { 'some_directory' }
|
let(:path) { 'some_directory' }
|
||||||
subject(:has_dir) { HasDir.new(env, path) }
|
subject(:has_dir) { described_class.new(env, path) }
|
||||||
|
|
||||||
it_behaves_like 'test'
|
it_behaves_like 'test'
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ module Producer::Core
|
|||||||
let(:var_name) { 'SOME_VAR' }
|
let(:var_name) { 'SOME_VAR' }
|
||||||
let(:var_value) { 'SOME_VALUE' }
|
let(:var_value) { 'SOME_VALUE' }
|
||||||
let(:remote_env) { { 'SOME_VAR' => 'SOME_VALUE' } }
|
let(:remote_env) { { 'SOME_VAR' => 'SOME_VALUE' } }
|
||||||
subject(:has_env) { HasEnv.new(env, var_name) }
|
subject(:has_env) { described_class.new(env, var_name) }
|
||||||
|
|
||||||
it_behaves_like 'test'
|
it_behaves_like 'test'
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when var name and value are provided' do
|
context 'when var name and value are provided' do
|
||||||
subject(:has_env) { HasEnv.new(env, var_name, var_value) }
|
subject(:has_env) { described_class.new(env, var_name, var_value) }
|
||||||
|
|
||||||
describe '#verify' do
|
describe '#verify' do
|
||||||
context 'when remote environment var is defined' do
|
context 'when remote environment var is defined' do
|
||||||
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||||||
module Producer::Core
|
module Producer::Core
|
||||||
module Tests
|
module Tests
|
||||||
describe HasExecutable, :env do
|
describe HasExecutable, :env do
|
||||||
subject(:test) { HasExecutable.new(env, executable) }
|
subject(:test) { described_class.new(env, executable) }
|
||||||
|
|
||||||
it_behaves_like 'test'
|
it_behaves_like 'test'
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ module Producer::Core
|
|||||||
module Tests
|
module Tests
|
||||||
describe HasFile, :env do
|
describe HasFile, :env do
|
||||||
let(:filepath) { 'some_file' }
|
let(:filepath) { 'some_file' }
|
||||||
subject(:has_file) { HasFile.new(env, filepath) }
|
subject(:has_file) { described_class.new(env, filepath) }
|
||||||
|
|
||||||
it_behaves_like 'test'
|
it_behaves_like 'test'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user