Fix coding standards (module nesting) in specs
This commit is contained in:
parent
115561ee88
commit
48a9da9365
@ -1,10 +1,11 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Actions::Echo do
|
module Actions
|
||||||
|
describe Echo do
|
||||||
let(:env) { Env.new(output: StringIO.new) }
|
let(:env) { Env.new(output: StringIO.new) }
|
||||||
let(:text) { 'hello' }
|
let(:text) { 'hello' }
|
||||||
subject(:echo) { Actions::Echo.new(env, text) }
|
subject(:echo) { Echo.new(env, text) }
|
||||||
|
|
||||||
describe '#apply' do
|
describe '#apply' do
|
||||||
it 'writes the given string to env output with a record separator' do
|
it 'writes the given string to env output with a record separator' do
|
||||||
@ -13,4 +14,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Actions::FileWriter do
|
module Actions
|
||||||
|
describe FileWriter do
|
||||||
let(:env) { Env.new }
|
let(:env) { Env.new }
|
||||||
let(:path) { 'some_path' }
|
let(:path) { 'some_path' }
|
||||||
let(:content) { 'some_content' }
|
let(:content) { 'some_content' }
|
||||||
subject(:writer) { Actions::FileWriter.new(env, path, content) }
|
subject(:writer) { FileWriter.new(env, path, content) }
|
||||||
|
|
||||||
describe '#apply' do
|
describe '#apply' do
|
||||||
it 'writes content to file on remote filesystem' do
|
it 'writes content to file on remote filesystem' do
|
||||||
@ -26,4 +27,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Actions::Mkdir do
|
module Actions
|
||||||
|
describe Mkdir do
|
||||||
let(:env) { Env.new }
|
let(:env) { Env.new }
|
||||||
let(:path) { 'some_path' }
|
let(:path) { 'some_path' }
|
||||||
subject(:mkdir) { Actions::Mkdir.new(env, path) }
|
subject(:mkdir) { Mkdir.new(env, path) }
|
||||||
|
|
||||||
describe '#apply' do
|
describe '#apply' do
|
||||||
it 'creates directory on remote filesystem' do
|
it 'creates directory on remote filesystem' do
|
||||||
@ -19,4 +20,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Actions::ShellCommand do
|
module Actions
|
||||||
|
describe ShellCommand do
|
||||||
let(:env) { Env.new(output: StringIO.new) }
|
let(:env) { Env.new(output: StringIO.new) }
|
||||||
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) { Actions::ShellCommand.new(env, command) }
|
subject(:sh) { ShellCommand.new(env, command) }
|
||||||
|
|
||||||
describe '#apply' do
|
describe '#apply' do
|
||||||
it 'executes the remote command' do
|
it 'executes the remote command' do
|
||||||
@ -20,4 +21,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Condition::DSL do
|
class Condition
|
||||||
|
describe DSL do
|
||||||
let(:block) { proc { :some_condition_code } }
|
let(:block) { proc { :some_condition_code } }
|
||||||
let(:env) { double 'env' }
|
let(:env) { double 'env' }
|
||||||
subject(:dsl) { Condition::DSL.new(env, &block) }
|
subject(:dsl) { DSL.new(env, &block) }
|
||||||
|
|
||||||
%w[file_contains has_dir has_env has_file].each do |test|
|
%w[file_contains has_dir has_env has_file].each do |test|
|
||||||
it "has `#{test}' test defined" do
|
it "has `#{test}' test defined" do
|
||||||
@ -15,7 +16,7 @@ module Producer::Core
|
|||||||
describe '.define_test' do
|
describe '.define_test' do
|
||||||
let(:some_test_class) { Test }
|
let(:some_test_class) { Test }
|
||||||
|
|
||||||
before { Condition::DSL.define_test(:some_test, some_test_class) }
|
before { described_class.define_test(:some_test, some_test_class) }
|
||||||
|
|
||||||
it 'defines a new test keyword' do
|
it 'defines a new test keyword' do
|
||||||
expect(dsl).to respond_to :some_test
|
expect(dsl).to respond_to :some_test
|
||||||
@ -74,4 +75,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Recipe::DSL do
|
class Recipe
|
||||||
|
describe DSL do
|
||||||
include FixturesHelpers
|
include FixturesHelpers
|
||||||
|
|
||||||
let(:code) { proc { :some_recipe_code } }
|
let(:code) { proc { :some_recipe_code } }
|
||||||
let(:env) { Env.new }
|
let(:env) { Env.new }
|
||||||
subject(:dsl) { Recipe::DSL.new(env, &code) }
|
subject(:dsl) { DSL.new(env, &code) }
|
||||||
|
|
||||||
describe '#initialize' do
|
describe '#initialize' do
|
||||||
it 'assigns the given env' do
|
it 'assigns the given env' do
|
||||||
@ -115,4 +116,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Remote::Environment do
|
class Remote
|
||||||
|
describe Environment do
|
||||||
let(:variables) { { 'FOO' => 'bar', 'BAZ' => 'qux' } }
|
let(:variables) { { 'FOO' => 'bar', 'BAZ' => 'qux' } }
|
||||||
let(:string) { "FOO=bar\nBAZ=qux" }
|
let(:string) { "FOO=bar\nBAZ=qux" }
|
||||||
let(:argument) { variables }
|
let(:argument) { variables }
|
||||||
subject(:environment) { Remote::Environment.new(argument) }
|
subject(:environment) { Environment.new(argument) }
|
||||||
|
|
||||||
describe '.string_to_hash' do
|
describe '.string_to_hash' do
|
||||||
it 'converts key=value pairs separated by new lines to a hash' do
|
it 'converts key=value pairs separated by new lines to a hash' do
|
||||||
@ -46,4 +47,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Remote::FS do
|
class Remote
|
||||||
|
describe FS do
|
||||||
let(:remote) { Remote.new('some_host.example') }
|
let(:remote) { Remote.new('some_host.example') }
|
||||||
subject(:fs) { Remote::FS.new(remote) }
|
subject(:fs) { FS.new(remote) }
|
||||||
|
|
||||||
describe '#new' do
|
describe '#new' do
|
||||||
it 'assigns the remote given as argument' do
|
it 'assigns the remote given as argument' do
|
||||||
@ -180,4 +181,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Task::DSL do
|
class Task
|
||||||
|
describe DSL do
|
||||||
let(:block) { proc {} }
|
let(:block) { proc {} }
|
||||||
let(:env) { Env.new }
|
let(:env) { Env.new }
|
||||||
subject(:dsl) { Task::DSL.new(env, &block) }
|
subject(:dsl) { DSL.new(env, &block) }
|
||||||
|
|
||||||
%w[echo sh mkdir file_write].each do |action|
|
%w[echo sh mkdir file_write].each do |action|
|
||||||
it "has `#{action}' action defined" do
|
it "has `#{action}' action defined" do
|
||||||
@ -111,4 +112,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -49,7 +49,7 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when only the name is given as argument' do
|
context 'when only the name is given as argument' do
|
||||||
subject(:task) { Task.new(name) }
|
subject(:task) { described_class.new(name) }
|
||||||
|
|
||||||
it 'assigns no action' do
|
it 'assigns no action' do
|
||||||
expect(task.actions).to be_empty
|
expect(task.actions).to be_empty
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Tests::FileContains do
|
module Tests
|
||||||
|
describe FileContains do
|
||||||
let(:env) { Env.new }
|
let(:env) { Env.new }
|
||||||
let(:filepath) { 'some_file' }
|
let(:filepath) { 'some_file' }
|
||||||
let(:content) { 'some_content' }
|
let(:content) { 'some_content' }
|
||||||
subject(:test) { Tests::FileContains.new(env, filepath, content) }
|
subject(:test) { FileContains.new(env, filepath, content) }
|
||||||
|
|
||||||
it 'is a kind of test' do
|
it 'is a kind of test' do
|
||||||
expect(test).to be_a Test
|
expect(test).to be_a Test
|
||||||
@ -17,7 +18,10 @@ module Producer::Core
|
|||||||
before { allow(test).to receive(:fs) { fs } }
|
before { allow(test).to receive(:fs) { fs } }
|
||||||
|
|
||||||
context 'when file contains the content' do
|
context 'when file contains the content' do
|
||||||
before { allow(fs).to receive(:file_read).with(filepath) { "foo#{content}bar" } }
|
before do
|
||||||
|
allow(fs)
|
||||||
|
.to receive(:file_read).with(filepath) { "foo#{content}bar" }
|
||||||
|
end
|
||||||
|
|
||||||
it 'returns true' do
|
it 'returns true' do
|
||||||
expect(test.verify).to be true
|
expect(test.verify).to be true
|
||||||
@ -25,7 +29,9 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when file does not contain the content' do
|
context 'when file does not contain the content' do
|
||||||
before { allow(fs).to receive(:file_read).with(filepath) { 'foo bar' } }
|
before do
|
||||||
|
allow(fs).to receive(:file_read).with(filepath) { 'foo bar' }
|
||||||
|
end
|
||||||
|
|
||||||
it 'returns false' do
|
it 'returns false' do
|
||||||
expect(test.verify).to be false
|
expect(test.verify).to be false
|
||||||
@ -41,4 +47,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Tests::HasDir do
|
module Tests
|
||||||
|
describe HasDir do
|
||||||
let(:env) { Env.new }
|
let(:env) { Env.new }
|
||||||
let(:path) { 'some_directory' }
|
let(:path) { 'some_directory' }
|
||||||
subject(:has_dir) { Tests::HasDir.new(env, path) }
|
subject(:has_dir) { HasDir.new(env, path) }
|
||||||
|
|
||||||
it 'is a kind of test' do
|
it 'is a kind of test' do
|
||||||
expect(has_dir).to be_a Test
|
expect(has_dir).to be_a Test
|
||||||
@ -25,4 +26,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Tests::HasEnv do
|
module Tests
|
||||||
|
describe HasEnv do
|
||||||
let(:env) { Env.new }
|
let(:env) { Env.new }
|
||||||
let(:variable_name) { :some_variable_name }
|
let(:variable_name) { :some_variable_name }
|
||||||
subject(:has_env) { Tests::HasEnv.new(env, variable_name) }
|
subject(:has_env) { HasEnv.new(env, variable_name) }
|
||||||
|
|
||||||
it 'is a kind of test' do
|
it 'is a kind of test' do
|
||||||
expect(has_env).to be_a Test
|
expect(has_env).to be_a Test
|
||||||
@ -38,4 +39,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe Tests::HasFile do
|
module Tests
|
||||||
|
describe HasFile do
|
||||||
let(:env) { Env.new }
|
let(:env) { Env.new }
|
||||||
let(:filepath) { 'some_file' }
|
let(:filepath) { 'some_file' }
|
||||||
subject(:has_file) { Tests::HasFile.new(env, filepath) }
|
subject(:has_file) { HasFile.new(env, filepath) }
|
||||||
|
|
||||||
it 'is a kind of test' do
|
it 'is a kind of test' do
|
||||||
expect(has_file).to be_a Test
|
expect(has_file).to be_a Test
|
||||||
@ -25,4 +26,5 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user