use let instead of before

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
Dominik Richter 2015-09-03 10:12:20 +02:00
parent 199cb84ab3
commit 5ae3b13b38
2 changed files with 21 additions and 25 deletions

View file

@ -1,33 +1,30 @@
require 'helper'
describe 'Vulcano::Plugins::Backend::FileCommon' do
before do
@backend = Vulcano::Plugins::Backend::FileCommon
@test = @backend.new
end
let(:cls) { Vulcano::Plugins::Backend::FileCommon }
let(:backend) { cls.new }
it 'default type is :unkown' do
@test.type.must_equal :unknown
backend.type.must_equal :unknown
end
describe 'with non-empty content' do
before do
@content = 'Hello World'
@test = Class.new(@backend) do
let(:backend) {
Class.new(cls) do
def content; 'Hello World'; end
end.new
end
}
it 'must return raw content' do
@test.content.must_equal @content
backend.content.must_equal 'Hello World'
end
it 'must calculate the md5sum of content' do
@test.md5sum.must_equal 'b10a8db164e0754105b7a99be72e3fe5'
backend.md5sum.must_equal 'b10a8db164e0754105b7a99be72e3fe5'
end
it 'must calculate the sha256sum of content' do
@test.sha256sum.must_equal 'a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e'
backend.sha256sum.must_equal 'a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e'
end
end

View file

@ -1,42 +1,41 @@
require 'helper'
describe 'Vulcano::Plugins::Backend' do
before do
@backend = Vulcano::Plugins::Backend
@child = Class.new(@backend)
end
let(:cls) { Vulcano::Plugins::Backend }
let(:child) { Class.new(cls) }
it 'provides a name method for registering' do
@child.must_respond_to :name
child.must_respond_to :name
end
describe 'when registering a plugin' do
let(:registry) { Vulcano::Backend.registry }
before do
@child.name 'test'
@reg = Vulcano::Backend.registry
child.name 'test'
end
after do
@reg.delete('test')
registry.delete('test')
end
it 'must have the backend registered' do
@reg.keys.must_include 'test'
@reg['test'].must_equal @child
registry.keys.must_include 'test'
registry['test'].must_equal child
end
it 'must raise an error if file is not implemented' do
t = @reg['test'].new
t = registry['test'].new
proc { t.run_command }.must_raise NotImplementedError
end
it 'must raise an error if run_command is not implemented' do
t = @reg['test'].new
t = registry['test'].new
proc { t.file }.must_raise NotImplementedError
end
it 'must raise an error if os is not implemented' do
t = @reg['test'].new
t = registry['test'].new
proc { t.os }.must_raise NotImplementedError
end
end