Optimized a Rspec code