Module: RSpec::Todo
- Defined in:
- lib/rspec/todo.rb
Instance Method Summary collapse
- #not_todo(reason = nil, opts = {}, &block) ⇒ Object
- #rspec_todo_works_for(opts = {}) ⇒ Object
- #todo(reason = nil, opts = {}, &block) ⇒ Object
Instance Method Details
#not_todo(reason = nil, opts = {}, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rspec/todo.rb', line 33 def not_todo(reason = nil, opts = {}, &block) reason, opts = nil, reason if reason.is_a?(Hash) if rspec_todo_works_for(opts) if block_given? begin yield rescue RSpec::Expectations::ExpectationNotMetError, *opts[:errors] => e # do nothing else if reason raise(reason) else raise "not todo but passed" end end else pending(reason) end else yield end end |
#rspec_todo_works_for(opts = {}) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/rspec/todo.rb', line 3 def rspec_todo_works_for(opts = {}) if opts[:if].nil? && opts[:unless].nil? true else opts[:if] || (opts[:unless].nil? ? false : !opts[:unless]) end end |
#todo(reason = nil, opts = {}, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rspec/todo.rb', line 11 def todo(reason = nil, opts = {}, &block) reason, opts = nil, reason if reason.is_a?(Hash) if rspec_todo_works_for(opts) if block_given? begin yield rescue => e if reason pending(reason) else pending(e.inspect) end end else pending(reason) end else yield end end |