Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ gem 'puma', '~> 3.7'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'pry-rails'
end

group :development do
Expand Down
2 changes: 2 additions & 0 deletions app/models/customer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
class Customer < ApplicationRecord
has_many :rentals

validates :name, presence: true
end
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html

end
26 changes: 23 additions & 3 deletions test/models/customer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,27 @@
describe Customer do
let(:customer) { Customer.new }

it "must be valid" do
value(customer).must_be :valid?
end
describe "validations" do
it "can be created if all fields are provided" do
start_count = Customer.count
c = Customer.new(name: "Tamira", registered_at: "Date registered", address: "An address", city: "Seattle", state: "WA", postal_code: "zip", phone: "111111111", account_credit: 15.50)

c.must_be :valid?

c.save
Customer.count.must_equal start_count + 1
end # can be created

it "can't be created without a title" do
start_count = Customer.count
c = Customer.new(registered_at: "Date registered", address: "An address", city: "Seattle", state: "WA", postal_code: "zip", phone: "111111111", account_credit: 15.50)

c.wont_be :valid?

# can't be saved because it isn't valid
c.save
Customer.count.must_equal start_count

end
end # validations
end
4 changes: 0 additions & 4 deletions test/models/rental_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
require "test_helper"

describe Rental do
let(:rental) { Rental.new }

it "must be valid" do
value(rental).must_be :valid?
end
end