Coder Social home page Coder Social logo

murcielago17 / testing_inventory Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sf-wdi-24/testing_inventory

0.0 2.0 0.0 42 KB

Practice TDD in Rails by implementing an inventory management app

Ruby 84.68% JavaScript 1.58% CSS 1.69% HTML 12.05%

testing_inventory's Introduction

Testing Inventory

Objective: Use TDD in Rails to create an inventory management application. Your goal is to write code to pass the tests.

Getting Started

  1. Fork this repo, and clone it into your develop folder on your local machine.
  2. Run bundle install to install gems.
  3. Run rake db:create db:migrate to create and migrate the database.
  4. Start your Rails server.
  5. Run rspec in the Terminal. You should see an angry error message. Your job is to fix it!

Part 1: Products

  • The failing specs are for a ProductsController. For the first part of this lab, implement the functionality for the ProductsController to pass the tests. Some tips:
    • Read the errors carefully. They will guide you as to what to do next.
    • Once you've gotten past the initial setup errors, and you have failing specs printing out in the Terminal, it may help to comment-out some of the specs to narrow in on what you're working on. Comment them back in when you're ready to work on them.
  • You DON'T need to implement fully-functioning views, but you can if you want to.
  • Once you have all the specs passing for the ProductsController, it's time to implement a unit test for products:
    • Products should have an instance method called #margin that calculates the retail margin.
    • Write the spec for #margin before implementing the method!
    • Hint: rails g rspec:model product

Feel free to reference the solution branch for guidance.

Part 2: Items

  • A product should have many items. Use TDD to guide your implementation of CRUD for items. Follow the examples in spec/controllers/products_controller_spec.rb as a guide for testing your ItemsController.
  • Items should have a minimum of three attributes: size, color, and status. Validate these three attributes for presence.
  • Items routes should be nested under products routes. See the Rails docs for nested resources.
  • Your ItemsController doesn't need an #index method, since your app should display all of a product's items on the products#show page. However, it should have the other six methods for RESTful routes (#new, #create, #show, #edit, #update, and #destroy).
  • You DON'T need to implement fully-functioning views, but you can if you want to.
  • Take advantage of the factory_girl_rails and ffaker gems to define an item factory to use in your tests.
  • Once you have passing specs for your ItemsController, it's time for another unit test:
    • Products should have an instance method called #sell_through that calculates the sell-through rate (items sold / total items).
    • Write the spec for #sell_through before implementing the method!

Feel free to reference the solution_items branch for guidance.

Resources

testing_inventory's People

Contributors

cameronjacoby avatar

Watchers

James Cloos avatar  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.