Fix coding standards (module nesting) in specs
This commit is contained in:
@@ -1,42 +1,49 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module Producer::Core
|
||||
describe Tests::FileContains do
|
||||
let(:env) { Env.new }
|
||||
let(:filepath) { 'some_file' }
|
||||
let(:content) { 'some_content' }
|
||||
subject(:test) { Tests::FileContains.new(env, filepath, content) }
|
||||
module Tests
|
||||
describe FileContains do
|
||||
let(:env) { Env.new }
|
||||
let(:filepath) { 'some_file' }
|
||||
let(:content) { 'some_content' }
|
||||
subject(:test) { FileContains.new(env, filepath, content) }
|
||||
|
||||
it 'is a kind of test' do
|
||||
expect(test).to be_a Test
|
||||
end
|
||||
|
||||
describe '#verify' do
|
||||
let(:fs) { double 'fs' }
|
||||
|
||||
before { allow(test).to receive(:fs) { fs } }
|
||||
|
||||
context 'when file contains the content' do
|
||||
before { allow(fs).to receive(:file_read).with(filepath) { "foo#{content}bar" } }
|
||||
|
||||
it 'returns true' do
|
||||
expect(test.verify).to be true
|
||||
end
|
||||
it 'is a kind of test' do
|
||||
expect(test).to be_a Test
|
||||
end
|
||||
|
||||
context 'when file does not contain the content' do
|
||||
before { allow(fs).to receive(:file_read).with(filepath) { 'foo bar' } }
|
||||
describe '#verify' do
|
||||
let(:fs) { double 'fs' }
|
||||
|
||||
it 'returns false' do
|
||||
expect(test.verify).to be false
|
||||
before { allow(test).to receive(:fs) { fs } }
|
||||
|
||||
context 'when file contains the content' do
|
||||
before do
|
||||
allow(fs)
|
||||
.to receive(:file_read).with(filepath) { "foo#{content}bar" }
|
||||
end
|
||||
|
||||
it 'returns true' do
|
||||
expect(test.verify).to be true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when file does not exist' do
|
||||
before { allow(fs).to receive(:file_read).with(filepath) { nil } }
|
||||
context 'when file does not contain the content' do
|
||||
before do
|
||||
allow(fs).to receive(:file_read).with(filepath) { 'foo bar' }
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
expect(test.verify).to be false
|
||||
it 'returns false' do
|
||||
expect(test.verify).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when file does not exist' do
|
||||
before { allow(fs).to receive(:file_read).with(filepath) { nil } }
|
||||
|
||||
it 'returns false' do
|
||||
expect(test.verify).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -1,27 +1,29 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module Producer::Core
|
||||
describe Tests::HasDir do
|
||||
let(:env) { Env.new }
|
||||
let(:path) { 'some_directory' }
|
||||
subject(:has_dir) { Tests::HasDir.new(env, path) }
|
||||
module Tests
|
||||
describe HasDir do
|
||||
let(:env) { Env.new }
|
||||
let(:path) { 'some_directory' }
|
||||
subject(:has_dir) { HasDir.new(env, path) }
|
||||
|
||||
it 'is a kind of test' do
|
||||
expect(has_dir).to be_a Test
|
||||
end
|
||||
|
||||
describe '#verify', :ssh do
|
||||
before { sftp_story }
|
||||
|
||||
it 'delegates the call on remote FS' do
|
||||
expect(env.remote.fs).to receive(:dir?).with(path)
|
||||
has_dir.verify
|
||||
it 'is a kind of test' do
|
||||
expect(has_dir).to be_a Test
|
||||
end
|
||||
|
||||
it 'returns the dir existence' do
|
||||
existence = double 'existence'
|
||||
allow(env.remote.fs).to receive(:dir?) { existence }
|
||||
expect(has_dir.verify).to be existence
|
||||
describe '#verify', :ssh do
|
||||
before { sftp_story }
|
||||
|
||||
it 'delegates the call on remote FS' do
|
||||
expect(env.remote.fs).to receive(:dir?).with(path)
|
||||
has_dir.verify
|
||||
end
|
||||
|
||||
it 'returns the dir existence' do
|
||||
existence = double 'existence'
|
||||
allow(env.remote.fs).to receive(:dir?) { existence }
|
||||
expect(has_dir.verify).to be existence
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -1,40 +1,42 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module Producer::Core
|
||||
describe Tests::HasEnv do
|
||||
let(:env) { Env.new }
|
||||
let(:variable_name) { :some_variable_name }
|
||||
subject(:has_env) { Tests::HasEnv.new(env, variable_name) }
|
||||
module Tests
|
||||
describe HasEnv do
|
||||
let(:env) { Env.new }
|
||||
let(:variable_name) { :some_variable_name }
|
||||
subject(:has_env) { HasEnv.new(env, variable_name) }
|
||||
|
||||
it 'is a kind of test' do
|
||||
expect(has_env).to be_a Test
|
||||
end
|
||||
|
||||
describe '#verify' do
|
||||
let(:environment) { double 'environment' }
|
||||
|
||||
before do
|
||||
allow(env.remote).to receive(:environment) { environment }
|
||||
it 'is a kind of test' do
|
||||
expect(has_env).to be_a Test
|
||||
end
|
||||
|
||||
it 'stringifies the queried variable name' do
|
||||
expect(environment).to receive(:key?).with(kind_of(String))
|
||||
has_env.verify
|
||||
end
|
||||
describe '#verify' do
|
||||
let(:environment) { double 'environment' }
|
||||
|
||||
it 'upcases the queried variable name' do
|
||||
expect(environment).to receive(:key?).with('SOME_VARIABLE_NAME')
|
||||
has_env.verify
|
||||
end
|
||||
before do
|
||||
allow(env.remote).to receive(:environment) { environment }
|
||||
end
|
||||
|
||||
it 'returns true when remote environment var is defined' do
|
||||
allow(environment).to receive(:key?) { true }
|
||||
expect(has_env.verify).to be true
|
||||
end
|
||||
it 'stringifies the queried variable name' do
|
||||
expect(environment).to receive(:key?).with(kind_of(String))
|
||||
has_env.verify
|
||||
end
|
||||
|
||||
it 'returns false when remote environment var is not defined' do
|
||||
allow(environment).to receive(:key?) { false }
|
||||
expect(has_env.verify).to be false
|
||||
it 'upcases the queried variable name' do
|
||||
expect(environment).to receive(:key?).with('SOME_VARIABLE_NAME')
|
||||
has_env.verify
|
||||
end
|
||||
|
||||
it 'returns true when remote environment var is defined' do
|
||||
allow(environment).to receive(:key?) { true }
|
||||
expect(has_env.verify).to be true
|
||||
end
|
||||
|
||||
it 'returns false when remote environment var is not defined' do
|
||||
allow(environment).to receive(:key?) { false }
|
||||
expect(has_env.verify).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -1,27 +1,29 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module Producer::Core
|
||||
describe Tests::HasFile do
|
||||
let(:env) { Env.new }
|
||||
let(:filepath) { 'some_file' }
|
||||
subject(:has_file) { Tests::HasFile.new(env, filepath) }
|
||||
module Tests
|
||||
describe HasFile do
|
||||
let(:env) { Env.new }
|
||||
let(:filepath) { 'some_file' }
|
||||
subject(:has_file) { HasFile.new(env, filepath) }
|
||||
|
||||
it 'is a kind of test' do
|
||||
expect(has_file).to be_a Test
|
||||
end
|
||||
|
||||
describe '#verify', :ssh do
|
||||
before { sftp_story }
|
||||
|
||||
it 'delegates the call on remote FS' do
|
||||
expect(env.remote.fs).to receive(:file?).with(filepath)
|
||||
has_file.verify
|
||||
it 'is a kind of test' do
|
||||
expect(has_file).to be_a Test
|
||||
end
|
||||
|
||||
it 'returns the file existence' do
|
||||
existence = double 'existence'
|
||||
allow(env.remote.fs).to receive(:file?) { existence }
|
||||
expect(has_file.verify).to be existence
|
||||
describe '#verify', :ssh do
|
||||
before { sftp_story }
|
||||
|
||||
it 'delegates the call on remote FS' do
|
||||
expect(env.remote.fs).to receive(:file?).with(filepath)
|
||||
has_file.verify
|
||||
end
|
||||
|
||||
it 'returns the file existence' do
|
||||
existence = double 'existence'
|
||||
allow(env.remote.fs).to receive(:file?) { existence }
|
||||
expect(has_file.verify).to be existence
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user