Skip to content

krk324/wdi_2_ruby_lab_rspec_songs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 

Repository files navigation

SpecTunes

Using pair test-driven development with RSpec, create the following classes:

Track

  • Has a title, list of artists (order doesn't matter), duration, and price
  • Has a "set discount" method that reduces the price by a given percentage
  • Has a "reset discount" method that restores the price to its original value

Note: The "set discount" method should not return a discounted price – it should actually change the price of the track. If I create a track with price 1.0 and I call track.set_discount(0.2), subsequent calls to track.price should now return 0.8. If I apply another discount, it should replace the previous discount rather than stacking onto it.

Album

  • Has a title and a list of Track objects (order matters)
  • Has a duration (combined duration of all tracks)
  • Has a price (combined price of all tracks)
  • Has a list of artists (combined artists of all tracks in alphabetical order – no duplicates)
  • Can determine whether the album is a single (has exactly one track)

Next Steps

Still using test-driven development, add some data validation to these classes. For instance, I probably shouldn't be able to create an album with no tracks, or set a track's discount greater than 100%. Think of ways someone could abuse your code – what happens if I try to create a track with the "list of artists" set to 42? Generally it's appropriate to raise ArgumentError when your methods receive invalid data as an argument.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published