Skip to content

Instantly share code, notes, and snippets.

@robmiller
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robmiller/11194161 to your computer and use it in GitHub Desktop.
Save robmiller/11194161 to your computer and use it in GitHub Desktop.
mutant exception example
# foo.rb
def foo
@db = PStore.new(data_file)
rescue PStore::Error
raise DatabaseError.new("Database directory #{data_file} does not exist")
end
# foo_spec.rb
describe "#foo" do
it "should raise an error when database directory is inaccessible" do
expect { Database.new(nonexistent_dir) }.to raise_error(DatabaseError,
"Database directory #{nonexistent_dir} does not exist")
end
end
-rescue PStore::Error
+rescue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment