Class: JobSpec::Role
- Inherits:
-
Object
- Object
- JobSpec::Role
- Defined in:
- lib/job_spec.rb
Defined Under Namespace
Classes: Expectations
Class Method Summary collapse
Instance Method Summary collapse
- #expected(expectation) ⇒ Object
- #include(role_expectations) ⇒ Object
-
#initialize(name, &block) ⇒ Role
constructor
A new instance of Role.
- #salary(range = nil) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ Role
Returns a new instance of Role.
12 13 14 15 16 |
# File 'lib/job_spec.rb', line 12 def initialize(name, &block) @name = name @expectations = [] instance_eval(&block) if block_given? end |
Class Method Details
.definition(name, &block) ⇒ Object
3 4 5 6 |
# File 'lib/job_spec.rb', line 3 def self.definition(name, &block) @definitions ||= [] @definitions << new(name, &block) end |
.definitions ⇒ Object
8 9 10 |
# File 'lib/job_spec.rb', line 8 def self.definitions @definitions end |
Instance Method Details
#expected(expectation) ⇒ Object
26 27 28 |
# File 'lib/job_spec.rb', line 26 def expected(expectation) @expectations << expectation end |
#include(role_expectations) ⇒ Object
22 23 24 |
# File 'lib/job_spec.rb', line 22 def include(role_expectations) @expectations.concat(role_expectations.to_a) end |
#salary(range = nil) ⇒ Object
18 19 20 |
# File 'lib/job_spec.rb', line 18 def salary(range = nil) @salary = @salary || range end |
#to_a ⇒ Object
30 31 32 |
# File 'lib/job_spec.rb', line 30 def to_a @expectations end |