class JobSpec::AdhocExpectations
Public Class Methods
clear!()
click to toggle source
# File lib/job_spec/adhoc_expectations.rb, line 3 def self.clear! @expectations = nil end
define(expectation, &block)
click to toggle source
# File lib/job_spec/adhoc_expectations.rb, line 7 def self.define(expectation, &block) @expectations ||= [] @expectations << new(expectation, &block) end
new(expectation, &block)
click to toggle source
# File lib/job_spec/adhoc_expectations.rb, line 32 def initialize(expectation, &block) @expectation = expectation @block = block instance_eval(&block) unless block.nil? end
roles()
click to toggle source
# File lib/job_spec/adhoc_expectations.rb, line 12 def self.roles return [] if @expectations.nil? roles = {} @expectations.each do |expectation| expectation.to_a.each do |role_expectation| roles[role_expectation[:role]] ||= { name: role_expectation[:role], expectations: [] } roles[role_expectation[:role]][:expectations] << { expectation: role_expectation[:expectation], description: role_expectation[:description] } end end roles.values end
Public Instance Methods
description(description)
click to toggle source
# File lib/job_spec/adhoc_expectations.rb, line 38 def description(description) @description = description end
roles(*roles)
click to toggle source
# File lib/job_spec/adhoc_expectations.rb, line 42 def roles(*roles) @roles = roles end
to_a()
click to toggle source
# File lib/job_spec/adhoc_expectations.rb, line 46 def to_a @roles.map do |role| { role: role, expectation: @expectation, description: @description } end end