Refactored rspec tests to use shared_examples_for.