From b2f75dd907d46c2f5bac7d212eb9c0eee999605c Mon Sep 17 00:00:00 2001 From: Rishabh Saxena Date: Thu, 18 Aug 2016 23:22:46 +0530 Subject: [PATCH] spec/tickets: add tests for free ticket creation --- spec/features/tickets_spec.rb | 4 ++-- spec/models/ticket_spec.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/features/tickets_spec.rb b/spec/features/tickets_spec.rb index 3a40f537..ab872196 100644 --- a/spec/features/tickets_spec.rb +++ b/spec/features/tickets_spec.rb @@ -35,7 +35,7 @@ feature Ticket do fill_in 'ticket_price', with: '-1' click_button 'Create Ticket' - expect(flash).to eq("Creating Ticket failed: Title can't be blank. Price cents must be greater than 0.") + expect(flash).to eq("Creating Ticket failed: Title can't be blank. Price cents must be greater than or equal to 0.") expect(Ticket.count).to eq(0) end @@ -72,7 +72,7 @@ feature Ticket do # It's necessary to multiply by 100 because the price is in cents expect(ticket.price).to eq(Money.new(100 * 100, 'USD')) expect(ticket.title).to eq('Business Ticket') - expect(flash).to eq("Ticket update failed: Title can't be blank. Price cents must be greater than 0.") + expect(flash).to eq("Ticket update failed: Title can't be blank. Price cents must be greater than or equal to 0.") expect(Ticket.count).to eq(1) end diff --git a/spec/models/ticket_spec.rb b/spec/models/ticket_spec.rb index 631ca59a..70aa80d1 100644 --- a/spec/models/ticket_spec.rb +++ b/spec/models/ticket_spec.rb @@ -22,14 +22,14 @@ describe Ticket do should validate_presence_of(:price_currency) end - it 'is not valid with a price_cents equals zero' do - should_not allow_value(0).for(:price_cents) - end - it 'is not valid with a price_cents smaller than zero' do should_not allow_value(-1).for(:price_cents) end + it 'is valid with a price_cents equals zero' do + should allow_value(0).for(:price_cents) + end + it 'is valid with a price_cents greater than zero' do should allow_value(1).for(:price_cents) end