google-geo 1.0 → 2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/README +12 -8
- data/lib/google/geo.rb +10 -6
- data/test/fixtures/invalid_map_key.xml +10 -0
- data/test/fixtures/missing_address.xml +10 -0
- data/test/fixtures/server_error.xml +10 -0
- data/test/fixtures/success.xml +36 -0
- data/test/fixtures/success_with_multiple_addresses.xml +62 -0
- data/test/fixtures/too_many_queries.xml +10 -0
- data/test/fixtures/unavailable_address.xml +10 -0
- data/test/fixtures/unknown_address.xml +10 -0
- data/test/geo_test.rb +19 -5
- data/vendor/mocha-0.4.0/COPYING +3 -0
- data/vendor/mocha-0.4.0/MIT-LICENSE +7 -0
- data/vendor/mocha-0.4.0/README +35 -0
- data/vendor/mocha-0.4.0/RELEASE +98 -0
- data/vendor/mocha-0.4.0/Rakefile +126 -0
- data/vendor/mocha-0.4.0/examples/misc.rb +36 -0
- data/vendor/mocha-0.4.0/examples/mocha.rb +26 -0
- data/vendor/mocha-0.4.0/examples/stubba.rb +65 -0
- data/vendor/mocha-0.4.0/lib/mocha.rb +19 -0
- data/vendor/mocha-0.4.0/lib/mocha/any_instance_method.rb +35 -0
- data/vendor/mocha-0.4.0/lib/mocha/auto_verify.rb +113 -0
- data/vendor/mocha-0.4.0/lib/mocha/central.rb +35 -0
- data/vendor/mocha-0.4.0/lib/mocha/class_method.rb +62 -0
- data/vendor/mocha-0.4.0/lib/mocha/expectation.rb +295 -0
- data/vendor/mocha-0.4.0/lib/mocha/expectation_error.rb +6 -0
- data/vendor/mocha-0.4.0/lib/mocha/infinite_range.rb +27 -0
- data/vendor/mocha-0.4.0/lib/mocha/inspect.rb +37 -0
- data/vendor/mocha-0.4.0/lib/mocha/instance_method.rb +8 -0
- data/vendor/mocha-0.4.0/lib/mocha/metaclass.rb +7 -0
- data/vendor/mocha-0.4.0/lib/mocha/mock.rb +20 -0
- data/vendor/mocha-0.4.0/lib/mocha/mock_methods.rb +122 -0
- data/vendor/mocha-0.4.0/lib/mocha/object.rb +100 -0
- data/vendor/mocha-0.4.0/lib/mocha/pretty_parameters.rb +28 -0
- data/vendor/mocha-0.4.0/lib/mocha/setup_and_teardown.rb +23 -0
- data/vendor/mocha-0.4.0/lib/mocha/standalone.rb +30 -0
- data/vendor/mocha-0.4.0/lib/mocha/test_case_adapter.rb +49 -0
- data/vendor/mocha-0.4.0/lib/mocha_standalone.rb +2 -0
- data/vendor/mocha-0.4.0/lib/stubba.rb +2 -0
- data/vendor/mocha-0.4.0/test/active_record_test_case.rb +36 -0
- data/vendor/mocha-0.4.0/test/all_tests.rb +75 -0
- data/vendor/mocha-0.4.0/test/execution_point.rb +34 -0
- data/vendor/mocha-0.4.0/test/method_definer.rb +18 -0
- data/vendor/mocha-0.4.0/test/mocha/any_instance_method_test.rb +124 -0
- data/vendor/mocha-0.4.0/test/mocha/auto_verify_test.rb +163 -0
- data/vendor/mocha-0.4.0/test/mocha/central_test.rb +124 -0
- data/vendor/mocha-0.4.0/test/mocha/class_method_test.rb +196 -0
- data/vendor/mocha-0.4.0/test/mocha/expectation_test.rb +357 -0
- data/vendor/mocha-0.4.0/test/mocha/infinite_range_test.rb +50 -0
- data/vendor/mocha-0.4.0/test/mocha/inspect_test.rb +90 -0
- data/vendor/mocha-0.4.0/test/mocha/metaclass_test.rb +22 -0
- data/vendor/mocha-0.4.0/test/mocha/mock_methods_test.rb +235 -0
- data/vendor/mocha-0.4.0/test/mocha/mock_test.rb +84 -0
- data/vendor/mocha-0.4.0/test/mocha/object_test.rb +165 -0
- data/vendor/mocha-0.4.0/test/mocha/pretty_parameters_test.rb +32 -0
- data/vendor/mocha-0.4.0/test/mocha/setup_and_teardown_test.rb +76 -0
- data/vendor/mocha-0.4.0/test/mocha_acceptance_test.rb +98 -0
- data/vendor/mocha-0.4.0/test/mocha_test_result_integration_test.rb +105 -0
- data/vendor/mocha-0.4.0/test/standalone_acceptance_test.rb +110 -0
- data/vendor/mocha-0.4.0/test/stubba_acceptance_test.rb +102 -0
- data/vendor/mocha-0.4.0/test/stubba_integration_test.rb +89 -0
- data/vendor/mocha-0.4.0/test/stubba_test_result_integration_test.rb +85 -0
- data/vendor/mocha-0.4.0/test/test_helper.rb +4 -0
- metadata +73 -3
data/CHANGELOG
CHANGED
@@ -1 +1,6 @@
|
|
1
|
+
= 2.0 Multiple Addresses (and tests you can actually run!)
|
2
|
+
- Not insignificant API change: *** Google::Geo#locate ALWAYS RETURNS AN ARRAY ***
|
3
|
+
- There are now some nice examples in the README.
|
4
|
+
- Updated to include the fixtures and vendor dependencies for tests, yeknow, so you can actually run them.
|
5
|
+
- No namby pamby point releases. This is serious, folks.
|
1
6
|
= 1.0 Initial Release
|
data/README
CHANGED
@@ -5,23 +5,27 @@ A simple, elegant library for getting geocoding information from Google Maps. Ve
|
|
5
5
|
== Examples
|
6
6
|
|
7
7
|
geo = Google::Geo.new API_KEY
|
8
|
+
|
9
|
+
addresses = geo.locate '1600 Amphitheatre Parkway, Mountain View, CA'
|
8
10
|
|
9
|
-
|
11
|
+
addresses.size # 1, :locate always returns an Array
|
10
12
|
|
13
|
+
address = addresses.first
|
14
|
+
|
11
15
|
address.country # 'US'
|
12
16
|
address.city # 'Mountain View'
|
13
17
|
address.full_address # '1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA'
|
14
|
-
|
18
|
+
|
15
19
|
address.query # '1600 Amphitheatre Parkway, Mountain View, CA'
|
16
20
|
address.accuracy # 8
|
17
|
-
|
18
|
-
In the case of sufficiently vague queries,
|
19
|
-
|
21
|
+
|
22
|
+
In the case of sufficiently vague queries, Google::Geo will return more than one:
|
23
|
+
|
20
24
|
addresses = geo.locate 'hell'
|
21
|
-
|
25
|
+
|
22
26
|
addresses.size # 2
|
23
|
-
addresses.map { |a| a.
|
27
|
+
addresses.map { |a| a.state } # ['PA', 'NC']
|
24
28
|
|
25
29
|
== Contributors
|
26
|
-
|
30
|
+
|
27
31
|
Seth Thomas Rasmussen - http://sethrasmussen.com - sethrasmussen@gmail.com
|
data/lib/google/geo.rb
CHANGED
@@ -10,7 +10,11 @@ module Google
|
|
10
10
|
#
|
11
11
|
# geo = Google::Geo.new API_KEY
|
12
12
|
#
|
13
|
-
#
|
13
|
+
# addresses = geo.locate '1600 Amphitheatre Parkway, Mountain View, CA'
|
14
|
+
#
|
15
|
+
# addresses.size # 1, :locate always returns an Array
|
16
|
+
#
|
17
|
+
# address = addresses.first
|
14
18
|
#
|
15
19
|
# address.country # 'US'
|
16
20
|
# address.city # 'Mountain View'
|
@@ -19,12 +23,12 @@ module Google
|
|
19
23
|
# address.query # '1600 Amphitheatre Parkway, Mountain View, CA'
|
20
24
|
# address.accuracy # 8
|
21
25
|
#
|
22
|
-
# In the case of sufficiently vague queries,
|
26
|
+
# In the case of sufficiently vague queries, Google will return more than one address:
|
23
27
|
#
|
24
|
-
# addresses = geo.locate '
|
28
|
+
# addresses = geo.locate 'heaven'
|
25
29
|
#
|
26
30
|
# addresses.size # 2
|
27
|
-
# addresses.map { |a| a.
|
31
|
+
# addresses.map { |a| a.state } # ['PA', 'NC']
|
28
32
|
#
|
29
33
|
# == Contributors
|
30
34
|
#
|
@@ -37,8 +41,8 @@ class Geo
|
|
37
41
|
@key = key
|
38
42
|
end
|
39
43
|
|
40
|
-
# Returns an
|
41
|
-
# The
|
44
|
+
# Returns an array of Address objects, each with accessors for all the components of a location.
|
45
|
+
# The query argument should be a string.
|
42
46
|
def locate(query)
|
43
47
|
xml = open(uri(query)).read
|
44
48
|
res = Response.new(xml, key)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<kml xmlns="http://earth.google.com/kml/2.1">
|
3
|
+
<Response>
|
4
|
+
<name>1600 Amphitheatre Parkway, Mountain View, CA</name>
|
5
|
+
<Status>
|
6
|
+
<code>200</code>
|
7
|
+
<request>geocode</request>
|
8
|
+
</Status>
|
9
|
+
<Placemark>
|
10
|
+
<address>1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA</address>
|
11
|
+
<AddressDetails xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" Accuracy="8">
|
12
|
+
<Country>
|
13
|
+
<CountryNameCode>US</CountryNameCode>
|
14
|
+
<AdministrativeArea>
|
15
|
+
<AdministrativeAreaName>CA</AdministrativeAreaName>
|
16
|
+
<SubAdministrativeArea>
|
17
|
+
<SubAdministrativeAreaName>Santa Clara</SubAdministrativeAreaName>
|
18
|
+
<Locality>
|
19
|
+
<LocalityName>Mountain View</LocalityName>
|
20
|
+
<Thoroughfare>
|
21
|
+
<ThoroughfareName>1600 Amphitheatre Pkwy</ThoroughfareName>
|
22
|
+
</Thoroughfare>
|
23
|
+
<PostalCode>
|
24
|
+
<PostalCodeNumber>94043</PostalCodeNumber>
|
25
|
+
</PostalCode>
|
26
|
+
</Locality>
|
27
|
+
</SubAdministrativeArea>
|
28
|
+
</AdministrativeArea>
|
29
|
+
</Country>
|
30
|
+
</AddressDetails>
|
31
|
+
<Point>
|
32
|
+
<coordinates>-122.083739,37.423021,0</coordinates>
|
33
|
+
</Point>
|
34
|
+
</Placemark>
|
35
|
+
</Response>
|
36
|
+
</kml>
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<kml xmlns="http://earth.google.com/kml/2.0">
|
3
|
+
<Response>
|
4
|
+
<name>heaven</name>
|
5
|
+
<Status>
|
6
|
+
<code>200</code>
|
7
|
+
<request>geocode</request>
|
8
|
+
</Status>
|
9
|
+
<Placemark id="p1">
|
10
|
+
<address>Heaven, Pottsville, PA 17901, USA</address>
|
11
|
+
<AddressDetails xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" Accuracy="6">
|
12
|
+
<Country>
|
13
|
+
<CountryNameCode>US</CountryNameCode>
|
14
|
+
<AdministrativeArea>
|
15
|
+
<AdministrativeAreaName>PA</AdministrativeAreaName>
|
16
|
+
<SubAdministrativeArea>
|
17
|
+
<SubAdministrativeAreaName>Schuylkill</SubAdministrativeAreaName>
|
18
|
+
<Locality>
|
19
|
+
<LocalityName>Pottsville</LocalityName>
|
20
|
+
<Thoroughfare>
|
21
|
+
<ThoroughfareName>Heaven</ThoroughfareName>
|
22
|
+
</Thoroughfare>
|
23
|
+
<PostalCode>
|
24
|
+
<PostalCodeNumber>17901</PostalCodeNumber>
|
25
|
+
</PostalCode>
|
26
|
+
</Locality>
|
27
|
+
</SubAdministrativeArea>
|
28
|
+
</AdministrativeArea>
|
29
|
+
</Country>
|
30
|
+
</AddressDetails>
|
31
|
+
<Point>
|
32
|
+
<coordinates>-76.169968,40.650970,0</coordinates>
|
33
|
+
</Point>
|
34
|
+
</Placemark>
|
35
|
+
<Placemark id="p2">
|
36
|
+
<address>Heaven, Oakboro, NC 28129, USA</address>
|
37
|
+
<AddressDetails xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" Accuracy="6">
|
38
|
+
<Country>
|
39
|
+
<CountryNameCode>US</CountryNameCode>
|
40
|
+
<AdministrativeArea>
|
41
|
+
<AdministrativeAreaName>NC</AdministrativeAreaName>
|
42
|
+
<SubAdministrativeArea>
|
43
|
+
<SubAdministrativeAreaName>Stanly</SubAdministrativeAreaName>
|
44
|
+
<Locality>
|
45
|
+
<LocalityName>Oakboro</LocalityName>
|
46
|
+
<Thoroughfare>
|
47
|
+
<ThoroughfareName>Heaven</ThoroughfareName>
|
48
|
+
</Thoroughfare>
|
49
|
+
<PostalCode>
|
50
|
+
<PostalCodeNumber>28129</PostalCodeNumber>
|
51
|
+
</PostalCode>
|
52
|
+
</Locality>
|
53
|
+
</SubAdministrativeArea>
|
54
|
+
</AdministrativeArea>
|
55
|
+
</Country>
|
56
|
+
</AddressDetails>
|
57
|
+
<Point>
|
58
|
+
<coordinates>-80.330399,35.254227,0</coordinates>
|
59
|
+
</Point>
|
60
|
+
</Placemark>
|
61
|
+
</Response>
|
62
|
+
</kml>
|
data/test/geo_test.rb
CHANGED
@@ -10,7 +10,8 @@ class Google::GeoTest < Test::Unit::TestCase
|
|
10
10
|
|
11
11
|
def test_success
|
12
12
|
@geo.expects(:open).
|
13
|
-
|
13
|
+
# show that query is escaped
|
14
|
+
with("http://maps.google.com/maps/geo?q=1600%20Amphitheatre%20Parkway,%20Mountain%20View,%20CA&key=API_KEY&output=xml").
|
14
15
|
returns(response(:success))
|
15
16
|
|
16
17
|
query = '1600 Amphitheatre Parkway, Mountain View, CA'
|
@@ -50,6 +51,19 @@ class Google::GeoTest < Test::Unit::TestCase
|
|
50
51
|
assert_equal '1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA', address.full_address
|
51
52
|
assert_equal query, address.query
|
52
53
|
end
|
54
|
+
|
55
|
+
def test_success_with_multiple_addresses
|
56
|
+
@geo.expects(:open).returns(response(:success_with_multiple_addresses))
|
57
|
+
|
58
|
+
heavens = @geo.locate('heaven')
|
59
|
+
|
60
|
+
assert_equal 2, heavens.size
|
61
|
+
|
62
|
+
assert_equal 'Heaven, Pottsville, PA 17901, USA', heavens[0].full_address
|
63
|
+
assert_equal 'Heaven, Oakboro, NC 28129, USA', heavens[1].full_address
|
64
|
+
|
65
|
+
heavens.each { |h| assert_kind_of Google::Geo::Address, h }
|
66
|
+
end
|
53
67
|
|
54
68
|
def test_invalid_map_key
|
55
69
|
@geo.expects(:open).returns(response(:invalid_map_key))
|
@@ -81,8 +95,8 @@ class Google::GeoTest < Test::Unit::TestCase
|
|
81
95
|
assert_raises(Google::Geo::UnknownAddressError) { @geo.locate 'foo' }
|
82
96
|
end
|
83
97
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
98
|
+
private
|
99
|
+
def response(filename)
|
100
|
+
File.new "#{File.dirname __FILE__}/fixtures/#{filename}.xml"
|
101
|
+
end
|
88
102
|
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2006 Revieworld Ltd.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,35 @@
|
|
1
|
+
= Mocha
|
2
|
+
|
3
|
+
Mocha is a library for mocking and stubbing using a syntax like that of JMock[http://www.jmock.org], and SchMock[http://rubyforge.org/projects/schmock]. Most commonly Mocha is used in conjunction with Test::Unit[http://www.ruby-doc.org/core/classes/Test/Unit.html], but it can be used in other contexts.
|
4
|
+
|
5
|
+
One of its main advantages is that it allows you to mock and stub methods on _real_ (non-mock) classes and instances. You can for example stub ActiveRecord[http://api.rubyonrails.com/classes/ActiveRecord/Base.html] instance methods like +create+, +save+, +destroy+ and even class methods like +find+ to avoid hitting the database in unit tests.
|
6
|
+
|
7
|
+
Mocha provides a unified, simple and readable syntax for both traditional mocking and for mocking with _real_ objects.
|
8
|
+
|
9
|
+
Mocha has been harvested from projects at Reevoo[http://www.reevoo.com] by me (James[http://blog.floehopper.org]) and my colleagues Ben[http://www.reevoo.com/blogs/bengriffiths], Chris[http://blog.seagul.co.uk] and Paul[http://po-ru.com]. Mocha is in use on real-world Rails[http://www.rubyonrails.org] projects.
|
10
|
+
|
11
|
+
== Download and Installation
|
12
|
+
|
13
|
+
Install the gem with the following command...
|
14
|
+
|
15
|
+
$ gem install mocha
|
16
|
+
|
17
|
+
Or install the Rails[http://www.rubyonrails.org] plugin...
|
18
|
+
|
19
|
+
$ script/plugin install svn://rubyforge.org/var/svn/mocha/trunk
|
20
|
+
|
21
|
+
Or download Mocha from here - http://rubyforge.org/projects/mocha
|
22
|
+
|
23
|
+
== Examples
|
24
|
+
|
25
|
+
* Quick Start - {Usage Examples}[link:examples/misc.html]
|
26
|
+
* Traditional mocking - {Star Trek Example}[link:examples/mocha.html]
|
27
|
+
* Setting expectations on real classes - {Order Example}[link:examples/stubba.html]
|
28
|
+
* More examples on {Floehopper's Blog}[http://blog.floehopper.org]
|
29
|
+
* {Mailing List Archives}[http://rubyforge.org/pipermail/mocha-developer/]
|
30
|
+
|
31
|
+
== License
|
32
|
+
|
33
|
+
Copyright Revieworld Ltd. 2006
|
34
|
+
|
35
|
+
You may use, copy and redistribute this library under the same terms as {Ruby itself}[http://www.ruby-lang.org/en/LICENSE.txt] or under the {MIT license}[http://mocha.rubyforge.org/files/MIT-LICENSE.html].
|
@@ -0,0 +1,98 @@
|
|
1
|
+
= 0.4.0
|
2
|
+
|
3
|
+
- Allow naming of mocks (patch from Chris Roos).
|
4
|
+
- Specify multiple return values for consecutive calls.
|
5
|
+
- Improved consistency of expectation error messages.
|
6
|
+
- Allow mocking of Object instance methods e.g. kind_of?, type.
|
7
|
+
- Provide aliased versions of #expects and #stubs to allow mocking of these methods.
|
8
|
+
- Added at_least, at_most, at_most_once methods to expectation.
|
9
|
+
- Allow expects and stubs to take a hash of method and return values.
|
10
|
+
- Eliminate warning: "instance variable @yield not initialized" (patch from Xavier Shay).
|
11
|
+
- Restore instance methods on partial mocks (patch from Chris Roos).
|
12
|
+
- Allow stubbing of a method with non-word characters in its name (patch from Paul Battley).
|
13
|
+
- Removed coupling to Test::Unit.
|
14
|
+
- Allow specified exception instance to be raised (patch from Chris Roos).
|
15
|
+
- Make mock object_id appear in hex like normal Ruby inspect (patch from Paul Battley).
|
16
|
+
- Fix path to object.rb in rdoc rake task (patch from Tomas Pospisek).
|
17
|
+
- Reverse order in which expectations are matched, so that last expectation is matched first. This allows e.g. a call to #stubs to be effectively overridden by a call to #expects (patch from Tobias Lutke).
|
18
|
+
- Stubba & SmartTestCase modules incorporated into Mocha module so only need to require 'mocha' - no longer need to require 'stubba'.
|
19
|
+
- AutoMocha removed.
|
20
|
+
|
21
|
+
= 0.3.3
|
22
|
+
|
23
|
+
- Quick bug fix to restore instance methods on partial mocks (for Kevin Clark).
|
24
|
+
|
25
|
+
= 0.3.2
|
26
|
+
|
27
|
+
- Examples added.
|
28
|
+
|
29
|
+
= 0.3.1
|
30
|
+
|
31
|
+
- Dual licensing with MIT license added.
|
32
|
+
|
33
|
+
= 0.3.0
|
34
|
+
|
35
|
+
* Rails plugin.
|
36
|
+
* Auto-verify for expectations on concrete classes.
|
37
|
+
* Include each expectation verification in the test result assertion count.
|
38
|
+
* Filter out noise from assertion backtraces.
|
39
|
+
* Point assertion backtrace to line where failing expectation was created.
|
40
|
+
* New yields method for expectations.
|
41
|
+
* Create stubs which stub all method calls.
|
42
|
+
* Mocks now respond_to? expected methods.
|
43
|
+
|
44
|
+
= 0.2.1
|
45
|
+
|
46
|
+
* Rename MochaAcceptanceTest::Rover#move method to avoid conflict with Rake (in Ruby 1.8.4 only?)
|
47
|
+
|
48
|
+
= 0.2.0
|
49
|
+
|
50
|
+
* Small change to SetupAndTeardown#teardown_stubs suggested by Luke Redpath (http://www.lukeredpath.co.uk) to allow use of Stubba with RSpec (http://rspec.rubyforge.org).
|
51
|
+
* Reorganized directory structure and extracted addition of setup and teardown methods into SmartTestCase mini-library.
|
52
|
+
* Addition of auto-verify for Mocha (but not Stubba). This means there is more significance in the choice of expects or stubs in that any expects on a mock will automatically get verified.
|
53
|
+
|
54
|
+
So instead of...
|
55
|
+
|
56
|
+
wotsit = Mocha.new
|
57
|
+
wotsit.expects(:thingummy).with(5).returns(10)
|
58
|
+
doobrey = Doobrey.new(wotsit)
|
59
|
+
doobrey.hoojamaflip
|
60
|
+
wotsit.verify
|
61
|
+
|
62
|
+
you need to do...
|
63
|
+
|
64
|
+
wotsit = mock()
|
65
|
+
wotsit.expects(:thingummy).with(5).returns(10)
|
66
|
+
doobrey = Doobrey.new(wotsit)
|
67
|
+
doobrey.hoojamaflip
|
68
|
+
# no need to verify
|
69
|
+
|
70
|
+
There are also shortcuts as follows...
|
71
|
+
|
72
|
+
instead of...
|
73
|
+
|
74
|
+
wotsit = Mocha.new
|
75
|
+
wotsit.expects(:thingummy).returns(10)
|
76
|
+
wotsit.expects(:summat).returns(25)
|
77
|
+
|
78
|
+
you can have...
|
79
|
+
|
80
|
+
wotsit = mock(:thingummy => 5, :summat => 25)
|
81
|
+
|
82
|
+
and instead of...
|
83
|
+
|
84
|
+
wotsit = Mocha.new
|
85
|
+
wotsit.stubs(:thingummy).returns(10)
|
86
|
+
wotsit.stubs(:summat).returns(25)
|
87
|
+
|
88
|
+
you can have...
|
89
|
+
|
90
|
+
wotsit = stub(:thingummy => 5, :summat => 25)
|
91
|
+
|
92
|
+
= 0.1.2
|
93
|
+
|
94
|
+
* Minor tweaks
|
95
|
+
|
96
|
+
= 0.1.1
|
97
|
+
|
98
|
+
* Initial release.
|