Sha256: 3b913477c5db3516358e9a6b263ae0cc98567ae632feefffce7a5f340a6ab686
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
module JobSpec class AdhocExpectations def self.clear! @expectations = nil end def self.define(expectation, &block) @expectations ||= [] @expectations << new(expectation, &block) end def self.roles 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 def initialize(expectation, &block) @expectation = expectation @block = block instance_eval(&block) unless block.nil? end def description(description) @description = description end def roles(*roles) @roles = roles end def to_a @roles.map do |role| { role: role, expectation: @expectation, description: @description } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
job_spec-0.3.0 | lib/job_spec/adhoc_expectations.rb |