Example #1
0
		Context("with a percentage", func() {
			BeforeEach(func() {
				str = "Are you 100% sure?"
			})

			It("should include the trailing percentage", func() {
				Expect(question.Positions).To(Equal([]int{8, 11}))
			})
		})
	})

	Describe("Accessing answers", func() {
		var question Question
		BeforeEach(func() {
			question = fixtures.Question()
		})

		It("should be able to return the first answer", func() {
			answer, err := question.FirstAnswer()
			Expect(err).ToNot(HaveOccurred())
			Expect(answer).To(Equal(Answer{
				Exact:     float64(26),
				Formatted: "26",
			}))
		})

		It("should be able to return the second answer", func() {
			answer, err := question.AnswerAt(19)
			Expect(err).ToNot(HaveOccurred())
			Expect(answer).To(Equal(Answer{
Example #2
0
func EqualMessage(cmp match.Message) types.GomegaMatcher {
	return WithTransform(func(m match.Message) match.Message {
		if m.MatchState != nil {
			m.MatchState.PhaseMsLeft = 0
		}
		return m
	}, Equal(cmp))
}

var _ = Describe("Match Phases", func() {
	var clients []*client.Client
	var matchID string
	var nextMatchID int

	questions := []models.Question{
		fixtures.Question(),
	}

	// Each run should have a unique match id
	BeforeEach(func() {
		nextMatchID++
		matchID = strconv.Itoa(nextMatchID)
		server.AddMatch(matchID, server.MatchSize, questions)

		clients = make([]*client.Client, server.MatchSize)
		for i := 0; i < server.MatchSize; i++ {
			clients[i] = client.NewClient(strconv.Itoa(i))
		}
	})

	connect := func(cs ...*client.Client) {