Skip to content

Latest commit

 

History

History
16 lines (14 loc) · 1.35 KB

model_testing_rails.markdown

File metadata and controls

16 lines (14 loc) · 1.35 KB

Model Testing in Rails -- Challenges

Add tests for the following specifications and make them pass one at a time.

    1. A fan should not be valid without an email.
    1. A location is valid with a city, state, and country and should be invalid if they are missing a city, state, or country.
    1. A city must be unique within the scope of a state. For example, we can have Bloomington, IL, and Bloomington, IN, but we can't have two of Bloomington, IN.
    1. A state must be exactly two characters. Take a look at the documentation to figure out how to do exact length validations.
    1. Cities and countries may only contain uppercase letters, lowercase letters, and spaces.
    1. Donations must have an amount that can only be whole numbers. Take a look at the documentation for a built-in way to write this.
    1. A donations must have a status. Donation statuses can be "processed", "pending", or "cancelled". No other values should be allowed.
    1. Donations of 1 dollar are not allowed. Don't be cheap.
    1. When calling full_name on a location, it should return a string of the city, state, and country. (Example: location.full_name returns "Denver, CO, USA")
    1. A donation should belong to a fan.
    1. Fan.all should return all fans ordered alphabetically by name.
    1. Fan.joined_since(date) should return all the fans that have joined since that date.