Module: KnowsAboutGrammaticalSubjects

Defined in:
lib/cucumber/blinkbox/subjects.rb

Overview

This module allows steps to set the subject of a scenario simply.

subject(:book, {"isbn" => "9780111222333"})
subject(:contributor, {"guid" => "abc123"})

p subject(:book)
# => {"isbn" => "9780111222333"}

It's really just a readable wrapper for a hash with some test specific exceptions and things

Constant Summary collapse

SUBJECTS =
{}
USING_SETTER =
:you_will_never_accidentally_pass_this

Instance Method Summary collapse

Instance Method Details

#subject(type, details = USING_SETTER) ⇒ Object


14
15
16
17
18
19
20
21
# File 'lib/cucumber/blinkbox/subjects.rb', line 14

def subject(type, details = USING_SETTER)
  if details == USING_SETTER
    raise "Test error: A #{type} subject hasn't been defined in this scenario yet." unless SUBJECTS[type]
    return SUBJECTS[type]
  else
    SUBJECTS[type] = details
  end
end