remarkable 3.0.9 → 3.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ * Pending groups show proper backtrace and run by default in execute mode [#49]
2
+
1
3
  * Added support to blocks configuration. All Remarkable matcher and macros can
2
4
  now be configured using a block:
3
5
 
@@ -16,8 +16,14 @@ module Remarkable
16
16
  end
17
17
  end
18
18
 
19
- def should_or_should_not_method_missing(should_or_should_not, method, calltrace, *args, &block) #:nodoc:
20
- it {
19
+ def should_or_should_not_method_missing(should_or_should_not, method, calltrace, *args, &block) #:nodoc:
20
+ description = if @_pending_group
21
+ get_description_from_matcher(should_or_should_not, method, *args, &block)
22
+ else
23
+ nil
24
+ end
25
+
26
+ example(description){
21
27
  begin
22
28
  send(should_or_should_not, send(method, *args, &block))
23
29
  rescue Exception => e
@@ -9,8 +9,9 @@ module Remarkable
9
9
  # If the module to be included responds to :after_include, it's called with the
10
10
  # target as argument.
11
11
  #
12
- def self.include_matchers!(base, target)
13
- target.send :extend, Remarkable::Macros
12
+ def self.include_matchers!(base, target)
13
+ target.send :extend, Remarkable::Pending
14
+ target.send :extend, Remarkable::Macros
14
15
 
15
16
  if defined?(base::Matchers)
16
17
  target.send :include, base::Matchers
@@ -1,42 +1,62 @@
1
1
  module Remarkable
2
- module Macros
3
-
4
- protected
2
+ module Pending
5
3
 
6
- # Adds a pending block to your specs.
7
- #
8
- # == Examples
9
- #
10
- # pending 'create manager resource' do
11
- # should_have_one :manager
12
- # should_validate_associated :manager
13
- # end
14
- #
15
- def pending(description='TODO', &block)
16
- PendingSandbox.new(description, self).instance_eval(&block)
17
- end
18
-
19
- class PendingSandbox < Struct.new(:description, :spec) #:nodoc:
20
- include Macros
21
-
22
- def example(mather_description=nil)
23
- method_caller = caller.detect{ |c| c !~ /method_missing'/ }
24
-
25
- error = begin
26
- ::Spec::Example::ExamplePendingError.new(description, method_caller)
27
- rescue # For rspec <= 1.1.12 and rspec => 1.2.4
28
- ::Spec::Example::ExamplePendingError.new(description)
29
- end
30
-
31
- spec.send(:example, mather_description){ raise error }
32
- end
33
- alias :it :example
34
- alias :specify :example
4
+ # We cannot put the alias method in the module because it's a Ruby 1.8 bug
5
+ # http://coderrr.wordpress.com/2008/03/28/alias_methodmodule-bug-in-ruby-18/
6
+ #
7
+ def self.extended(base) #:nodoc:
8
+ class << base
9
+ alias :it :example
10
+ alias :specify :example
11
+ end
12
+ end
13
+
14
+ # Adds a pending block to your specs.
15
+ #
16
+ # == Examples
17
+ #
18
+ # pending 'create manager resource' do
19
+ # should_have_one :manager
20
+ # should_validate_associated :manager
21
+ # end
22
+ #
23
+ # By default, it executes the examples inside the pending block. So as soon
24
+ # as you add the has_one :manager relationship to your model, your specs
25
+ # will say that this was already fixed and there is no need to be treated
26
+ # as pending. To disable this behavior, you can give :execute => false:
27
+ #
28
+ # pending 'create manager resource', :execute => false
29
+ #
30
+ def pending(*args, &block)
31
+ options = { :execute => true }.merge(args.extract_options!)
32
+
33
+ @_pending_group = true
34
+ @_pending_group_description = args.first || "TODO"
35
+ @_pending_group_execute = options.delete(:execute)
36
+
37
+ self.instance_eval(&block)
38
+
39
+ @_pending_group = false
40
+ @_pending_group_description = nil
41
+ @_pending_group_execute = nil
42
+ end
35
43
 
36
- def should_or_should_not_method_missing(should_or_should_not, method, calltrace, *args, &block)
37
- example(get_description_from_matcher(should_or_should_not, method, *args, &block))
38
- end
39
- end
44
+ def example(description=nil, options={}, backtrace=nil, &implementation) #:nodoc:
45
+ if block_given? && @_pending_group
46
+ pending_caller = caller.detect{ |c| c !~ /method_missing'/ }
47
+ pending_description = @_pending_group_description
48
+
49
+ pending_block = if @_pending_group_execute
50
+ proc{ pending(pending_description, &implementation) }
51
+ else
52
+ proc{ pending(pending_description) }
53
+ end
54
+
55
+ super(description, options, backtrace || pending_caller, &pending_block)
56
+ else
57
+ super(description, options, backtrace || caller(0)[1], &implementation)
58
+ end
59
+ end
40
60
 
41
61
  end
42
62
  end
@@ -1,3 +1,3 @@
1
1
  module Remarkable
2
- VERSION = '3.0.9' unless self.const_defined?('VERSION')
2
+ VERSION = '3.0.10' unless self.const_defined?('VERSION')
3
3
  end
data/spec/pending_spec.rb CHANGED
@@ -1,12 +1,33 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe Remarkable::Macros do
3
+ describe Remarkable::Pending do
4
+
5
+ it "should create pending groups" do
6
+ spec = self
7
+
8
+ self.class.pending "pending examples" do
9
+ self.instance_variable_get("@_pending_group").should spec.be_true
10
+ self.instance_variable_get("@_pending_group_description").should spec.eql("pending examples")
11
+ self.instance_variable_get("@_pending_group_execute").should spec.be_true
12
+ end
13
+
14
+ self.instance_variable_get("@_pending_group").should be_nil
15
+ self.instance_variable_get("@_pending_group_description").should be_nil
16
+ self.instance_variable_get("@_pending_group_execute").should be_nil
17
+ end
4
18
 
5
- describe "with pending examples" do
6
- pending "pending examples" do
7
- should_contain(5)
8
- it("should not be run"){ true.should be_false }
9
- end
19
+ pending "pending examples" do
20
+ # example "should show as not implemented"
21
+ #
22
+ # specify "should show as pending" do
23
+ # raise "oops"
24
+ # end
25
+ #
26
+ # it "should show as fixed" do
27
+ # # success ...
28
+ # end
29
+
30
+ should_contain(5)
10
31
  end
11
32
 
12
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remarkable
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.9
4
+ version: 3.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Brando
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-04-25 00:00:00 +02:00
13
+ date: 2009-04-27 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency