Test File Structure
With Rakefile generated by serverspec-init, test files must be placed under the directory which name matches the target host name like this. (You can customize this structure by editing Rakefile and spec_helper.rb as you like.)
Test file structure would be like this.
require 'spec_helper' describe 'RESOURCE_NAME' do #TEST_YOU_WANT_TO_CHECK end
Serverspec provide many resource types. You can check yourself how to write rspec tests for each resource type as there are many you can test yourself.
bond | bridge | cgroup | command | cron | default_gateway | docker_container | docker_image | file | group | host | iis_app_pool | iis_website | interface | ip6tables | ipfilter | ipnat | iptables | kernel_module | linux_audit_system | linux_kernel_parameter | lxc | mail_alias | mysql_config | package | php_config | port | ppa | process | routing_table | selinux | selinux_module | service | user | x509_certificate | x509_private_key | windows_feature | windows_registry_key | yumrepo | zfs
For an example, I have write this rspec test to make sure mysql have been setup correctely and some user files and configurations are in place.
These rspec test can even be invoked through SSH on a remote server. On the inital setup of serverspec init we have to select SSH option and setup the remote host as the spec host to be used. for this server configurations have to be set in ~/.ssh/config accordingly.
I have serverspec-init a unix server named us-mc-staging which is in my ssh configuration and run the rake test of sample.rb and the console output is shown below