Module: RSpec::Core::Hooks
- Defined in:
- lib/rspec-action.rb
Instance Method Summary collapse
Instance Method Details
#action(&block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rspec-action.rb', line 8 def action(&block) around do |ex| self.class.remove_previous_action &block self.class.before &block unless self.class.action_added?(&block) self.class.hooks[:before][:each].last.instance_eval do def action_hook?; true; end end ex.run end end |
#action_added?(&block) ⇒ Boolean
25 26 27 28 |
# File 'lib/rspec-action.rb', line 25 def action_added?(&block) parent_groups_hooks = parent_groups.reverse.map { |parent| parent.hooks[:before][:each] }.flatten parent_groups_hooks.include? block end |
#remove_previous_action(&block) ⇒ Object
19 20 21 22 23 |
# File 'lib/rspec-action.rb', line 19 def remove_previous_action(&block) parent_groups.each do |parent| parent.hooks[:before][:each].delete_if {|hook| hook.respond_to?(:action_hook?)} end end |