A simple web application built with Ruby on Rails and ReactJS that calculates resistance, tolerance, minimum and maximum resistance based on the band colors of a 4-band resistor.
It is deployed on Heroku : safe-sands-64395.herokuapp.com/
I used the react-rails gem to include ReactJS in the project
These are the relevant files :
app/controllers/ohm_value_calculator_controller.rb app/models/color_code_calculator.rb config/routes.rb ohm-value-calculator/app/views/ohm_value_calculator/index.html.erb React components ohm-value-calculator/app/assets/javascripts/components/resistor.jsx ohm-value-calculator/app/assets/javascripts/components/resistorband.jsx The test file for the Rails model is here ohm-value-calculator/spec/models/color_code_calculator_spec.rb I have configured the model method so that when empty values are passed for any band color, the first one in the list is used as default to calculate resistance and other values. Hence the test checks the value of resistance when any bandcolor is nil/empty. It also checks as a positive test case the value when all band colors are passed in.