{"id":13462976,"url":"https://github.com/lkdjiin/coco","last_synced_at":"2025-03-25T06:31:27.484Z","repository":{"id":1394965,"uuid":"1397294","full_name":"lkdjiin/coco","owner":"lkdjiin","description":"Code coverage for ruby 2.x","archived":false,"fork":false,"pushed_at":"2018-10-12T10:02:37.000Z","size":604,"stargazers_count":70,"open_issues_count":8,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-04T21:17:45.876Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://lkdjiin.github.com/coco/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"dan335/dominus","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lkdjiin.png","metadata":{"files":{"readme":"README.markdown","changelog":"Changelog.markdown","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-02-22T11:37:59.000Z","updated_at":"2022-02-10T02:58:11.000Z","dependencies_parsed_at":"2022-07-07T11:04:59.963Z","dependency_job_id":null,"html_url":"https://github.com/lkdjiin/coco","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lkdjiin%2Fcoco","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lkdjiin%2Fcoco/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lkdjiin%2Fcoco/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lkdjiin%2Fcoco/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lkdjiin","download_url":"https://codeload.github.com/lkdjiin/coco/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245413796,"owners_count":20611353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T13:00:43.070Z","updated_at":"2025-03-25T06:31:27.096Z","avatar_url":"https://github.com/lkdjiin.png","language":"Ruby","readme":"coco [![Build Status](https://travis-ci.org/lkdjiin/coco.png)](https://travis-ci.org/lkdjiin/coco) [![Gem Version](https://badge.fury.io/rb/coco.png)](http://badge.fury.io/rb/coco) [![Inline docs](http://inch-ci.org/github/lkdjiin/coco.png)](http://inch-ci.org/github/lkdjiin/coco) [![Dependency Status](https://gemnasium.com/lkdjiin/coco.svg)](https://gemnasium.com/lkdjiin/coco)\n==============================\n\n— *«If it's well-covered it doesn't mean it's well-tested!»* —\n\n# Code coverage tool for ruby 2.x\n\n## Install\n\nIn your Gemfile:\n\n    gem 'coco'\n\nOr directly:\n\n    gem install coco\n\n*NOTE: If you're using a Gemfile, don't `:require =\u003e false`*\n\nAnd in case you want to test the latest development:\n\n    gem 'coco', github: 'lkdjiin/coco', branch: 'development'\n\n## Usage\nRequire the coco library at the beginning of your tests:\n\n    require 'coco'\n\nUsually you do this only once, by putting this line in an spec_helper.rb,\nor test_helper.rb (or whatever you named it).\n\n### View report\n\nAfter your tests, coco will display a **very** short report in the console\nwindow, like this one:\n\n    $ rake test\n    [...]\n    26 examples, 0 failures\n\n    Rate 82% | Uncovered 0 | Files 7\n    $\n\ncoco will also create a `coverage/` folder at the root of the project. Browse\nthe `coverage/index.html` to access a line by line report.\n\n_Note: files with a coverage of 0% are only listed in index.html ; there\nis no line by line report for such files._\n\n## Basic Configuration\n\nConfiguration is done via a YAML file. You can configure:\n\n* __theme__: Choose between a light and a dark theme for the HTML report\n* __threshold__: the percentage threshold\n* __include__: the directories from where coco will search for untested source files\n* __exclude__: a list of files and/or directories to exclude from the report, if any\n* __single_line_report__: style of the report in the console\n\nBy default, threshold is set to 100, the list of directories is set to `['lib']`,\nno files are excluded and the console report is a single line one.\n\nTo change this default configuration, put a `.coco.yml` file at the root of your project.\n\n### Theme\n\nYou can choose between a light and a dark theme. The light theme is the\ndefault one. For a dark theme, add this line in the configuration file:\n\n    :theme: dark\n\n**Light theme**\n\n![light](theme-light.png)\n\n**Dark theme**\n\n![dark](theme-dark.png)\n\n### Threshold\n\nAdd the following line to your .coco.yml file to set the threshold to 80%.\n\n    :threshold: 80\n\nOnly files under 80% of coverage will be directly reported in the report.\nI strongly advice to use the default threshold (100%).\n\n### Directories Included\n\nAdd the following lines to your .coco.yml file to set the directories to both\n'lib' and “ext':\n\n    :include: \n    - lib\n    - ext\n\n### Files and Directories Excludes\n\nAdd the following lines to your .coco.yml file to exclude a file from the\nreport:\n\n    :exclude:\n    - lib/project/file1.rb\n\nAdd the following lines to your .coco.yml file to exclude a whole folder's\ncontent from the report:\n\n    :exclude:\n    - config/initializers\n\nOf course you can mix files and folders:\n\n    :exclude:\n    - path/to/file1\n    - path/to/file2\n    - folder1\n    - path/to/folder2\n\n### Single line report\n\nBy default, the console's reports a brief, one line, summary. If instead, you\nwant to display the coverage of all files under the threeshold, put this line\nin your .coco.yml file:\n\n    :single_line_report: false\n\nAdvice: Don't do this!\n\n## Sample config for a Rails project\n\n    :include: \n    - app\n    - custom_dir\n    - lib\n    :exclude:\n    - config/initializers\n\n_Note: YAML is very punctilious with the syntax. In particular, paid attention\nto not put any leading spaces or tab at all._\n\n\n## Advanced configuration\n\n### When to start coco, and when not to start it\n\nFor projects whose complete test suite runs in a matter of seconds, running\ncode coverage with every test is fine.  But when the test suite takes longer to\ncomplete, we typically start to run a single test more often than the complete\nsuite. In such cases, the behavior of Coco could be really annoying: you\nrun a single test and Coco reports a infinite list of uncovered files. The\nproblem here is this is a lie. To avoid this behavior, I recommend to run code\ncoverage only from time to time, and with the entire test suite. To do so,\nCoco provide the following configuration key:\n\n__always_run__: If true, Coco will run every time you start a test.\nIf false, Coco will run only when you explicitly set an\nenvironement variable named `COCO` with something other than `false`,\n`0` or the empty string.\n\n#### Example\n\nPut this in your `.coco.yml` configuration file:\n\n    :always_run: false\n\nNow, when you run:\n\n    rspec\n\n…Coco will no start. To start it, you have to set the\nenvironement variable `COCO`, like this:\n\n    COCO=1 rspec\n\n### Premature exit if coverage is under a particular threshold\n\nIf you're using some kind of continuous integration, there is some chance you\nwould like the build to fail if the coverage is under a particular threshold.\nIn such case you want to set the `exit_if_coverage_below` option.\n\n#### Example\n\nPut this in your `.coco.yml` configuration file:\n\n    :exit_if_coverage_below: 95\n\nThis will make coco fail if the coverage percentage is below 95%.\n\n### Change the output directory\n\nThe HTML output goes into a folder named `coverage`. This is fine 99.9% of the\ntime. For the remaining 0.1% this is customisable.\n\n#### Example\n\nPut this in your `.coco.yml` configuration file:\n\n    :output_directory: 'code_coverage'\n\nOr even outside of the current folder if you need to :\n\n    :output_directory: '../outside/coverage'\n\n### See coverage of all files in the console\n\nBy default, with a multilines report style on the console, Coco will display\nonly the files with a coverage above the threshold. And as the threshold is\n100% by default, nothing will be displayed if your test suite is 100% covered.\nThis could be annoying for some people, or worst, you could even feel like Coco\ndoing something the wrong way.\n\nSo, to display in green the covered files, put this in your `.coco.yml`\nconfiguration file:\n\n    :exclude_above_threshold: false\n\n### Index page URI in your terminal\n\nIf your terminal supports opening an URI with a double-clic (or any\nother method), you may want to display the URI of the report's index\npage. For that, you have to set the __show_link_in_terminal__ key.\n\n#### Example\n\nPut this in your `.coco.yml` configuration file:\n\n    :show_link_in_terminal: true\n\nNow, when running tests, you will see something like the following:\n\n    $ rspec spec\n    .............\n    [...]\n\n    97% /path/to/bad/tested/file.rb\n    See file:///path/to/your/coverage/index.html\n\n\n## How is this different than [SimpleCov](https://github.com/colszowka/simplecov) ?\n\nI designed Coco from the start to have only the features I need. And I don't\nneed much: 95% of the time, all I want is a tiny one line summary in my console.\n\nIt's easier. Add a single line of code at the start of your spec helper and\nyou are good to go.\n\nIt's faster. Because Coco has no dependencies and less features, analyzing and\nreporting are so fast you don't even notice them.\n\nTo synthesize, if you have big needs, give SimpleCov a try ; if you have small\nneeds, give Coco a try.\n\n\n## Contributing\n\n1. Fork it.\n2. Create your feature branch\n   - `git pull origin master`\n   - `git checkout -b my-new-feature`\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a Pull Request.\n\n\n## License\nMIT, see LICENSE.\n\n\n## Questions and/or Comments\n\nFeel free to email [Xavier Nayrac](mailto:xavier.nayrac@gmail.com)\nwith any questions, or contact me on [twitter](https://twitter.com/lkdjiin).\n\n","funding_links":[],"categories":["Code Quality"],"sub_categories":["Code Metrics"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flkdjiin%2Fcoco","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flkdjiin%2Fcoco","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flkdjiin%2Fcoco/lists"}