Class: Funktional::ShouldBlock
- Inherits:
-
Object
- Object
- Funktional::ShouldBlock
- Defined in:
- lib/funktional/context/should_block.rb
Direct Known Subclasses
AssignedShouldBlock, CountShouldBlock, DelegatingShouldBlock, ElementShouldBlock, FlashedShouldBlock, ShouldCreateBlock, ShouldDeleteBlock, ShouldNotCreateBlock, ShouldNotDeleteBlock, ShouldNotSendEmailBlock
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(should_name, context, &blk) ⇒ ShouldBlock
constructor
A new instance of ShouldBlock.
- #to_test ⇒ Object
Constructor Details
#initialize(should_name, context, &blk) ⇒ ShouldBlock
Returns a new instance of ShouldBlock.
19 20 21 22 |
# File 'lib/funktional/context/should_block.rb', line 19 def initialize(should_name, context, &blk) raise 'block required' unless block_given? @should_name, @blk, @context = should_name, blk, context end |
Class Method Details
.build(options, context, &blk) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/funktional/context/should_block.rb', line 4 def self.build(, context, &blk) return self.new(name = , context, &blk) if .is_a? String = {:render_404 => 'public/404'} if == :render_404 case .keys.first when :create ShouldCreateBlock.new([:create], context) when :delete ShouldDeleteBlock.new([:delete], context) else DelegatingShouldBlock.new(, context, &blk) end end |
Instance Method Details
#to_test ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/funktional/context/should_block.rb', line 24 def to_test context, blk, before = @context, @blk, @before @context.test_unit_class.send(:define_method, build_test_name) do begin context.run_parent_setup_blocks(self) before.bind(self).call if before context.run_current_setup_blocks(self) blk.bind(self).call ensure context.run_all_teardown_blocks(self) end end end |