Skip to content

Commit

Permalink
Bump v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nepalez committed Apr 27, 2019
1 parent f57c967 commit 4d7ca1c
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 30 deletions.
21 changes: 0 additions & 21 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,11 @@ Metrics/LineLength:
- http
- https

Layout/SpaceInLambdaLiteral:
Enabled: false

Style/CaseEquality:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Style/Documentation:
Enabled: false

Style/DoubleNegation:
Enabled: false # by intention

Style/FrozenStringLiteralComment:
Enabled: false

Style/Lambda:
Enabled: false

Style/PercentLiteralDelimiters:
Enabled: false

Style/RaiseArgs:
Enabled: false

Style/StringLiterals:
EnforcedStyle: double_quotes
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ script:
rvm:
- 2.3.0
- 2.6.0
- jruby-9.2.0.0
- ruby-head
- jruby-9.1.0.0
- jruby-head
env:
global:
- JRUBY_OPTS='--dev -J-Xmx1024M'
matrix:
allow_failures:
- rvm: ruby-head
Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
# Change Log

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.0.2] - [2018-04-27]

### Added

- Restriction of stub by arguments (nepalez)

```yaml
---
- class: Balance
chain: debet
arguments: 0
actions:
- return: 1

- class: Balance
chain: debet
arguments: 1
actions:
- return: 0
- raise: UnsifficientFunds

- class: Balance
chain: debet
arguments: 2
actions:
- raise: UnsifficientFunds
```
## [0.0.1] - [2018-03-01]
This is a first public release with features extracted from production app.
[0.0.1]: https://github.com/nepalez/fixturama/releases/tag/v0.0.1
[0.0.2]: https://github.com/nepalez/fixturama/compare/v0.0.1...v0.0.2
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fixturama

Collection of helpers for dealing with fixtures in RSpec
Collection of helpers for dealing with fixtures in [RSpec][rspec]

<a href="https://evilmartians.com/">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
Expand All @@ -24,7 +24,7 @@ require "fixturama/rspec"
The gem defines 3 helpers (support ERB bindings):

- `load_fixture(path, **opts)` to load data from a fixture, and deserialize YAML and JSON
- `seed_fixture(path_to_yaml, **opts)` to prepare database
- `seed_fixture(path_to_yaml, **opts)` to prepare database using the [FactoryBot][factory-bot]
- `stub_fixture(path_to_yaml, **opts)` to stub some classes

```ruby
Expand Down Expand Up @@ -79,6 +79,7 @@ Another opinionated format we use for stubs (`stub_fixture`):

- `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
Expand All @@ -87,14 +88,26 @@ Every action either `return` some value, or `raise` some exception
# ./stubs.yml
#
# The first invocation acts like
# allow(Events).to receive_message_chain(:create).and_return true
#
# Afterwards it will act like
# allow(Events).to receive_message_chain(:create).and_raise AlreadyRegisteredError
# allow(Notifier)
# .to receive_message_chain(:create)
# .with(:profileDeleted, 42)
# .and_return true
#
# then it will act like
#
# allow(Notifier)
# .to receive_message_chain(:create)
# .with(:profileDeleted, 42)
# .and_raise AlreadyRegisteredError
#
---
- class: Events
- class: Notifier
chain:
- create
arguments:
- :profileDeleted
- <%= profile_id %>
actions:
- return: true
- raise: AlreadyRegisteredError
Expand Down Expand Up @@ -138,3 +151,5 @@ The gem is available as open source under the terms of the [MIT License][license
[gem]: https://rubygems.org/gems/fixturama
[travis]: https://travis-ci.org/nepalez/fixturama
[license]: http://opensource.org/licenses/MIT
[factory-bot]: https://github.com/thoughtbot/factory_bot
[rspec]: https://rspec.info/
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.0.1"
gem.version = "0.0.2"
gem.author = "Andrew Kozin (nepalez)"
gem.email = "[email protected]"
gem.homepage = "https://github.com/nepalez/fixturama"
Expand Down
7 changes: 6 additions & 1 deletion lib/fixturama/stubs/actions/return.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def to_s

def initialize(stub, output)
@stub = stub
@call = output.respond_to?(:dup) ? output.dup : output
@call = \
begin # in ruby 2.3.0 Fixnum#dup is defined, but raises TypeError
output.respond_to?(:dup) ? output.dup : output
rescue TypeError
output
end
end
end

0 comments on commit 4d7ca1c

Please sign in to comment.