flexmock 0.4.3 → 0.4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  = Changes for FlexMock
4
4
 
5
+ == Version Pre-0.4.4
6
+
7
+ * Added block support to flexstub.
8
+
5
9
  == Version 0.4.3
6
10
 
7
11
  * Fixed bug where non-direct class methods were not properly handled.
data/README CHANGED
@@ -3,7 +3,7 @@
3
3
  FlexMock is a simple, but flexible, mock object library for Ruby unit
4
4
  testing.
5
5
 
6
- Version :: 0.4.3
6
+ Version :: 0.4.3.1
7
7
 
8
8
  = Links
9
9
 
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ require 'rake/testtask'
9
9
  CLEAN.include('*.tmp')
10
10
  CLOBBER.include("html", 'pkg')
11
11
 
12
- PKG_VERSION = '0.4.3'
12
+ PKG_VERSION = '0.4.3.1'
13
13
 
14
14
  PKG_FILES = FileList[
15
15
  '[A-Z]*',
@@ -780,7 +780,7 @@ class FlexMock
780
780
  # (assuming the the flexmock teardown isn't overridden).
781
781
  #
782
782
  # If a block is given, then the mock object is passed to the block and
783
- # may be configured in the block.
783
+ # may be configured within the block.
784
784
  def flexmock(name="unknown")
785
785
  mock = FlexMock.new(name)
786
786
  yield(mock) if block_given?
@@ -788,25 +788,31 @@ class FlexMock
788
788
  mock
789
789
  end
790
790
 
791
- # Stub the given object by overriding the behavior of individual methods.
792
- # The stub object returned will respond to the +should_receive+
793
- # method, just like normal stubs. Singleton methods cannot be
794
- # stubbed.
791
+ # Stub the given object by overriding the behavior of individual
792
+ # methods. The stub object returned will respond to the
793
+ # +should_receive+ method, just like normal stubs.
794
+ #
795
+ # If a block is given, then the stub object is passed to the block
796
+ # and may be configured within the block.
795
797
  #
796
798
  # Example: Stub out DBI to return a fake db connection.
797
799
  #
798
- # flexstub(DBI).should_receive(:connect).and_return {
799
- # fake_db = flexmock("db connection")
800
- # fake_db.should_receive(:select_all).and_return(...)
801
- # fake_db
802
- # }
800
+ # flexstub(DBI) do |s|
801
+ # s.should_receive(:connect).and_return {
802
+ # flexmock("db connection") do |m|
803
+ # m.should_receive(:select_all).and_return(...)
804
+ # end
805
+ # }
806
+ # end
803
807
  #
804
808
  def flexstub(obj, name=nil)
805
809
  name ||= "flexstub(#{obj.class.to_s})"
806
810
  obj.instance_eval {
807
811
  @flexmock_proxy ||= StubProxy.new(obj, FlexMock.new(name))
808
812
  }
809
- flexmock_remember(obj.instance_variable_get("@flexmock_proxy"))
813
+ proxy = obj.instance_variable_get("@flexmock_proxy")
814
+ yield(proxy) if block_given?
815
+ flexmock_remember(proxy)
810
816
  end
811
817
 
812
818
  # Intercept the named class in the target class for the duration
@@ -818,6 +824,9 @@ class FlexMock
818
824
  # will be left behind that will forward all calls to the original
819
825
  # class.
820
826
  #
827
+ # <b>Warning:</b> <em>Class Interception is deprecated. Use
828
+ # flexstub instead.</em>
829
+ #
821
830
  # Usage:
822
831
  # intercept(SomeClass).in(ClassBeingTested).with(MockClass)
823
832
  # intercept(SomeClass).with(MockClass).in(ClassBeingTested)
@@ -30,6 +30,14 @@ class TestStubbing < Test::Unit::TestCase
30
30
  assert_equal :stub_hi, obj.hi
31
31
  end
32
32
 
33
+ def test_stub_command_can_configure_via_block
34
+ obj = Object.new
35
+ flexstub(obj) do |m|
36
+ m.should_receive(:hi).once.and_return(:stub_hi)
37
+ end
38
+ assert_equal :stub_hi, obj.hi
39
+ end
40
+
33
41
  def test_stubbed_methods_can_take_blocks
34
42
  obj = Object.new
35
43
  flexstub(obj).should_receive(:with_block).once.with(Proc).
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0.6
2
+ rubygems_version: 0.9.0.10
3
3
  specification_version: 1
4
4
  name: flexmock
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.3
7
- date: 2006-10-18 00:00:00 -04:00
6
+ version: 0.4.3.1
7
+ date: 2007-01-26 00:00:00 -05:00
8
8
  summary: Simple and Flexible Mock Objects for Testing
9
9
  require_paths:
10
10
  - lib