{"id":18318408,"url":"https://github.com/tether/analytics-ruby-mock","last_synced_at":"2025-04-09T13:54:02.962Z","repository":{"id":10730565,"uuid":"12984293","full_name":"tether/analytics-ruby-mock","owner":"tether","description":"Capture all calls to segment.io and prevent them from being sent","archived":false,"fork":false,"pushed_at":"2015-07-15T10:38:59.000Z","size":230,"stargazers_count":1,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-03-14T23:06:55.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tether.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2013-09-20T21:31:19.000Z","updated_at":"2017-06-23T21:44:08.000Z","dependencies_parsed_at":"2022-09-22T21:41:17.580Z","dependency_job_id":null,"html_url":"https://github.com/tether/analytics-ruby-mock","commit_stats":null,"previous_names":["petrofeed/analytics-ruby-mock"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tether%2Fanalytics-ruby-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tether%2Fanalytics-ruby-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tether%2Fanalytics-ruby-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tether%2Fanalytics-ruby-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tether","download_url":"https://codeload.github.com/tether/analytics-ruby-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198472,"owners_count":20900082,"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-11-05T18:09:31.173Z","updated_at":"2025-04-09T13:54:02.942Z","avatar_url":"https://github.com/tether.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"analytics-ruby-mock\n===================\n\nCapture all calls to Segment.io and prevent them from going to the server. Great for keeping your tests connection free!\n\nInstallation\n----\n\n```\ngem install analytics_ruby_mock\n```\n\nUsage\n----\n\nAdd `analytics_ruby_mock` to your gemfile:\n\n```ruby\ngem 'analytics_ruby_mock', group: :test\n```\n\nRequire analytics_ruby_mock in your `spec_helper`:\n\n```ruby\nrequire 'analytics_ruby_mock'\n```\n\nThat's it!\n\nAsserting on Analytics\n----\n\nAnalytics Ruby Mock provides you with the ability to test whether an Analytics call has occurred during your tests.\nThe following accessors are available for you to check against: `track_calls`, `identify_calls`, and `alias_calls`.\nAll 3 methods collect the options passed to their respective calls and holds them in an array. Here's an example usage:\n\n```ruby\ndescribe 'show' do\n  before :each do\n    get :show, id: @company.id\n  end\n\n  it \"calls track for analytics\" do\n    Analytics.track_calls.should == [\n      { event: '...', properties: '...' }\n    ]\n  end\nend\n```\n\nThere's an additional helper for `tracked_events`. It provides an array of any `event` option that occurred during a track\nrequest _(this only applies to `track`, and not `identify` or `alias`)_\n\n```ruby\nit \"records 'User Viewed Company Page' as an event\" do\n  Analtics.track(event: 'User Viewed Company Page')\n  Analytics.tracked_events.should == ['User Viewed Company Page']\nend\n```\n\nYou'll need to clear the collected data at the end of your tests. You can do that by calling `Analytics.clear`. We\nkeep that call in our `spec_helper`:\n\n```ruby\nconfig.after(:each) do\n  Analytics.clear\nend\n```\n\n_Future plans would be to move that into a session so that the `clear` could be removed._\n\nDebugging\n----\n\nIf you'd like to see your calls output to console call the `debug` method:\n\n```ruby\nAnalytics.debug\n```\n\nYou'll get an output message any time a method on Analytics is called.\n\n===\n\nProudly brought to you by [PetroFeed](http://PetroFeed.com). Pull requests and issues always welcome. :kissing_heart:\n\n\n![Pedro](https://www.petrofeed.com/img/company/pedro.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftether%2Fanalytics-ruby-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftether%2Fanalytics-ruby-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftether%2Fanalytics-ruby-mock/lists"}