refactor rspec test code