fixturama 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.rubocop.yml +43 -0
- data/.travis.yml +20 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +140 -0
- data/Rakefile +6 -0
- data/fixturama.gemspec +23 -0
- data/lib/fixturama/rspec.rb +4 -0
- data/lib/fixturama/seed.rb +14 -0
- data/lib/fixturama/stubs/actions.rb +27 -0
- data/lib/fixturama/stubs/raise.rb +15 -0
- data/lib/fixturama/stubs/return.rb +13 -0
- data/lib/fixturama/stubs.rb +37 -0
- data/lib/fixturama/utils.rb +21 -0
- data/lib/fixturama.rb +47 -0
- data/spec/fixturama/load_fixture/_spec.rb +21 -0
- data/spec/fixturama/load_fixture/data.json +5 -0
- data/spec/fixturama/load_fixture/data.yaml +3 -0
- data/spec/fixturama/load_fixture/data.yml +3 -0
- data/spec/fixturama/seed_fixture/_spec.rb +32 -0
- data/spec/fixturama/seed_fixture/seed.yml +7 -0
- data/spec/fixturama/stub_fixture/_spec.rb +47 -0
- data/spec/fixturama/stub_fixture/stub.yml +8 -0
- data/spec/spec_helper.rb +20 -0
- metadata +164 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8373fb84e1acca73b060d54aab09588b6f196aa9420a6378361a9f5e011c2e71
|
4
|
+
data.tar.gz: 286b6cf22fecdebe1f7fec48c30bbcc49879683726c1ad3da1282e9b2eb6cd66
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 705ddbd4b4c6458d3fe7338748a9dcbb1166ca8dbedbb01a9c21e37036c5a71df70963af5e3d6ba6ae50baaf04435b23e69570c7360e9577175038ec238a7a41
|
7
|
+
data.tar.gz: 26cbcea20fd78fe35d78edf6161f66f048d6b406e1246c55d88432e0149d11cde13c2d2577b6735f3e74dda21764cee73e077df3063765312b1de0bc22422599
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
---
|
2
|
+
AllCops:
|
3
|
+
DisplayCopNames: true
|
4
|
+
DisplayStyleGuide: true
|
5
|
+
StyleGuideCopsOnly: true
|
6
|
+
TargetRubyVersion: 2.3
|
7
|
+
|
8
|
+
Metrics/LineLength:
|
9
|
+
AllowHeredoc: true
|
10
|
+
AllowURI: true
|
11
|
+
URISchemes:
|
12
|
+
- http
|
13
|
+
- https
|
14
|
+
|
15
|
+
Layout/SpaceInLambdaLiteral:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/CaseEquality:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/ClassAndModuleChildren:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/Documentation:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Style/DoubleNegation:
|
28
|
+
Enabled: false # by intention
|
29
|
+
|
30
|
+
Style/FrozenStringLiteralComment:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Style/Lambda:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Style/PercentLiteralDelimiters:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Style/RaiseArgs:
|
40
|
+
Enabled: false
|
41
|
+
|
42
|
+
Style/StringLiterals:
|
43
|
+
EnforcedStyle: double_quotes
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
sudo: false
|
3
|
+
language: ruby
|
4
|
+
cache: bundler
|
5
|
+
before_install:
|
6
|
+
- gem install bundler --no-document
|
7
|
+
- gem update --system
|
8
|
+
script:
|
9
|
+
- bundle exec rspec
|
10
|
+
- bundle exec rubocop
|
11
|
+
rvm:
|
12
|
+
- 2.3.0
|
13
|
+
- 2.6.0
|
14
|
+
- ruby-head
|
15
|
+
- jruby-9.1.0.0
|
16
|
+
- jruby-head
|
17
|
+
matrix:
|
18
|
+
allow_failures:
|
19
|
+
- rvm: ruby-head
|
20
|
+
- rvm: jruby-head
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
|
+
|
7
|
+
## [0.0.1] - [2018-03-01]
|
8
|
+
|
9
|
+
This is a first public release with features extracted from production app.
|
10
|
+
|
11
|
+
[0.0.1]: https://github.com/nepalez/fixturama/releases/tag/v0.0.1
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Andrew Kozin (aka nepalez)
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
# Fixturama
|
2
|
+
|
3
|
+
Collection of helpers for dealing with fixtures in RSpec
|
4
|
+
|
5
|
+
<a href="https://evilmartians.com/">
|
6
|
+
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
|
7
|
+
|
8
|
+
[![Gem Version](https://badge.fury.io/rb/fixturama.svg)][gem]
|
9
|
+
[![Build Status](https://travis-ci.org/nepalez/fixturama.svg?branch=master)][travis]
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem "fixturama"
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
# spec/spec_helper.rb
|
21
|
+
require "fixturama/rspec"
|
22
|
+
```
|
23
|
+
|
24
|
+
The gem defines 3 helpers (support ERB bindings):
|
25
|
+
|
26
|
+
- `load_fixture(path, **opts)` to load data from a fixture, and deserialize YAML and JSON
|
27
|
+
- `seed_fixture(path_to_yaml, **opts)` to prepare database
|
28
|
+
- `stub_fixture(path_to_yaml, **opts)` to stub some classes
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
# spec/models/user/_spec.rb
|
32
|
+
RSpec.describe "GraphQL mutation 'deleteProfile'" do
|
33
|
+
subject { Schema.execute(mutation).to_h }
|
34
|
+
|
35
|
+
before do
|
36
|
+
seed_fixture("#{__dir__}/database.yml", profile_id: 42)
|
37
|
+
stub_fixture("#{__dir__}/stubs.yml", profile_id: 42)
|
38
|
+
end
|
39
|
+
|
40
|
+
let(:mutation) { load_fixture "#{__dir__}/mutation.graphql", profile_id: 42 }
|
41
|
+
let(:result) { load_fixture "#{__dir__}/result.yaml" }
|
42
|
+
|
43
|
+
it { is_expected.to eq result }
|
44
|
+
|
45
|
+
it "deletes the profile" do
|
46
|
+
expect { subject }.to change { Profile.find_by(id: 42) }.to nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it "sends a notification" do
|
50
|
+
expect(Notifier)
|
51
|
+
.to receive_message_chain(:create)
|
52
|
+
.with("profileDeleted", 42)
|
53
|
+
|
54
|
+
subject
|
55
|
+
end
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
The seed (`seed_fixture`) file should be a YAML/JSON with opinionated parameters, namely:
|
60
|
+
|
61
|
+
- `type` for the name of the [FactoryBot][factory_bot] factory
|
62
|
+
- `traits` for the factory traits
|
63
|
+
- `params` for parameters of the factory
|
64
|
+
|
65
|
+
```yaml
|
66
|
+
# ./database.yml
|
67
|
+
#
|
68
|
+
# This is the same as
|
69
|
+
# `create :profile, :active, id: profile_id`
|
70
|
+
---
|
71
|
+
- type: profile
|
72
|
+
traits:
|
73
|
+
- active
|
74
|
+
params:
|
75
|
+
id: <%= profile_id %>
|
76
|
+
```
|
77
|
+
|
78
|
+
Another opinionated format we use for stubs (`stub_fixture`):
|
79
|
+
|
80
|
+
- `class` for stubbed class
|
81
|
+
- `chain` for messages chain
|
82
|
+
- `actions` for an array of actions for consecutive invocations of the chain
|
83
|
+
|
84
|
+
Every action either `return` some value, or `raise` some exception
|
85
|
+
|
86
|
+
```yaml
|
87
|
+
# ./stubs.yml
|
88
|
+
#
|
89
|
+
# The first invocation acts like
|
90
|
+
# allow(Events).to receive_message_chain(:create).and_return true
|
91
|
+
#
|
92
|
+
# Afterwards it will act like
|
93
|
+
# allow(Events).to receive_message_chain(:create).and_raise AlreadyRegisteredError
|
94
|
+
---
|
95
|
+
- class: Events
|
96
|
+
chain:
|
97
|
+
- create
|
98
|
+
actions:
|
99
|
+
- return: true
|
100
|
+
- raise: AlreadyRegisteredError
|
101
|
+
```
|
102
|
+
|
103
|
+
```graphql
|
104
|
+
mutation {
|
105
|
+
deleteProfile(
|
106
|
+
input: {
|
107
|
+
id: "<%= profile_id %>"
|
108
|
+
}
|
109
|
+
) {
|
110
|
+
success
|
111
|
+
errors {
|
112
|
+
message
|
113
|
+
fields
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
```
|
118
|
+
|
119
|
+
```yaml
|
120
|
+
# ./result.yaml
|
121
|
+
---
|
122
|
+
data:
|
123
|
+
deleteProfile:
|
124
|
+
success: true
|
125
|
+
errors: []
|
126
|
+
```
|
127
|
+
|
128
|
+
With these helpers all the concrete settings can be extracted to fixtures.
|
129
|
+
|
130
|
+
I find it especially helpful when I need to check different edge cases. Instead of polluting a specification with various parameters, I create the sub-folder with "input" and "output" fixtures for every case.
|
131
|
+
|
132
|
+
Looking at the spec I can easily figure out the "structure" of expectation, while looking at fixtures I can check the concrete corner cases.
|
133
|
+
|
134
|
+
## License
|
135
|
+
|
136
|
+
The gem is available as open source under the terms of the [MIT License][license].
|
137
|
+
|
138
|
+
[gem]: https://rubygems.org/gems/fixturama
|
139
|
+
[travis]: https://travis-ci.org/nepalez/fixturama
|
140
|
+
[license]: http://opensource.org/licenses/MIT
|
data/Rakefile
ADDED
data/fixturama.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Gem::Specification.new do |gem|
|
2
|
+
gem.name = "fixturama"
|
3
|
+
gem.version = "0.0.1"
|
4
|
+
gem.author = "Andrew Kozin (nepalez)"
|
5
|
+
gem.email = "andrew.kozin@gmail.com"
|
6
|
+
gem.homepage = "https://github.com/nepalez/fixturama"
|
7
|
+
gem.summary = "A set of helpers to prettify specs with fixtures"
|
8
|
+
gem.license = "MIT"
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
11
|
+
gem.test_files = gem.files.grep(/^spec/)
|
12
|
+
gem.extra_rdoc_files = Dir["README.md", "LICENSE", "CHANGELOG.md"]
|
13
|
+
|
14
|
+
gem.required_ruby_version = ">= 2.2"
|
15
|
+
|
16
|
+
gem.add_runtime_dependency "factory_bot", "~> 4.0"
|
17
|
+
gem.add_runtime_dependency "rspec", "~> 3.0"
|
18
|
+
gem.add_runtime_dependency "hashie", "~> 3.6"
|
19
|
+
|
20
|
+
gem.add_development_dependency "rake", "~> 10"
|
21
|
+
gem.add_development_dependency "rspec-its", "~> 1.2"
|
22
|
+
gem.add_development_dependency "rubocop", "~> 0.49"
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Fixturama
|
2
|
+
module Seed
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def call(opts)
|
6
|
+
opts = Utils.symbolize_hash(opts)
|
7
|
+
type = opts[:type].to_sym
|
8
|
+
traits = Utils.symbolize_array opts[:traits]
|
9
|
+
params = Utils.symbolize_hash opts[:params]
|
10
|
+
|
11
|
+
FactoryBot.create(type, *traits, **params)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fixturama
|
2
|
+
class Stubs
|
3
|
+
class Actions
|
4
|
+
def add(opts)
|
5
|
+
queue.push build(opts)
|
6
|
+
self
|
7
|
+
end
|
8
|
+
|
9
|
+
def call_next
|
10
|
+
queue.pop.tap { |item| queue.push(item.dup) if queue.empty? }.call
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def build(opts)
|
16
|
+
opts = Utils.symbolize_hash(opts)
|
17
|
+
return Raise.new opts[:raise] if opts.key?(:raise)
|
18
|
+
|
19
|
+
Return.new opts[:return]
|
20
|
+
end
|
21
|
+
|
22
|
+
def queue
|
23
|
+
@queue ||= Queue.new
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Fixturama
|
2
|
+
class Stubs
|
3
|
+
require_relative "stubs/actions"
|
4
|
+
require_relative "stubs/raise"
|
5
|
+
require_relative "stubs/return"
|
6
|
+
|
7
|
+
def add(options)
|
8
|
+
options = Utils.symbolize_hash(options)
|
9
|
+
klass, chain, actions = options.values_at(:class, :chain, :actions)
|
10
|
+
|
11
|
+
klass = Utils.constantize(klass)
|
12
|
+
chain = Utils.symbolize_array(chain)
|
13
|
+
actions ||= { return: nil }
|
14
|
+
|
15
|
+
Array(actions).each do |action|
|
16
|
+
collection[[klass, chain]] ||= Actions.new
|
17
|
+
collection[[klass, chain]].add action
|
18
|
+
end
|
19
|
+
|
20
|
+
self
|
21
|
+
end
|
22
|
+
|
23
|
+
def apply(example)
|
24
|
+
collection.each do |(klass, chain), actions|
|
25
|
+
example.send(:allow, klass).to example.receive_message_chain(chain) do
|
26
|
+
actions.call_next
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def collection
|
34
|
+
@collection ||= {}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fixturama
|
2
|
+
module Utils
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def symbolize_hash(data)
|
6
|
+
Hash(data).transform_keys { |key| key.to_s.to_sym }
|
7
|
+
end
|
8
|
+
|
9
|
+
def symbolize_array(data)
|
10
|
+
Array(data).map { |item| item.to_s.to_sym }
|
11
|
+
end
|
12
|
+
|
13
|
+
def constantize(item)
|
14
|
+
item.to_s.constantize
|
15
|
+
end
|
16
|
+
|
17
|
+
def clone(item)
|
18
|
+
item.respond_to?(:dup) ? item.dup : item
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/fixturama.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require "erb"
|
2
|
+
require "factory_bot"
|
3
|
+
require "hashie/mash"
|
4
|
+
require "json"
|
5
|
+
require "rspec"
|
6
|
+
require "yaml"
|
7
|
+
|
8
|
+
module Fixturama
|
9
|
+
require_relative "fixturama/utils"
|
10
|
+
require_relative "fixturama/stubs"
|
11
|
+
require_relative "fixturama/seed"
|
12
|
+
|
13
|
+
def stub_fixture(path, **opts)
|
14
|
+
items = load_fixture(path, **opts)
|
15
|
+
raise "The fixture should contain an array" unless items.is_a?(Array)
|
16
|
+
|
17
|
+
items.each { |item| fixturama_stubs.add(item) }
|
18
|
+
fixturama_stubs.apply(self)
|
19
|
+
end
|
20
|
+
|
21
|
+
def seed_fixture(path, **opts)
|
22
|
+
Array(load_fixture(path, **opts)).each { |item| Seed.call(item) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def load_fixture(path, **opts)
|
26
|
+
extname = Pathname.new(path).extname
|
27
|
+
|
28
|
+
read_fixture(path, **opts).tap do |content|
|
29
|
+
return YAML.load(content) if %w[.yaml .yml].include?(extname)
|
30
|
+
return JSON.parse(content) if extname == ".json"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def read_fixture(path, **opts)
|
35
|
+
content = File.read(path)
|
36
|
+
hashie = Hashie::Mash.new(opts)
|
37
|
+
bindings = hashie.instance_eval { binding }
|
38
|
+
|
39
|
+
ERB.new(content).result(bindings)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def fixturama_stubs
|
45
|
+
@fixturama_stubs ||= Stubs.new
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
RSpec.describe "load_fixture" do
|
2
|
+
let(:expected) { { "foo" => { "bar" => 42 } } }
|
3
|
+
|
4
|
+
context "YAML" do
|
5
|
+
subject { load_fixture("#{__dir__}/data.yaml", id: 42) }
|
6
|
+
|
7
|
+
it { is_expected.to eq expected }
|
8
|
+
end
|
9
|
+
|
10
|
+
context "YML" do
|
11
|
+
subject { load_fixture("#{__dir__}/data.yml", id: 42) }
|
12
|
+
|
13
|
+
it { is_expected.to eq expected }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "JSON" do
|
17
|
+
subject { load_fixture("#{__dir__}/data.json", id: 42) }
|
18
|
+
|
19
|
+
it { is_expected.to eq expected }
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
RSpec.describe "seed_fixture" do
|
2
|
+
subject { seed_fixture "#{__dir__}/seed.yml" }
|
3
|
+
|
4
|
+
before do
|
5
|
+
FactoryBot.define do
|
6
|
+
factory :foo, class: Hash do
|
7
|
+
transient do
|
8
|
+
bar { 0 }
|
9
|
+
baz { 0 }
|
10
|
+
qux { 0 }
|
11
|
+
end
|
12
|
+
|
13
|
+
trait :bar do
|
14
|
+
bar { 99 }
|
15
|
+
end
|
16
|
+
|
17
|
+
trait :baz do
|
18
|
+
baz { 77 }
|
19
|
+
end
|
20
|
+
|
21
|
+
skip_create
|
22
|
+
initialize_with { { bar: bar, baz: baz, qux: qux } }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "runs the factory", aggregate_failures: true do
|
28
|
+
expect(FactoryBot).to receive(:create).and_return(bar: 99, baz: 77, qux: 42)
|
29
|
+
|
30
|
+
subject
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
RSpec.describe "stub_fixture" do
|
2
|
+
subject { Foo.new.bar }
|
3
|
+
|
4
|
+
before do
|
5
|
+
class Foo
|
6
|
+
def bar
|
7
|
+
"bar"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "without stubbing" do
|
13
|
+
it { is_expected.to eq "bar" }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "with first invocation" do
|
17
|
+
before { stub_fixture "#{__dir__}/stub.yml" }
|
18
|
+
|
19
|
+
it { is_expected.to eq "baz" }
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with next_day invocation" do
|
23
|
+
before do
|
24
|
+
stub_fixture "#{__dir__}/stub.yml"
|
25
|
+
Foo.new.bar
|
26
|
+
end
|
27
|
+
|
28
|
+
it "raises an exception" do
|
29
|
+
expect { subject }.to raise_error StandardError
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "with later invocations" do
|
34
|
+
before do
|
35
|
+
stub_fixture "#{__dir__}/stub.yml"
|
36
|
+
3.times do begin
|
37
|
+
Foo.new.bar
|
38
|
+
rescue
|
39
|
+
nil
|
40
|
+
end end
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises an exception" do
|
44
|
+
expect { subject }.to raise_error StandardError
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
begin
|
2
|
+
require "pry"
|
3
|
+
rescue LoadError
|
4
|
+
nil
|
5
|
+
end
|
6
|
+
|
7
|
+
require "bundler/setup"
|
8
|
+
require "fixturama/rspec"
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
# Enable flags like --only-failures and --next-failure
|
12
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
13
|
+
|
14
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
15
|
+
config.disable_monkey_patching!
|
16
|
+
|
17
|
+
config.expect_with :rspec do |c|
|
18
|
+
c.syntax = :expect
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fixturama
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Kozin (nepalez)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: factory_bot
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hashie
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.6'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-its
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.49'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.49'
|
97
|
+
description:
|
98
|
+
email: andrew.kozin@gmail.com
|
99
|
+
executables: []
|
100
|
+
extensions: []
|
101
|
+
extra_rdoc_files:
|
102
|
+
- README.md
|
103
|
+
- CHANGELOG.md
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- ".travis.yml"
|
109
|
+
- CHANGELOG.md
|
110
|
+
- Gemfile
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- fixturama.gemspec
|
115
|
+
- lib/fixturama.rb
|
116
|
+
- lib/fixturama/rspec.rb
|
117
|
+
- lib/fixturama/seed.rb
|
118
|
+
- lib/fixturama/stubs.rb
|
119
|
+
- lib/fixturama/stubs/actions.rb
|
120
|
+
- lib/fixturama/stubs/raise.rb
|
121
|
+
- lib/fixturama/stubs/return.rb
|
122
|
+
- lib/fixturama/utils.rb
|
123
|
+
- spec/fixturama/load_fixture/_spec.rb
|
124
|
+
- spec/fixturama/load_fixture/data.json
|
125
|
+
- spec/fixturama/load_fixture/data.yaml
|
126
|
+
- spec/fixturama/load_fixture/data.yml
|
127
|
+
- spec/fixturama/seed_fixture/_spec.rb
|
128
|
+
- spec/fixturama/seed_fixture/seed.yml
|
129
|
+
- spec/fixturama/stub_fixture/_spec.rb
|
130
|
+
- spec/fixturama/stub_fixture/stub.yml
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
homepage: https://github.com/nepalez/fixturama
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '2.2'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubygems_version: 3.0.1
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: A set of helpers to prettify specs with fixtures
|
155
|
+
test_files:
|
156
|
+
- spec/fixturama/load_fixture/_spec.rb
|
157
|
+
- spec/fixturama/load_fixture/data.json
|
158
|
+
- spec/fixturama/load_fixture/data.yaml
|
159
|
+
- spec/fixturama/load_fixture/data.yml
|
160
|
+
- spec/fixturama/seed_fixture/_spec.rb
|
161
|
+
- spec/fixturama/seed_fixture/seed.yml
|
162
|
+
- spec/fixturama/stub_fixture/_spec.rb
|
163
|
+
- spec/fixturama/stub_fixture/stub.yml
|
164
|
+
- spec/spec_helper.rb
|