forked from sous-chefs/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers_container_spec.rb
82 lines (66 loc) · 2.14 KB
/
helpers_container_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require 'rspec'
require 'rspec/its'
require_relative '../libraries/helpers_container'
class FakeContainerForTestingImageProperty
include DockerCookbook::DockerHelpers::Container
def initialize(attributes = {})
@attributes = attributes
end
def repo(value = nil)
attributes['repo'] = value if value
attributes['repo']
end
def tag(value = nil)
attributes['tag'] = value if value
attributes['tag'] || 'latest'
end
private
attr_reader :attributes
end
describe DockerCookbook::DockerHelpers::Container do
let(:helper) { FakeContainerForTestingImageProperty.new }
describe '#image' do
subject { helper }
context "If you say: repo 'blah'" do
before { helper.repo 'blah' }
its(:image) { is_expected.to eq('blah:latest') }
end
context "If you say: repo 'blah'; tag '3.1'" do
before do
helper.repo 'blah'
helper.tag '3.1'
end
its(:image) { is_expected.to eq('blah:3.1') }
end
context "If you say: image 'blah'" do
before { helper.image 'blah' }
its(:repo) { is_expected.to eq('blah') }
its(:tag) { is_expected.to eq('latest') }
end
context "If you say: image 'blah:3.1'" do
before { helper.image 'blah:3.1' }
its(:repo) { is_expected.to eq('blah') }
its(:tag) { is_expected.to eq('3.1') }
end
context "If you say: image 'repo/blah'" do
before { helper.image 'repo/blah' }
its(:repo) { is_expected.to eq('repo/blah') }
its(:tag) { is_expected.to eq('latest') }
end
context "If you say: image 'repo/blah:3.1'" do
before { helper.image 'repo/blah:3.1' }
its(:repo) { is_expected.to eq('repo/blah') }
its(:tag) { is_expected.to eq('3.1') }
end
context "If you say: image 'repo:1337/blah'" do
before { helper.image 'repo:1337/blah' }
its(:repo) { is_expected.to eq('repo:1337/blah') }
its(:tag) { is_expected.to eq('latest') }
end
context "If you say: image 'repo:1337/blah:3.1'" do
before { helper.image 'repo:1337/blah:3.1' }
its(:repo) { is_expected.to eq('repo:1337/blah') }
its(:tag) { is_expected.to eq('3.1') }
end
end
end