refactor rspec code