You repeat this line several times. Maybe do something like Chef::Nexus.assert_nexus_available(node) and it does this