https://github.com/manfred/bendy
A tiny mocking framework for Ruby
https://github.com/manfred/bendy
Last synced: about 1 year ago
JSON representation
A tiny mocking framework for Ruby
- Host: GitHub
- URL: https://github.com/manfred/bendy
- Owner: Manfred
- License: mit
- Created: 2010-12-02T18:02:13.000Z (over 15 years ago)
- Default Branch: main
- Last Pushed: 2021-08-27T09:17:33.000Z (almost 5 years ago)
- Last Synced: 2025-04-01T02:48:12.815Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 10.7 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
# Bendy
Bendy is a tiny mocking framework.
## Install
$ curl -o lib/bendy.rb https://raw.github.com/Manfred/Bendy/master/bendy.rb
## Examples
Mock object that responds to a couple of methods.
```ruby
henry = shape(name: "Henry")
henry.name #=> "Henry"
```
Wrap a class definition and override a couple of methods.
```ruby
class Weblog
def author
"Henry"
end
def path
"/path/to/weblog"
end
end
weblog = shape(Weblog,
path: "/mnt/data/weblog",
reverse: Proc.new { |s| s.reverse }
)
weblog.path #=> "/mnt/data/weblog"
weblog.author #=> "Henry"
weblog.reverse('Jimmy') #=> 'ymmiJ"
```
Initialize a shape with arguments.
```ruby
class Weblog
attr_reader :path
def initialize(path)
@path = path
end
end
weblog = shape(Weblog, "/mnt/data/weblog", author: "Henry")
weblog.path #=> "/mnt/data/weblog"
weblog.author #=> "Henry"
```
## Copying
Bendy is freely distributable under the terms of an MIT-style license. See COPYING or http://www.opensource.org/licenses/mit-license.php.
-----
“Ik wil alleen maar benden.”