rr 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,5 @@
1
+ - Performance improvements
2
+
1
3
  * 0.7.0
2
4
  - Added spies (Patchs by Joe Ferris, Michael Niessner & Mike Mangino)
3
5
  - Added strongly typed reimplementation doubles (Patch by Michael Niessner)
@@ -312,10 +312,10 @@ to making it possible. We all are standing on the shoulders of giants.
312
312
  * Dan North for syntax ideas
313
313
  * Dave Astels for some BDD inspiration
314
314
  * David Chelimsky for encouragement to make the RR framework, for developing the Rspec mock framework, and syntax ideas
315
+ * Daniel Sudol for identifing performance issues with RR
315
316
  * Felix Morio for pairing with me
316
317
  * Gerard Meszaros for his excellent book "xUnit Test Patterns"
317
318
  * James Mead for developing Mocha
318
- * Joe Ferris for patches
319
319
  * Jeff Whitmire for documentation suggestions
320
320
  * Jim Weirich for developing Flexmock, the first Terse ruby mock framework in Ruby
321
321
  * Joe Ferris for patches
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ def run_suite
26
26
  end
27
27
 
28
28
  PKG_NAME = "rr"
29
- PKG_VERSION = "0.7.0"
29
+ PKG_VERSION = "0.7.1"
30
30
  PKG_FILES = FileList[
31
31
  '[A-Z]*',
32
32
  '*.rb',
@@ -1,54 +1,34 @@
1
1
  module RR
2
2
  module DoubleDefinitions
3
3
  class DoubleDefinitionCreatorProxy
4
- def initialize(creator, &block) #:nodoc:
5
- @creator = creator
6
- class << self
7
- def __apply_blank_slate
8
- @apply_blank_slate = true
9
- end
10
-
11
- def __apply_blank_slate?
12
- @apply_blank_slate ||= false
13
- end
14
-
4
+ class << self
5
+ def blank_slate_methods
15
6
  instance_methods.each do |m|
16
- unless m =~ /^_/ || m.to_s == 'object_id' || m.to_s == "instance_eval" || m.to_s == 'respond_to?'
7
+ unless m =~ /^_/ || m.to_s == 'object_id' || m.to_s == 'respond_to?' || m.to_s == 'method_missing'
17
8
  alias_method "__blank_slated_#{m}", m
18
9
  undef_method m
19
10
  end
20
11
  end
21
-
22
- def instance_eval
23
- return_value = super
24
- class << self
25
- alias_method "__blank_slated_instance_eval", "instance_eval"
26
- undef_method :instance_eval
27
- alias_method "__blank_slated_respond_to?", "respond_to?"
28
- undef_method :respond_to?
29
- end
30
- return_value
31
- end
32
-
33
- def method_missing(method_name, *args, &block)
34
- if __apply_blank_slate?
35
- @creator.create(method_name, *args, &block)
36
- else
37
- __blank_slated_send("__blank_slated_#{method_name}", *args, &block)
38
- end
39
- end
40
12
  end
13
+ end
14
+
15
+ def initialize(creator, &block) #:nodoc:
16
+ @creator = creator
17
+ respond_to?(:class) ? self.class.blank_slate_methods : __blank_slated_class.blank_slate_methods
41
18
 
42
- __apply_blank_slate
43
19
  if block_given?
44
20
  if block.arity == 1
45
21
  yield(self)
46
22
  else
47
- instance_eval(&block)
23
+ respond_to?(:instance_eval) ? instance_eval(&block) : __blank_slated_instance_eval(&block)
48
24
  end
49
25
  end
50
26
  end
51
27
 
28
+ def method_missing(method_name, *args, &block)
29
+ @creator.create(method_name, *args, &block)
30
+ end
31
+
52
32
  def __creator__
53
33
  @creator
54
34
  end
@@ -1,6 +1,6 @@
1
1
  module RR
2
2
  module Errors
3
- BACKTRACE_IDENTIFIER = /lib\/rr/
3
+ BACKTRACE_IDENTIFIER = Regexp.new("/lib/rr")
4
4
 
5
5
  class RRError < RuntimeError
6
6
  attr_writer :backtrace
@@ -8,17 +8,17 @@ module RR
8
8
  end
9
9
 
10
10
  def exact_match?(*arguments)
11
- return false unless arguments.length == @expected_arguments.length
11
+ return false unless arguments.length == expected_arguments.length
12
12
  arguments.each_with_index do |arg, index|
13
- return false unless equality_match(@expected_arguments[index], arg)
13
+ return false unless equality_match(expected_arguments[index], arg)
14
14
  end
15
15
  true
16
16
  end
17
17
 
18
18
  def wildcard_match?(*arguments)
19
- return false unless arguments.length == @expected_arguments.length
19
+ return false unless arguments.length == expected_arguments.length
20
20
  arguments.each_with_index do |arg, index|
21
- expected_argument = @expected_arguments[index]
21
+ expected_argument = expected_arguments[index]
22
22
  if expected_argument.respond_to?(:wildcard_match?)
23
23
  return false unless expected_argument.wildcard_match?(arg)
24
24
  else
@@ -29,7 +29,7 @@ module RR
29
29
  end
30
30
 
31
31
  def ==(other)
32
- @expected_arguments == other.expected_arguments
32
+ expected_arguments == other.expected_arguments
33
33
  end
34
34
 
35
35
  protected
@@ -19,34 +19,11 @@ module RR
19
19
  end
20
20
  end
21
21
 
22
- describe " backtrace tweaking" do
23
- attr_reader :original_rspec_options, :error, :output
24
- before do
25
- @original_rspec_options = Spec::Runner.options
26
- @error = StringIO.new("")
27
- @output = StringIO.new("")
28
- Spec::Runner.use(::Spec::Runner::Options.new(error, output))
29
- end
30
-
31
- after do
32
- Spec::Runner.use(original_rspec_options)
33
- end
34
-
22
+ describe "backtrace tweaking" do
35
23
  it "hides rr library from the backtrace by default" do
36
- subject = @subject
37
- example_group = Class.new(::Spec::Example::ExampleGroup) do
38
- describe "Example"
39
-
40
- it("hides RR framework in backtrace") do
41
- mock(subject).foobar()
42
- RR.verify_double(subject, :foobar)
43
- end
44
- end
45
-
46
- Spec::Runner.options.run_examples
47
-
48
- output.string.should_not be_empty
49
- output.string.should_not include("lib/rr")
24
+ dir = File.dirname(__FILE__)
25
+ output = `ruby #{dir}/rspec_backtrace_tweaking_spec_fixture.rb`
26
+ output.should_not include("lib/rr")
50
27
  end
51
28
  end
52
29
  end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require "spec"
3
+ dir = File.dirname(__FILE__)
4
+ require File.expand_path("#{dir}/../../../lib/rr")
5
+
6
+ describe "Example" do
7
+ it("hides RR framework in backtrace") do
8
+ mock(subject).foobar()
9
+ RR.verify_double(subject, :foobar)
10
+ end
11
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Takita
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-14 00:00:00 -05:00
12
+ date: 2009-01-16 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -102,6 +102,7 @@ files:
102
102
  - spec/rr/space/space_spec.rb
103
103
  - spec/rr/rspec/rspec_backtrace_tweaking_spec.rb
104
104
  - spec/rr/rspec/invocation_matcher_spec.rb
105
+ - spec/rr/rspec/rspec_backtrace_tweaking_spec_fixture.rb
105
106
  - spec/rr/rspec/rspec_usage_spec.rb
106
107
  - spec/rr/rspec/rspec_adapter_spec.rb
107
108
  - spec/rr/test_unit/test_unit_backtrace_test.rb