it'should recognize when all priviliges are set'do
provider_class.expects(:mysql).with('mysql','-Be','select * from user where user="user" and host="host"').returns<<-EOT
HostUserPasswordSelect_privInsert_privUpdate_priv
hostuserYYY
EOT
@provider.all_privs_set?.should==true
end
it'should recognize when all privileges are not set'do
provider_class.expects(:mysql).with('mysql','-Be','select * from user where user="user" and host="host"').returns<<-EOT
HostUserPasswordSelect_privInsert_privUpdate_priv
hostuserYNY
EOT
@provider.all_privs_set?.should==false
end
it'should be able to set all privileges'do
provider_class.expects(:mysql).with('mysql','-NBe','SELECT "1" FROM user WHERE user = \'user\' AND host = \'host\'').returns"1\n"
provider_class.expects(:mysql).with('mysql','-Be',"update user set Select_priv = 'Y', Insert_priv = 'Y', Update_priv = 'Y' where user=\"user\" and host=\"host\"")
provider_class.expects(:mysql).with('mysql','-NBe','SELECT "1" FROM user WHERE user = \'user\' AND host = \'host\'').returns"1\n"
provider_class.expects(:mysql).with('mysql','-Be',"update user set Select_priv = 'Y', Insert_priv = 'N', Update_priv = 'Y' where user=\"user\" and host=\"host\"")
provider_class.expects(:mysql).with('mysql','-NBe','SELECT "1" FROM user WHERE user = \'user\' AND host = \'host\'').returns"1\n"
provider_class.expects(:mysql).with('mysql','-Be',"update user set Select_priv = 'Y', Insert_priv = 'Y', Update_priv = 'Y' where user=\"user\" and host=\"host\"")