Skip to content

Commit

Permalink
Merge pull request #92 from da-ar/parallel_rspec
Browse files Browse the repository at this point in the history
Enable randomised rspec testing
  • Loading branch information
DavidS authored Jun 11, 2018
2 parents aab421e + d24b160 commit 63e9d46
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
--format documentation
--color
--order rand:123
21 changes: 14 additions & 7 deletions spec/puppet/resource_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1211,8 +1211,7 @@ def set(_context, changes)
context 'when flushing' do
before(:each) do
Puppet.debug = true
instance.flush
puts log_sink(&:message).inspect
instance.my_provider.set(nil, nil) # reset the current_state
end

after(:each) do
Expand All @@ -1221,19 +1220,27 @@ def set(_context, changes)

context 'with no changes' do
it('set will not be called') do
instance.flush

expect(instance.my_provider.last_changes).to be_nil
expect(log_sink.last.message).to eq('Current State: {:name=>"somename", :test_string=>"canonfoo"}')
end
end

context 'with a change' do
let(:test_string) { 'bar' }
let(:run_one) { type.new(name: 'somename', test_string: 'foo') }
let(:run_two) { type.new(name: 'somename', test_string: 'bar') }

before(:each) do
run_one.flush
run_two.flush
end

it('set will be called with the correct structure') do
expect(instance.my_provider.last_changes).to eq('somename' => {
is: { name: 'somename', test_string: 'canonfoo' },
should: { name: 'somename', test_string: 'canonbar' },
})
expect(run_two.my_provider.last_changes).to eq('somename' => {
is: { name: 'somename', test_string: 'canonfoo' },
should: { name: 'somename', test_string: 'canonbar' },
})
end

it 'logs correctly' do
Expand Down

0 comments on commit 63e9d46

Please sign in to comment.