From 82f8eac319222695e5b212858bb65cea9377adb9 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Mon, 20 Jan 2014 02:00:24 +0000 Subject: [PATCH] Improve Test spec: * Use attributes readers instead of instance_eval; * Refactor. --- spec/producer/core/test_spec.rb | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/spec/producer/core/test_spec.rb b/spec/producer/core/test_spec.rb index 94afd8e..7d09295 100644 --- a/spec/producer/core/test_spec.rb +++ b/spec/producer/core/test_spec.rb @@ -8,32 +8,26 @@ module Producer::Core describe '#initialize' do it 'assigns the env' do - expect(test.instance_eval { @env }).to be env + expect(test.env).to be env end it 'assigns the arguments' do - expect(test.instance_eval { @arguments }).to eq arguments + expect(test.arguments).to eq arguments end it 'assigns negated as false by default' do - expect(test.instance_eval { @negated }).to be false + expect(test).to_not be_negated end context 'when negated option is true' do - subject(:test) { Test.new(env, *arguments, negated: true) } + subject(:test) { described_class.new(env, *arguments, negated: true) } it 'assigns negated as true' do - expect(test.instance_eval { @negated }).to be true + expect(test).to be_negated end end end - describe '#env' do - it 'returns the assigned env' do - expect(test.env).to be env - end - end - describe '#remote' do it 'returns env remote' do expect(test.remote).to be test.env.remote @@ -46,19 +40,13 @@ module Producer::Core end end - describe '#arguments' do - it 'returns the assigned arguments' do - expect(test.arguments).to eq arguments - end - end - describe '#negated?' do it 'returns false' do expect(test.negated?).to be false end context 'when test is negated' do - subject(:test) { Test.new(env, *arguments, negated: true) } + subject(:test) { described_class.new(env, *arguments, negated: true) } it 'returns true' do expect(test.negated?).to be true @@ -78,7 +66,7 @@ module Producer::Core end context 'when test is negated' do - subject(:test) { Test.new(env, *arguments, negated: true) } + subject(:test) { described_class.new(env, *arguments, negated: true) } it 'returns false when #verify is true' do allow(test).to receive(:verify) { true }