Class: GUnit::Exercise
- Inherits:
-
Object
- Object
- GUnit::Exercise
- Defined in:
- lib/gunit/exercise.rb
Instance Attribute Summary collapse
- #message ⇒ Object
-
#task ⇒ Object
Returns the value of attribute task.
Instance Method Summary collapse
- #default_message ⇒ Object
-
#initialize(*args, &blk) ⇒ Exercise
constructor
Exercise.new(“my message”) Exercise.new(“my message”) { @foo.bar() } Exercise.new() { @foo.bar() }.
- #run(binding = self) ⇒ Object
Constructor Details
#initialize(*args, &blk) ⇒ Exercise
Exercise.new(“my message”) Exercise.new(“my message”) { @foo.bar() } Exercise.new() { @foo.bar() }
10 11 12 13 |
# File 'lib/gunit/exercise.rb', line 10 def initialize(*args, &blk) self. = args[0] self.task = blk if blk end |
Instance Attribute Details
#message ⇒ Object
29 30 31 |
# File 'lib/gunit/exercise.rb', line 29 def @message || end |
#task ⇒ Object
Returns the value of attribute task.
5 6 7 |
# File 'lib/gunit/exercise.rb', line 5 def task @task end |
Instance Method Details
#default_message ⇒ Object
33 34 35 |
# File 'lib/gunit/exercise.rb', line 33 def "Exercise" end |
#run(binding = self) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gunit/exercise.rb', line 15 def run(binding=self) begin if @task.is_a?(Proc) bound_task = @task.bind(binding) bound_task.call end return true rescue GUnit::AssertionFailure => e FailResponse.new rescue ::StandardError => e ExceptionResponse.new end end |