Module: Remarkable::Pending
- Defined in:
- lib/remarkable/pending.rb
Class Method Summary collapse
-
.extended(base) ⇒ Object
We cannot put the alias method in the module because it’s a Ruby 1.8 bug coderrr.wordpress.com/2008/03/28/alias_methodmodule-bug-in-ruby-18/.
Instance Method Summary collapse
-
#example(description = nil, options = {}, backtrace = nil, &implementation) ⇒ Object
:nodoc:.
-
#pending(*args, &block) ⇒ Object
Adds a pending block to your specs.
Class Method Details
.extended(base) ⇒ Object
We cannot put the alias method in the module because it’s a Ruby 1.8 bug coderrr.wordpress.com/2008/03/28/alias_methodmodule-bug-in-ruby-18/
7 8 9 10 11 12 |
# File 'lib/remarkable/pending.rb', line 7 def self.extended(base) #:nodoc: class << base alias :it :example alias :specify :example end end |
Instance Method Details
#example(description = nil, options = {}, backtrace = nil, &implementation) ⇒ Object
:nodoc:
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/remarkable/pending.rb', line 44 def example(description=nil, ={}, backtrace=nil, &implementation) #:nodoc: if block_given? && @_pending_group pending_caller = caller.detect{ |c| c !~ /method_missing'/ } pending_description = @_pending_group_description pending_block = if @_pending_group_execute proc{ pending(pending_description){ self.instance_eval(&implementation) } } else proc{ pending(pending_description) } end super(description, , backtrace || pending_caller, &pending_block) else super(description, , backtrace || caller(0)[1], &implementation) end end |
#pending(*args, &block) ⇒ Object
Adds a pending block to your specs.
Examples
pending 'create manager resource' do
should_have_one :manager
should_validate_associated :manager
end
By default, it executes the examples inside the pending block. So as soon as you add the has_one :manager relationship to your model, your specs will say that this was already fixed and there is no need to be treated as pending. To disable this behavior, you can give :execute => false:
pending 'create manager resource', :execute => false
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/remarkable/pending.rb', line 30 def pending(*args, &block) = { :execute => true }.merge(args.) @_pending_group = true @_pending_group_description = args.first || "TODO" @_pending_group_execute = .delete(:execute) self.instance_eval(&block) @_pending_group = false @_pending_group_description = nil @_pending_group_execute = nil end |