Skip to content

Instantly share code, notes, and snippets.

@nandokakimoto

nandokakimoto/plan_spec_bang.rb Secret

Last active Feb 1, 2017
Embed
What would you like to do?
blog-post-830-test-uses-bang
require 'rails_helper'
RSpec.describe Plan, type: :model do
describe ".price" do
let(:plan) { Plan.create!(name: 'basic') }
describe "has less than 2 members" do
let(:dan) { Member.create!(first_name: 'Daniel') }
let(:tom) { Member.create!(first_name: 'Thomas') }
it "should return base price when one member" do
plan.members << dan
expect(plan.price).to eql(20)
end
it "should return base price when two members" do
plan.members << dan
plan.members << tom
expect(plan.price).to eql(20)
end
end
describe "has more than two members" do
let(:joe) { Member.create!(first_name: 'Joe') }
let(:mary) { Member.create!(first_name: 'Mary') }
let(:sarah) { Member.create!(first_name: 'Sarah') }
it "should give 1 discount per additional user" do
plan.members << joe
plan.members << mary
plan.members << sarah
expect(plan.price).to eql(19)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment