Fix coding standards (module nesting) in specs

This commit is contained in:
Thibault Jouan
2014-02-08 17:59:33 +00:00
parent 115561ee88
commit 48a9da9365
14 changed files with 590 additions and 559 deletions

View File

@@ -1,15 +1,17 @@
require 'spec_helper'
module Producer::Core
describe Actions::Echo do
let(:env) { Env.new(output: StringIO.new) }
let(:text) { 'hello' }
subject(:echo) { Actions::Echo.new(env, text) }
module Actions
describe Echo do
let(:env) { Env.new(output: StringIO.new) }
let(:text) { 'hello' }
subject(:echo) { Echo.new(env, text) }
describe '#apply' do
it 'writes the given string to env output with a record separator' do
echo.apply
expect(env.output.string).to eq "hello\n"
describe '#apply' do
it 'writes the given string to env output with a record separator' do
echo.apply
expect(env.output.string).to eq "hello\n"
end
end
end
end

View File

@@ -1,28 +1,30 @@
require 'spec_helper'
module Producer::Core
describe Actions::FileWriter do
let(:env) { Env.new }
let(:path) { 'some_path' }
let(:content) { 'some_content' }
subject(:writer) { Actions::FileWriter.new(env, path, content) }
module Actions
describe FileWriter do
let(:env) { Env.new }
let(:path) { 'some_path' }
let(:content) { 'some_content' }
subject(:writer) { FileWriter.new(env, path, content) }
describe '#apply' do
it 'writes content to file on remote filesystem' do
expect(writer.fs).to receive(:file_write).with(path, content)
writer.apply
describe '#apply' do
it 'writes content to file on remote filesystem' do
expect(writer.fs).to receive(:file_write).with(path, content)
writer.apply
end
end
end
describe '#path' do
it 'returns the path' do
expect(writer.path).to eq path
describe '#path' do
it 'returns the path' do
expect(writer.path).to eq path
end
end
end
describe '#content' do
it 'returns the content' do
expect(writer.content).to eq content
describe '#content' do
it 'returns the content' do
expect(writer.content).to eq content
end
end
end
end

View File

@@ -1,21 +1,23 @@
require 'spec_helper'
module Producer::Core
describe Actions::Mkdir do
let(:env) { Env.new }
let(:path) { 'some_path' }
subject(:mkdir) { Actions::Mkdir.new(env, path) }
module Actions
describe Mkdir do
let(:env) { Env.new }
let(:path) { 'some_path' }
subject(:mkdir) { Mkdir.new(env, path) }
describe '#apply' do
it 'creates directory on remote filesystem' do
expect(mkdir.fs).to receive(:mkdir).with(path)
mkdir.apply
describe '#apply' do
it 'creates directory on remote filesystem' do
expect(mkdir.fs).to receive(:mkdir).with(path)
mkdir.apply
end
end
end
describe '#path' do
it 'returns the path' do
expect(mkdir.path).to eq path
describe '#path' do
it 'returns the path' do
expect(mkdir.path).to eq path
end
end
end
end

View File

@@ -1,22 +1,24 @@
require 'spec_helper'
module Producer::Core
describe Actions::ShellCommand do
let(:env) { Env.new(output: StringIO.new) }
let(:command_args) { 'hello from remote host' }
let(:command) { "echo #{command_args}" }
subject(:sh) { Actions::ShellCommand.new(env, command) }
module Actions
describe ShellCommand do
let(:env) { Env.new(output: StringIO.new) }
let(:command_args) { 'hello from remote host' }
let(:command) { "echo #{command_args}" }
subject(:sh) { ShellCommand.new(env, command) }
describe '#apply' do
it 'executes the remote command' do
expect(sh.remote).to receive(:execute).with(command)
sh.apply
end
describe '#apply' do
it 'executes the remote command' do
expect(sh.remote).to receive(:execute).with(command)
sh.apply
end
it 'writes the returned output with a record separator' do
allow(sh.remote).to receive(:execute) { command_args }
sh.apply
expect(sh.output.string).to eq "#{command_args}\n"
it 'writes the returned output with a record separator' do
allow(sh.remote).to receive(:execute) { command_args }
sh.apply
expect(sh.output.string).to eq "#{command_args}\n"
end
end
end
end