-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfeatures_spec.rb
More file actions
77 lines (70 loc) · 2.27 KB
/
features_spec.rb
File metadata and controls
77 lines (70 loc) · 2.27 KB
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
# frozen_string_literal: true
require_relative '../spec_helper'
module Smithy
module Client
describe Features do
it 'tracks and removes a feature' do
Features.track('A') { expect(Features.tracked).to eq(%w[A]) }
expect(Features.tracked).to be_empty
end
it 'tracks and removes multiple features' do
features = %w[A B C]
Features.track(*features) { expect(Features.tracked).to eq(features) }
expect(Features.tracked).to be_empty
end
it 'tracks and removes features in stack order' do
Features.track('A') do
expect(Features.tracked).to eq(%w[A])
Features.track('B') do
expect(Features.tracked).to eq(%w[A B])
Features.track('C') do
expect(Features.tracked).to eq(%w[A B C])
end
expect(Features.tracked).to eq(%w[A B])
end
expect(Features.tracked).to eq(%w[A])
end
expect(Features.tracked).to be_empty
end
it 'ensures that features are removed' do
begin
Features.track('A') do
expect(Features.tracked).to eq(%w[A])
raise StandardError
end
rescue StandardError
# ignore
end
expect(Features.tracked).to be_empty
end
it 'tracks features in multiple threads' do
Features.track('A') do
expect(Features.tracked).to eq(%w[A])
Thread.new do
expect(Features.tracked).to be_empty
Features.track('B') do
expect(Features.tracked).to eq(%w[B])
end
expect(Features.tracked).to be_empty
end.join
expect(Features.tracked).to eq(%w[A])
end
expect(Features.tracked).to be_empty
end
it 'does not track duplicate features' do
Features.track('A') do
expect(Features.tracked).to eq(%w[A])
Features.track('B') do
expect(Features.tracked).to eq(%w[A B])
Features.track('A') do
expect(Features.tracked).to eq(%w[A B])
end
expect(Features.tracked).to eq(%w[A B])
end
expect(Features.tracked).to eq(%w[A])
end
expect(Features.tracked).to be_empty
end
end
end
end