Skip to content

Instantly share code, notes, and snippets.

@ch1ago
Last active September 22, 2015 21:10
Show Gist options
  • Save ch1ago/d9793819744210e25a80 to your computer and use it in GitHub Desktop.
Save ch1ago/d9793819744210e25a80 to your computer and use it in GitHub Desktop.
require 'spec_helper'
RSpec.describe Ticketing::ValueObjects::Coupon do
describe "Instance Methods" do
# subject do
# # Given a VO
# Ticketing::ValueObjects::Coupon.new
# end
describe "#valid?" do
describe "is false" do
it "when unlimited_use? is false" do
# When
allow(subject).to receive(:unlimited_use?).and_return(false)
# Then
expect(subject.valid?).to be_falsey
end
end
describe "is true" do
it "by default" do
# When
end
it "when unlimited_use? is true" do
# When
allow(subject).to receive(:unlimited_use?).and_return(true)
end
it "when uses_remaining is > 0" do
# When
allow(subject).to receive(:uses_remaining).and_return(5)
end
after do
# Then
expect(subject.valid?).to be_truthy
end
end
end
end
end
RSpec.describe Ticketing::ValueObjects::CouponEffect do
describe "Instance Methods" do
describe "#valid_redeemable_and_timed?" do
describe "is false" do
it "by default" do
# When
# - this is a blank line
end
it "when valid? is true" do
# When
allow(subject).to receive(:valid?).and_return(true)
end
it "when redeemable? is true" do
# When
allow(subject).to receive(:redeemable?).and_return(true)
end
it "when timed? is true" do
# When
allow(subject).to receive(:timed?).and_return(true)
end
after do
# Then
expect(subject.valid_redeemable_and_timed?).to be_falsey
end
end
it "is true" do
it "when valid, redeemable & timed? are true" do
# When
allow(subject).to receive(:valid? ).and_return(true)
allow(subject).to receive(:redeemable?).and_return(true)
allow(subject).to receive(:timed? ).and_return(true)
# Then
expect(subject.valid_redeemable_and_timed?).to be_truthy
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment