Skip to content

Commit 3e8107e

Browse files
authored
Merge pull request #175 from DavidS/make-testing-order-random
(maint) make test order really random
2 parents a1d9de2 + 74559e0 commit 3e8107e

File tree

3 files changed

+28
-13
lines changed

3 files changed

+28
-13
lines changed

.rspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
--format documentation
22
--color
3-
--order rand:123
3+
--order rand

spec/puppet/resource_api/type_definition_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@
119119
Puppet.settings[:strict] = strict_level
120120
end
121121

122+
after(:each) do
123+
Puppet::ResourceApi.warning_count = 0
124+
end
125+
122126
context 'when puppet strict is set to default (warning)' do
123127
it 'displays up to 100 warnings' do
124128
expect(Puppet).to receive(:warning).with(message).exactly(100).times
@@ -156,6 +160,10 @@
156160
Puppet.settings[:strict] = strict_level
157161
end
158162

163+
after(:each) do
164+
Puppet::ResourceApi.warning_count = 0
165+
end
166+
159167
context 'when puppet strict is set to default (warning)' do
160168
it 'displays up to 100 warnings' do
161169
expect(Puppet).to receive(:warning).with(message).exactly(100).times

spec/puppet/resource_api_spec.rb

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,22 +1814,29 @@ def set(_context, changes) end
18141814
allow(provider_class).to receive(:new).and_return(provider)
18151815
end
18161816

1817+
after(:each) do
1818+
# reset cached provider between tests
1819+
type.instance_variable_set(:@my_provider, nil)
1820+
end
1821+
18171822
it { expect { described_class.register_type(definition) }.not_to raise_error }
18181823

1819-
it 'is seen as a supported feature' do
1820-
expect(Puppet).not_to receive(:warning).with(%r{Unknown feature detected:.*simple_test_filter})
1821-
expect { described_class.register_type(definition) }.not_to raise_error
1822-
end
1824+
context 'with the type registered' do
1825+
it 'is seen as a supported feature' do
1826+
expect(Puppet).not_to receive(:warning).with(%r{Unknown feature detected:.*simple_test_filter})
1827+
expect { described_class.register_type(definition) }.not_to raise_error
1828+
end
18231829

1824-
it 'passes through the an empty array to `get`' do
1825-
expect(provider).to receive(:get).with(anything, []).and_return([])
1826-
type.instances
1827-
end
1830+
it 'passes through the an empty array to `get`' do
1831+
expect(provider).to receive(:get).with(anything, []).and_return([])
1832+
type.instances
1833+
end
18281834

1829-
it 'passes through the resource title to `get`' do
1830-
instance = type.new(name: 'bar', ensure: 'present')
1831-
expect(provider).to receive(:get).with(anything, ['bar']).and_return([])
1832-
instance.retrieve
1835+
it 'passes through the resource title to `get`' do
1836+
instance = type.new(name: 'bar', ensure: 'present')
1837+
expect(provider).to receive(:get).with(anything, ['bar']).and_return([])
1838+
instance.retrieve
1839+
end
18331840
end
18341841
end
18351842

0 commit comments

Comments
 (0)