Add some new delegators in Test class:

* #remote (delegates to env.remote)
* #fs (delegates to env.remote.fs)
This commit is contained in:
Thibault Jouan 2014-01-18 22:53:54 +00:00
parent 22613059f1
commit 913cba6c23
4 changed files with 21 additions and 3 deletions

View File

@ -1,6 +1,12 @@
module Producer
module Core
class Test
require 'forwardable'
extend Forwardable
def_delegators :@env, :remote
def_delegators :remote, :fs
attr_reader :env, :arguments
def initialize(env, *arguments, negated: false)

View File

@ -3,7 +3,7 @@ module Producer
module Tests
class HasEnv < Test
def verify
env.remote.environment.key? arguments.first.to_s.upcase
remote.environment.key? arguments.first.to_s.upcase
end
end
end

View File

@ -3,7 +3,7 @@ module Producer
module Tests
class HasFile < Test
def verify
env.remote.fs.file? arguments.first
fs.file? arguments.first
end
end
end

View File

@ -2,7 +2,7 @@ require 'spec_helper'
module Producer::Core
describe Test do
let(:env) { double 'env' }
let(:env) { Env.new }
let(:arguments) { [:some, :arguments] }
subject(:test) { Test.new(env, *arguments) }
@ -34,6 +34,18 @@ module Producer::Core
end
end
describe '#remote' do
it 'returns env remote' do
expect(test.remote).to be test.env.remote
end
end
describe '#fs' do
it 'returns env remote fs' do
expect(test.fs).to be test.env.remote.fs
end
end
describe '#arguments' do
it 'returns the assigned arguments' do
expect(test.arguments).to eq arguments