Skip to content

Instantly share code, notes, and snippets.

@shepmaster
Created October 18, 2012 19:05
Show Gist options
  • Save shepmaster/3914134 to your computer and use it in GitHub Desktop.
Save shepmaster/3914134 to your computer and use it in GitHub Desktop.
PredictionGatekeeper
viewing predictions
a third party cannot see the prediction
before the prediction due date
the creator can reveal the prediction
the victim can only view prediction metadata
after the prediction due date
the creator can view the prediction
the victim can view the prediction
revealing predictions
the creator can reveal a prediction
anyone else cannot reveal a prediction
describe PredictionGatekeeper do
let(:creator) { Fabricate(:user, email: '[email protected]') }
let(:victim) { Fabricate(:user, email: '[email protected]') }
let(:prediction) { Fabricate(:prediction, creator: creator, victim: victim) }
let(:listener) { double("listener") }
before(:each) do
@gatekeeper = PredictionGatekeeper.new(prediction, listener)
end
context "viewing predictions" do
context "before the prediction due date" do
before(:each) { prediction.due_date = DateTime.now + 5.minutes }
it "the creator can reveal the prediction" do
listener.should_receive(:can_reveal_prediction)
@gatekeeper.may_view(creator)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment