Giter Club home page Giter Club logo

tdd-spec-cleanup-exercise's Introduction

Fundamentals of TDD / Tdd Spec Cleanup Exercise

Hey there! We're thoughtbot, a design and development consultancy that brings your digital product ideas to life. We also love to share what we learn.

This coding exercise comes from Upcase, the online learning platform we run. It's part of the Fundamentals of TDD course and is just one small sample of all the great material available on Upcase, so be sure to visit and check out the rest.

Exercise Intro

Test code deserves the same care and effort as we put into writing our production code. In this exercise you'll take a messy test and refactor it to better capture the intent and tell a good story.

Instructions

To start, you'll want to clone and run the setup script for the repo

git clone [email protected]:thoughtbot-upcase-exercises/tdd-spec-cleanup-exercise.git
cd tdd-spec-cleanup-exercise
bin/setup

Your goal is to refactor the provided spec to help it tell a good story. Currently the spec makes heavy use of features like let and before, obscuring the behavior and assertions in each of the specs. Instead, we want each spec to stand on its own, telling a small clear story about the behavior of our model

  1. Edit the spec in spec/models/invitation_spec.rb.
  2. Refactor the spec, cleaning up and clarifying things without changing the test or model behavior
  3. As with any good refactoring, your tests should remain green throughout. Be sure to check with:
$ bin/rspec spec/models/invitation_spec.rb

Your goal is to refactor the specs in that file to clarify the behavior and tell a good story

  • Keep the 4 phase test model in mind (likely you'll only need 3 as tear down is automated)
  • Feel free to extract helper methods to abstract away details while keeping setup explicit to the spec

Tips and Tricks

Revisit the video on Telling a Story with Your Tests for tips on how to tackle this cleanup.

Forum Discussion

If you find yourself stuck, be sure to check out the associated Upcase Forum discussion for this exercise to see what other folks have said.

Next Steps

When you've finished the exercise, head on back to the Fundamentals of TDD course to find the next exercise, or explore any of the other great content on Upcase.

License

tdd-spec-cleanup-exercise is Copyright © 2015-2018 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the LICENSE file.

Credits

thoughtbot

This exercise is maintained and funded by thoughtbot, inc.

The names and logos for Upcase and thoughtbot are registered trademarks of thoughtbot, inc.

tdd-spec-cleanup-exercise's People

Contributors

geoffharcourt avatar christoomey avatar cfinn16 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.