Class: InlineTesting::TestEnvironment
- Inherits:
-
Object
- Object
- InlineTesting::TestEnvironment
- Defined in:
- lib/inline_testing/test_environment.rb,
lib/inline_testing/test_environment/locals.rb,
lib/inline_testing/test_environment/context.rb
Defined Under Namespace
Instance Method Summary collapse
- #call(&blk) ⇒ Object
- #context(&blk) ⇒ Object
-
#initialize(&blk) ⇒ TestEnvironment
constructor
A new instance of TestEnvironment.
- #locals(&blk) ⇒ Object
- #test(&blk) ⇒ Object
Constructor Details
#initialize(&blk) ⇒ TestEnvironment
Returns a new instance of TestEnvironment.
9 10 11 |
# File 'lib/inline_testing/test_environment.rb', line 9 def initialize(&blk) instance_eval(&blk) if block_given? end |
Instance Method Details
#call(&blk) ⇒ Object
32 |
# File 'lib/inline_testing/test_environment.rb', line 32 def call(&blk); end |
#context(&blk) ⇒ Object
31 |
# File 'lib/inline_testing/test_environment.rb', line 31 def context(&blk); end |
#locals(&blk) ⇒ Object
13 14 15 16 17 |
# File 'lib/inline_testing/test_environment.rb', line 13 def locals(&blk) @locals ||= Locals.new @locals.edit(&blk) if block_given? @locals end |
#test(&blk) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/inline_testing/test_environment.rb', line 19 def test(&blk) @context ||= Context.new(@locals) @context.update_methods code_comments = CommentParser.parse(&blk) code_comments.each do |code_comment| @context.instance_exec(code_comment[:code]) do |code| p eval(code) end end end |