Skip to content

Commit

Permalink
Bump v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nepalez committed Feb 17, 2020
1 parent df4927d commit 22c0a6d
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 5 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.2.0] - [2020-02-17]

### Added

- Stubbing and seeding from the same source file via the `call_fixture` method (nepalez)

```yaml
# ./changes.yml
---
- type: user
params:
id: 1

- const: DEFAULT_USER_ID
value: 1

- url: https://example.com/users/default
method: get
responses:
- body:
id: 1
name: Andrew
```
```ruby
before { call_fixture "#{__dir__}/changes.yml" }
```

## [0.1.0] - [2020-02-09]

### Added
Expand Down Expand Up @@ -200,3 +228,4 @@ This is a first public release with features extracted from production app.
[0.0.6]: https://github.com/nepalez/fixturama/compare/v0.0.5...v0.0.6
[0.0.7]: https://github.com/nepalez/fixturama/compare/v0.0.6...v0.0.7
[0.1.0]: https://github.com/nepalez/fixturama/compare/v0.0.7...v0.1.0
[0.2.0]: https://github.com/nepalez/fixturama/compare/v0.1.0...v0.2.0
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,17 @@ Use the `count: 2` key to create more objects at once.

### Stubbing

Another opinionated format we use for stubs (`stub_fixture`). The gem supports stubbing both message chains and constants.
The gem supports stubbing message chains, constants and http requests with the following keys.

For message chains:

- `class` for stubbed class
- `chain` for messages chain
- `arguments` (optional) for specific arguments
- `actions` for an array of actions for consecutive invocations of the chain

Every action either `return` some value, or `raise` some exception
- `actions` for an array of actions for consecutive invocations of the chain with keys
- `return` for a value to be returned
- `raise` for an exception to be risen
- `repeate` for a number of invocations with this action

For constants:

Expand All @@ -152,6 +153,7 @@ For http requests:
- `status`
- `body`
- `headers`
- `repeate` for the number of times this response should be returned before switching to the next one

```yaml
# ./stubs.yml
Expand Down Expand Up @@ -179,6 +181,7 @@ For http requests:
- <%= profile_id %>
actions:
- return: true
repeate: 1 # this is the default value
- raise: ActiveRecord::RecordNotFound
- const: NOTIFIER_TIMEOUT_SEC
Expand All @@ -192,6 +195,7 @@ For http requests:
password: bar
responses:
- status: 200 # for the first call
repeate: 1 # this is the default value, but you can set another one
- status: 404 # for any other call
- uri: htpps://example.com/foo # exact string!
Expand Down Expand Up @@ -231,6 +235,30 @@ I find it especially helpful when I need to check different edge cases. Instead

Looking at the spec I can easily figure out the "structure" of expectation, while looking at fixtures I can check the concrete corner cases.

## Single Source of Changes

If you will, you can list all stubs and seeds at the one single file like

```yaml
# ./changes.yml
---
- type: user
params:
id: 1
name: Andrew
- const: DEFAULT_USER_ID
value: 1
```

This fixture can be applied via `call_fixture` method just like we did above with `seed_fixture` and `stub_fixture`:

```ruby
before { call_fixture "#{__dir__}/changes.yml" }
```

In fact, since the `v0.2.0` all those methods are just the aliases of the `call_fixture`.

## License

The gem is available as open source under the terms of the [MIT License][license].
Expand Down
2 changes: 1 addition & 1 deletion fixturama.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |gem|
gem.name = "fixturama"
gem.version = "0.1.0"
gem.version = "0.2.0"
gem.author = "Andrew Kozin (nepalez)"
gem.email = "[email protected]"
gem.homepage = "https://github.com/nepalez/fixturama"
Expand Down

0 comments on commit 22c0a6d

Please sign in to comment.