Class: Micronaut::Example
Instance Attribute Summary collapse
-
#behaviour ⇒ Object
readonly
Returns the value of attribute behaviour.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#example_block ⇒ Object
readonly
Returns the value of attribute example_block.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
Instance Method Summary collapse
-
#initialize(behaviour, desc, options, example_block = nil) ⇒ Example
constructor
A new instance of Example.
- #inspect ⇒ Object
- #run(behaviour_instance, reporter) ⇒ Object
- #run_after_each ⇒ Object
- #run_before_each ⇒ Object
- #run_example ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(behaviour, desc, options, example_block = nil) ⇒ Example
Returns a new instance of Example.
7 8 9 10 11 12 |
# File 'lib/micronaut/example.rb', line 7 def initialize(behaviour, desc, , example_block=nil) @behaviour, @description, @options, @example_block = behaviour, desc, , example_block @metadata = @behaviour..dup @metadata[:description] = description @metadata.update() end |
Instance Attribute Details
#behaviour ⇒ Object (readonly)
Returns the value of attribute behaviour.
5 6 7 |
# File 'lib/micronaut/example.rb', line 5 def behaviour @behaviour end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
5 6 7 |
# File 'lib/micronaut/example.rb', line 5 def description @description end |
#example_block ⇒ Object (readonly)
Returns the value of attribute example_block.
5 6 7 |
# File 'lib/micronaut/example.rb', line 5 def example_block @example_block end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/micronaut/example.rb', line 5 def @metadata end |
Instance Method Details
#inspect ⇒ Object
14 15 16 |
# File 'lib/micronaut/example.rb', line 14 def inspect "#{@metadata[:behaviour][:name]} - #{@metadata[:description]}" end |
#run(behaviour_instance, reporter) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/micronaut/example.rb', line 43 def run(behaviour_instance, reporter) @behaviour_instance, @reporter = behaviour_instance, reporter @behaviour_instance.running_example = self @reporter.example_started(self) all_systems_nominal = true exception_encountered = nil begin run_before_each run_example rescue Exception => e exception_encountered = e all_systems_nominal = false end begin run_after_each rescue Exception => e exception_encountered ||= e all_systems_nominal = false ensure @behaviour_instance.running_example = nil end @reporter.example_failed(self, exception_encountered) if exception_encountered all_systems_nominal end |
#run_after_each ⇒ Object
27 28 29 30 31 32 |
# File 'lib/micronaut/example.rb', line 27 def run_after_each @behaviour.eval_after_eachs(@behaviour_instance) @behaviour_instance._verify_mocks if @behaviour_instance.respond_to?(:_verify_mocks) ensure @behaviour_instance._teardown_mocks if @behaviour_instance.respond_to?(:_teardown_mocks) end |
#run_before_each ⇒ Object
22 23 24 25 |
# File 'lib/micronaut/example.rb', line 22 def run_before_each @behaviour_instance._setup_mocks if @behaviour_instance.respond_to?(:_setup_mocks) @behaviour.eval_before_eachs(@behaviour_instance) end |
#run_example ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/micronaut/example.rb', line 34 def run_example if example_block @behaviour_instance.instance_eval(&example_block) @reporter.example_passed(self) else @reporter.example_pending(self, 'Not yet implemented') end end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/micronaut/example.rb', line 18 def to_s inspect end |