shoegaze 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +190 -0
  3. data/lib/shoegaze.rb +15 -0
  4. data/lib/shoegaze/datastore.rb +36 -0
  5. data/lib/shoegaze/implementation.rb +71 -0
  6. data/lib/shoegaze/mock.rb +34 -0
  7. data/lib/shoegaze/model.rb +165 -0
  8. data/lib/shoegaze/proxy.rb +24 -0
  9. data/lib/shoegaze/proxy/interface.rb +169 -0
  10. data/lib/shoegaze/proxy/template.rb +61 -0
  11. data/lib/shoegaze/scenario.rb +100 -0
  12. data/lib/shoegaze/scenario/mock.rb +52 -0
  13. data/lib/shoegaze/scenario/orchestrator.rb +167 -0
  14. data/lib/shoegaze/version.rb +3 -0
  15. data/spec/features/basic_class_method_spec.rb +55 -0
  16. data/spec/features/basic_instance_method_spec.rb +53 -0
  17. data/spec/features/class_default_scenario_spec.rb +51 -0
  18. data/spec/features/class_method_block_argument_spec.rb +61 -0
  19. data/spec/features/data_store_spec.rb +73 -0
  20. data/spec/features/instance_customized_initializer.rb +24 -0
  21. data/spec/features/instance_default_scenario_spec.rb +51 -0
  22. data/spec/features/instance_method_block_argument_spec.rb +60 -0
  23. data/spec/features/nested_class_method_spec.rb +47 -0
  24. data/spec/features/nested_instance_method_spec.rb +47 -0
  25. data/spec/shoegaze/datastore_spec.rb +38 -0
  26. data/spec/shoegaze/implementation_spec.rb +97 -0
  27. data/spec/shoegaze/mock_spec.rb +42 -0
  28. data/spec/shoegaze/proxy/interface_spec.rb +88 -0
  29. data/spec/shoegaze/proxy/template_spec.rb +36 -0
  30. data/spec/shoegaze/proxy_spec.rb +18 -0
  31. data/spec/shoegaze/scenario/mock_spec.rb +31 -0
  32. data/spec/shoegaze/scenario/orchestrator_spec.rb +145 -0
  33. data/spec/shoegaze/scenario_spec.rb +74 -0
  34. metadata +133 -0
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+
3
+ describe Shoegaze::Scenario do
4
+ let!(:method_name){ :one_weird_trick }
5
+
6
+ describe "#initialize" do
7
+ it "stores instance variables" do
8
+ instance = Shoegaze::Scenario.new(method_name){}
9
+ expect(instance.instance_variable_get(:@_method_name)).to eq(method_name)
10
+ end
11
+
12
+ it "evaluates the provided block" do
13
+ expect_any_instance_of(Shoegaze::Scenario).to receive(:bananas)
14
+
15
+ Shoegaze::Scenario.new(method_name) do
16
+ bananas
17
+ end
18
+ end
19
+ end
20
+
21
+ describe "#representer" do
22
+ let!(:scenario){ Shoegaze::Scenario.new(method_name){} }
23
+
24
+ describe "with a representer passed in" do
25
+ let!(:fake_representer_class){ double }
26
+
27
+ it "sets and returns the representer class" do
28
+ expect(scenario.representer(fake_representer_class)).to eq(fake_representer_class)
29
+ expect(scenario.representer).to eq(fake_representer_class)
30
+ end
31
+ end
32
+
33
+ describe "with a block passed in" do
34
+ it "evaluates the block as a Representer::Decorator" do
35
+ scenario.representer do
36
+ include Representable::JSON
37
+
38
+ property :cows
39
+ end
40
+
41
+ expect(scenario.representer.ancestors[1]).to eq(Representable::JSON)
42
+ end
43
+ end
44
+ end
45
+
46
+ describe "#self.represent_method" do
47
+ let!(:scenario){ Shoegaze::Scenario.new(method_name){} }
48
+
49
+ describe "with a representation method passed in" do
50
+ it "sets the representation method" do
51
+ scenario.represent_method :as_cow
52
+
53
+ expect(scenario.represent_method).to eq(:as_cow)
54
+ end
55
+ end
56
+ end
57
+
58
+ describe "#self.datasource" do
59
+ let!(:scenario){ Shoegaze::Scenario.new(method_name){} }
60
+ let!(:test_block){ proc { } }
61
+
62
+ it "stores and returns the block" do
63
+ expect(scenario.datasource(&test_block)).to eq(test_block)
64
+ expect(scenario.instance_variable_get(:@_datasource)).to eq(test_block)
65
+ end
66
+
67
+ describe "#to_proc" do
68
+ it "returns the stored datasource" do
69
+ expect(scenario.datasource(&test_block)).to eq(test_block)
70
+ expect(scenario.to_proc).to eq(test_block)
71
+ end
72
+ end
73
+ end
74
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shoegaze
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dan Connor
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-10-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: factory_bot
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '6.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '6.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: representable
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: multi_json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '1.12'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '1.12'
69
+ description: Create mocks of modules (especially clients) with easily-defined scenarios
70
+ (success, invalid, etc)
71
+ email:
72
+ - dan@danconnor.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - README.md
78
+ - lib/shoegaze.rb
79
+ - lib/shoegaze/datastore.rb
80
+ - lib/shoegaze/implementation.rb
81
+ - lib/shoegaze/mock.rb
82
+ - lib/shoegaze/model.rb
83
+ - lib/shoegaze/proxy.rb
84
+ - lib/shoegaze/proxy/interface.rb
85
+ - lib/shoegaze/proxy/template.rb
86
+ - lib/shoegaze/scenario.rb
87
+ - lib/shoegaze/scenario/mock.rb
88
+ - lib/shoegaze/scenario/orchestrator.rb
89
+ - lib/shoegaze/version.rb
90
+ - spec/features/basic_class_method_spec.rb
91
+ - spec/features/basic_instance_method_spec.rb
92
+ - spec/features/class_default_scenario_spec.rb
93
+ - spec/features/class_method_block_argument_spec.rb
94
+ - spec/features/data_store_spec.rb
95
+ - spec/features/instance_customized_initializer.rb
96
+ - spec/features/instance_default_scenario_spec.rb
97
+ - spec/features/instance_method_block_argument_spec.rb
98
+ - spec/features/nested_class_method_spec.rb
99
+ - spec/features/nested_instance_method_spec.rb
100
+ - spec/shoegaze/datastore_spec.rb
101
+ - spec/shoegaze/implementation_spec.rb
102
+ - spec/shoegaze/mock_spec.rb
103
+ - spec/shoegaze/proxy/interface_spec.rb
104
+ - spec/shoegaze/proxy/template_spec.rb
105
+ - spec/shoegaze/proxy_spec.rb
106
+ - spec/shoegaze/scenario/mock_spec.rb
107
+ - spec/shoegaze/scenario/orchestrator_spec.rb
108
+ - spec/shoegaze/scenario_spec.rb
109
+ homepage: https://github.com/compose/shoegaze
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubygems_version: 3.1.4
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Create mocks of modules (especially clients) with easily-defined scenarios
132
+ (success, invalid, etc)
133
+ test_files: []