GithubHelp home page GithubHelp logo

paulanthonywilson / cat_facts Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 9 KB

Example repo illustrating methods of injecting implementations into testing seams. Also fetches cat facts.

Elixir 99.32% Euphoria 0.68%

cat_facts's Introduction

CatFacts

Uses the Cat Facts API to illustrate different approaches to creating a Mox style testing seam. See the accompanying blog post here

CatFacts.CatFactsApi is a behaviour and testing seam for extracting Cat Facts from Cat Facts API. It is implemented by CatFacts.RealCatFactsApi and mocked by MockCatFactsApi.

Various versions can be seen with the following tags.

  • initial_standard_moxing - the private function CatFacts.CatFactsApi.cat_facts_api/0 reads application config to return the implementation. This is the normal way of doing things.
  • accidental_behaviour_tag_deletion - a version in which I "accidentally" forgot to add @behaviour CatFacts.CatFactsApi to CatFacts.RealCatFactsApi. An ommission which will cause problems later.
  • rename_but_omit_implementation - CatFacts.CatFactsApi.get_cat_facts/0 has been renamed to CatFacts.fetch_fun_feline_facts/0. Thet tests are passing but I "forgot" to rename the function in CatFacts.RealCatFactsApi.
  • alternate_implementation_injection - inject the mock or real implementaton using alias. Still broken but compilation and dialyzer now gives warnings.
  • final_working - all working fine again, with the new function name (and the @behaviour restored).

cat_facts's People

Contributors

paulanthonywilson avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.