describe 'Gratan::Client#apply' do context 'when user does not exist' do subject { client } it do result = apply(subject) { '' } expect(result).to be_falsey expect(show_grants).to match_array [] end end context 'when create user with ignore_object' do subject { client(ignore_object: /test/) } it do result = apply(subject) { <<-RUBY user 'scott', 'localhost', identified: 'tiger' do on '*.*' do grant 'SELECT' grant 'INSERT' grant 'UPDATE' grant 'DELETE' end on 'test.*' do grant 'SELECT' grant 'INSERT' grant 'UPDATE' grant 'DELETE' end end RUBY } expect(result).to be_truthy expect(show_grants).to match_array [ "GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'scott'@'localhost' IDENTIFIED BY PASSWORD '*F2F68D0BB27A773C1D944270E5FAFED515A3FA40'", ].normalize end end context 'when create user with ignore_object (2)' do subject { client(ignore_object: /test2/) } it do result = apply(subject) { <<-RUBY user 'scott', 'localhost', identified: 'tiger' do on '*.*' do grant 'SELECT' grant 'INSERT' grant 'UPDATE' grant 'DELETE' end on 'test.*' do grant 'SELECT' grant 'INSERT' grant 'UPDATE' grant 'DELETE' end end RUBY } expect(result).to be_truthy expect(show_grants).to match_array [ "GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'scott'@'localhost' IDENTIFIED BY PASSWORD '*F2F68D0BB27A773C1D944270E5FAFED515A3FA40'", "GRANT SELECT, INSERT, UPDATE, DELETE ON `test`.* TO 'scott'@'localhost'", ].normalize end end end