fixturama 0.0.7 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +100 -0
  3. data/README.md +71 -3
  4. data/lib/fixturama.rb +49 -20
  5. data/lib/fixturama/changes.rb +72 -0
  6. data/lib/fixturama/changes/base.rb +28 -0
  7. data/lib/fixturama/changes/chain.rb +64 -0
  8. data/lib/fixturama/changes/chain/actions.rb +31 -0
  9. data/lib/fixturama/changes/chain/arguments.rb +59 -0
  10. data/lib/fixturama/changes/chain/raise_action.rb +43 -0
  11. data/lib/fixturama/changes/chain/return_action.rb +33 -0
  12. data/lib/fixturama/changes/const.rb +30 -0
  13. data/lib/fixturama/changes/env.rb +35 -0
  14. data/lib/fixturama/changes/request.rb +91 -0
  15. data/lib/fixturama/changes/request/response.rb +62 -0
  16. data/lib/fixturama/changes/request/responses.rb +22 -0
  17. data/lib/fixturama/changes/seed.rb +39 -0
  18. data/lib/fixturama/config.rb +5 -0
  19. data/lib/fixturama/fixture_error.rb +31 -0
  20. data/lib/fixturama/loader.rb +1 -0
  21. data/lib/fixturama/loader/context.rb +1 -0
  22. data/lib/fixturama/loader/value.rb +1 -0
  23. data/lib/fixturama/version.rb +4 -0
  24. metadata +80 -50
  25. data/.gitignore +0 -12
  26. data/.rspec +0 -2
  27. data/.rubocop.yml +0 -22
  28. data/.travis.yml +0 -23
  29. data/Gemfile +0 -9
  30. data/LICENSE.txt +0 -21
  31. data/Rakefile +0 -6
  32. data/fixturama.gemspec +0 -23
  33. data/lib/fixturama/seed.rb +0 -15
  34. data/lib/fixturama/stubs.rb +0 -57
  35. data/lib/fixturama/stubs/chain.rb +0 -89
  36. data/lib/fixturama/stubs/chain/actions.rb +0 -39
  37. data/lib/fixturama/stubs/chain/actions/raise.rb +0 -21
  38. data/lib/fixturama/stubs/chain/actions/return.rb +0 -23
  39. data/lib/fixturama/stubs/chain/arguments.rb +0 -86
  40. data/lib/fixturama/stubs/const.rb +0 -42
  41. data/lib/fixturama/utils.rb +0 -39
  42. data/spec/fixturama/load_fixture/_spec.rb +0 -53
  43. data/spec/fixturama/load_fixture/data.json +0 -5
  44. data/spec/fixturama/load_fixture/data.yaml +0 -3
  45. data/spec/fixturama/load_fixture/data.yml +0 -3
  46. data/spec/fixturama/seed_fixture/_spec.rb +0 -33
  47. data/spec/fixturama/seed_fixture/seed.yml +0 -16
  48. data/spec/fixturama/stub_fixture/_spec.rb +0 -96
  49. data/spec/fixturama/stub_fixture/stub.yml +0 -60
  50. data/spec/spec_helper.rb +0 -26
@@ -1,16 +0,0 @@
1
- ---
2
- - type: foo
3
- traits:
4
- - baz
5
- params:
6
- qux: 42
7
-
8
- - type: foo
9
- count: 3
10
- traits:
11
- - bar
12
-
13
- - type: foo
14
- count: 0
15
- traits:
16
- - baz
@@ -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