fixturama 0.0.7 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +100 -0
- data/README.md +71 -3
- data/lib/fixturama.rb +49 -20
- data/lib/fixturama/changes.rb +72 -0
- data/lib/fixturama/changes/base.rb +28 -0
- data/lib/fixturama/changes/chain.rb +64 -0
- data/lib/fixturama/changes/chain/actions.rb +31 -0
- data/lib/fixturama/changes/chain/arguments.rb +59 -0
- data/lib/fixturama/changes/chain/raise_action.rb +43 -0
- data/lib/fixturama/changes/chain/return_action.rb +33 -0
- data/lib/fixturama/changes/const.rb +30 -0
- data/lib/fixturama/changes/env.rb +35 -0
- data/lib/fixturama/changes/request.rb +91 -0
- data/lib/fixturama/changes/request/response.rb +62 -0
- data/lib/fixturama/changes/request/responses.rb +22 -0
- data/lib/fixturama/changes/seed.rb +39 -0
- data/lib/fixturama/config.rb +5 -0
- data/lib/fixturama/fixture_error.rb +31 -0
- data/lib/fixturama/loader.rb +1 -0
- data/lib/fixturama/loader/context.rb +1 -0
- data/lib/fixturama/loader/value.rb +1 -0
- data/lib/fixturama/version.rb +4 -0
- metadata +80 -50
- data/.gitignore +0 -12
- data/.rspec +0 -2
- data/.rubocop.yml +0 -22
- data/.travis.yml +0 -23
- data/Gemfile +0 -9
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -6
- data/fixturama.gemspec +0 -23
- data/lib/fixturama/seed.rb +0 -15
- data/lib/fixturama/stubs.rb +0 -57
- data/lib/fixturama/stubs/chain.rb +0 -89
- data/lib/fixturama/stubs/chain/actions.rb +0 -39
- data/lib/fixturama/stubs/chain/actions/raise.rb +0 -21
- data/lib/fixturama/stubs/chain/actions/return.rb +0 -23
- data/lib/fixturama/stubs/chain/arguments.rb +0 -86
- data/lib/fixturama/stubs/const.rb +0 -42
- data/lib/fixturama/utils.rb +0 -39
- data/spec/fixturama/load_fixture/_spec.rb +0 -53
- data/spec/fixturama/load_fixture/data.json +0 -5
- data/spec/fixturama/load_fixture/data.yaml +0 -3
- data/spec/fixturama/load_fixture/data.yml +0 -3
- data/spec/fixturama/seed_fixture/_spec.rb +0 -33
- data/spec/fixturama/seed_fixture/seed.yml +0 -16
- data/spec/fixturama/stub_fixture/_spec.rb +0 -96
- data/spec/fixturama/stub_fixture/stub.yml +0 -60
- data/spec/spec_helper.rb +0 -26
@@ -1,96 +0,0 @@
|
|
1
|
-
RSpec.describe "stub_fixture" do
|
2
|
-
subject { arguments.map { |argument| Payment.new.pay(argument) } }
|
3
|
-
|
4
|
-
before do
|
5
|
-
class Payment
|
6
|
-
def pay(_)
|
7
|
-
5
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
context "without stubbing" do
|
13
|
-
let(:arguments) { [0] }
|
14
|
-
|
15
|
-
it { is_expected.to eq [5] }
|
16
|
-
end
|
17
|
-
|
18
|
-
context "when message chain stubbed" do
|
19
|
-
before { stub_fixture "#{__dir__}/stub.yml" }
|
20
|
-
|
21
|
-
context "with a :raise option" do
|
22
|
-
let(:arguments) { [0] }
|
23
|
-
|
24
|
-
it "raises an exception" do
|
25
|
-
expect { subject }.to raise_error ArgumentError
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "with a :return option" do
|
30
|
-
let(:arguments) { [1] }
|
31
|
-
|
32
|
-
it "returns stubbed value" do
|
33
|
-
expect(subject).to eq [8]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "with several actions" do
|
38
|
-
let(:arguments) { [2] * 4 }
|
39
|
-
|
40
|
-
it "calls the consecutive actions and then repeates the last one" do
|
41
|
-
expect(subject).to eq [4, 2, 0, 0]
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context "with multi-count actions" do
|
46
|
-
let(:arguments) { [3] * 4 }
|
47
|
-
|
48
|
-
it "repeats the action a specified number of times" do
|
49
|
-
expect(subject).to eq [6, 6, 0, 0]
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context "with several arguments" do
|
54
|
-
let(:arguments) { [2, 3, 2, 3, 2, 3] }
|
55
|
-
|
56
|
-
it "counts actions for every stub in isolation from the others" do
|
57
|
-
expect(subject).to eq [4, 6, 2, 6, 0, 0]
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context "with partially defined options" do
|
62
|
-
subject { Payment.new.pay(10, overdraft: true, notiy: true) }
|
63
|
-
|
64
|
-
it "uses the stub" do
|
65
|
-
expect(subject).to eq(-5)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "when options differ" do
|
70
|
-
subject { Payment.new.pay(10, overdraft: false) }
|
71
|
-
|
72
|
-
it "uses universal stub" do
|
73
|
-
expect(subject).to eq(-1)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context "with unspecified argument" do
|
78
|
-
let(:arguments) { [4] }
|
79
|
-
|
80
|
-
it "uses universal stub" do
|
81
|
-
expect(subject).to eq [-1]
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
context "when constant stubbed" do
|
87
|
-
before do
|
88
|
-
TIMEOUT = 20
|
89
|
-
stub_fixture "#{__dir__}/stub.yml"
|
90
|
-
end
|
91
|
-
|
92
|
-
it "stubs the constant" do
|
93
|
-
expect(TIMEOUT).to eq 10
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
---
|
2
|
-
- class: Payment
|
3
|
-
chain:
|
4
|
-
- new
|
5
|
-
- pay
|
6
|
-
actions:
|
7
|
-
- return: -1
|
8
|
-
|
9
|
-
- class: Payment
|
10
|
-
chain:
|
11
|
-
- new
|
12
|
-
- pay
|
13
|
-
arguments:
|
14
|
-
- 0
|
15
|
-
actions:
|
16
|
-
- raise: ArgumentError
|
17
|
-
|
18
|
-
- class: Payment
|
19
|
-
chain:
|
20
|
-
- new
|
21
|
-
- pay
|
22
|
-
arguments:
|
23
|
-
- 1
|
24
|
-
actions:
|
25
|
-
- return: 8
|
26
|
-
|
27
|
-
- class: Payment
|
28
|
-
chain:
|
29
|
-
- new
|
30
|
-
- pay
|
31
|
-
arguments:
|
32
|
-
- 2
|
33
|
-
actions:
|
34
|
-
- return: 4
|
35
|
-
- return: 2
|
36
|
-
- return: 0
|
37
|
-
|
38
|
-
- object: Payment.itself
|
39
|
-
chain:
|
40
|
-
- new
|
41
|
-
- pay
|
42
|
-
arguments:
|
43
|
-
- 3
|
44
|
-
actions:
|
45
|
-
- return: 6
|
46
|
-
repeat: 2
|
47
|
-
- return: 0
|
48
|
-
|
49
|
-
- class: Payment
|
50
|
-
chain:
|
51
|
-
- new
|
52
|
-
- pay
|
53
|
-
arguments:
|
54
|
-
- 10
|
55
|
-
- :overdraft: true
|
56
|
-
actions:
|
57
|
-
- return: -5
|
58
|
-
|
59
|
-
- const: TIMEOUT
|
60
|
-
value: 10
|
data/spec/spec_helper.rb
DELETED
@@ -1,26 +0,0 @@
|
|
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
|
-
|
21
|
-
config.around do |example|
|
22
|
-
module Test; end
|
23
|
-
example.run
|
24
|
-
Object.send(:remove_const, :Test)
|
25
|
-
end
|
26
|
-
end
|