esse-rspec 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aeeba40267c5b5b1dbda8172ae71c3240fe5a1ffab9c7f9f7d0124d8a374aabe
4
+ data.tar.gz: 062bcb563387b34138a01286464093d32fa92dc6143170ed61b628d9e6d4b8f4
5
+ SHA512:
6
+ metadata.gz: e8112a8b570dfec71fdba8328db731884aa1de77a3409fb220fccc8b42c8483f523f5feee5b840c1fd35a5f4ef898fe4e4b7f4ebae2f0e1d753f8d15d652b3e5
7
+ data.tar.gz: 01e7c324f337dd2d790f332f304bcdb6f23fcf663f5cf0658c1ac99f399f771c55b1b6baec1f7db2b3514e430ff163203ac3325d77dc209f6a9c711f748c12c1
data/.rubocop.yml ADDED
@@ -0,0 +1,26 @@
1
+ inherit_mode:
2
+ merge:
3
+ - Exclude
4
+
5
+ require:
6
+ - rubocop-performance
7
+ - rubocop-rspec
8
+ - standard/cop/block_single_line_braces
9
+
10
+ inherit_gem:
11
+ standard: config/base.yml
12
+
13
+ AllCops:
14
+ TargetRubyVersion: 2.5
15
+ SuggestExtensions: false
16
+ Exclude:
17
+ - "db/**/*"
18
+ - "tmp/**/*"
19
+ - "vendor/**/*"
20
+ NewCops: enable
21
+
22
+ RSpec/MultipleExpectations:
23
+ Enabled: false
24
+
25
+ RSpec/ExampleLength:
26
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## 0.0.1 - 2023-11-15
8
+ The first release of the Esse::RSpec
9
+ * stub_esse_class helper
10
+ * stub_esse_index helper
11
+ * stub_esse_search helper
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "esse", "~> 0.2.4"
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,99 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ esse-rspec (0.0.1)
5
+ esse (>= 0.2.4)
6
+ rspec (~> 3.12)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ coderay (1.1.3)
13
+ diff-lcs (1.5.0)
14
+ esse (0.2.4)
15
+ multi_json
16
+ thor (>= 0.19)
17
+ json (2.6.3)
18
+ language_server-protocol (3.17.0.3)
19
+ lint_roller (1.1.0)
20
+ method_source (1.0.0)
21
+ multi_json (1.15.0)
22
+ parallel (1.23.0)
23
+ parser (3.2.2.4)
24
+ ast (~> 2.4.1)
25
+ racc
26
+ pry (0.14.2)
27
+ coderay (~> 1.1)
28
+ method_source (~> 1.0)
29
+ racc (1.7.3)
30
+ rainbow (3.1.1)
31
+ regexp_parser (2.8.2)
32
+ rexml (3.2.6)
33
+ rspec (3.12.0)
34
+ rspec-core (~> 3.12.0)
35
+ rspec-expectations (~> 3.12.0)
36
+ rspec-mocks (~> 3.12.0)
37
+ rspec-core (3.12.2)
38
+ rspec-support (~> 3.12.0)
39
+ rspec-expectations (3.12.3)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.12.0)
42
+ rspec-mocks (3.12.6)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.12.0)
45
+ rspec-support (3.12.1)
46
+ rubocop (1.57.2)
47
+ json (~> 2.3)
48
+ language_server-protocol (>= 3.17.0)
49
+ parallel (~> 1.10)
50
+ parser (>= 3.2.2.4)
51
+ rainbow (>= 2.2.2, < 4.0)
52
+ regexp_parser (>= 1.8, < 3.0)
53
+ rexml (>= 3.2.5, < 4.0)
54
+ rubocop-ast (>= 1.28.1, < 2.0)
55
+ ruby-progressbar (~> 1.7)
56
+ unicode-display_width (>= 2.4.0, < 3.0)
57
+ rubocop-ast (1.30.0)
58
+ parser (>= 3.2.1.0)
59
+ rubocop-capybara (2.19.0)
60
+ rubocop (~> 1.41)
61
+ rubocop-factory_bot (2.24.0)
62
+ rubocop (~> 1.33)
63
+ rubocop-performance (1.19.1)
64
+ rubocop (>= 1.7.0, < 2.0)
65
+ rubocop-ast (>= 0.4.0)
66
+ rubocop-rspec (2.25.0)
67
+ rubocop (~> 1.40)
68
+ rubocop-capybara (~> 2.17)
69
+ rubocop-factory_bot (~> 2.22)
70
+ ruby-progressbar (1.13.0)
71
+ standard (1.32.0)
72
+ language_server-protocol (~> 3.17.0.2)
73
+ lint_roller (~> 1.0)
74
+ rubocop (~> 1.57.2)
75
+ standard-custom (~> 1.0.0)
76
+ standard-performance (~> 1.2)
77
+ standard-custom (1.0.2)
78
+ lint_roller (~> 1.0)
79
+ rubocop (~> 1.50)
80
+ standard-performance (1.2.1)
81
+ lint_roller (~> 1.1)
82
+ rubocop-performance (~> 1.19.1)
83
+ thor (1.3.0)
84
+ unicode-display_width (2.5.0)
85
+
86
+ PLATFORMS
87
+ x86_64-linux
88
+
89
+ DEPENDENCIES
90
+ esse (~> 0.2.4)
91
+ esse-rspec!
92
+ pry
93
+ rubocop (~> 1.20)
94
+ rubocop-performance (~> 1.11, >= 1.11.5)
95
+ rubocop-rspec (~> 2.4)
96
+ standard (~> 1.3)
97
+
98
+ BUNDLED WITH
99
+ 2.4.13
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Marcos G. Zimmermann
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # esse-rspec
2
+
3
+ RSpec and testing support for [esse](https://github.com/marcosgz/esse)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'esse-rspec'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ Require the `esse/rspec` file in your `spec_helper.rb` file:
22
+
23
+ ```ruby
24
+ require 'esse/rspec'
25
+ ```
26
+
27
+ ### Stubbing Esse::Index classes
28
+
29
+ ```ruby
30
+ before do
31
+ stub_esse_index('products') do
32
+ repository :product, const: true do
33
+ # ...
34
+ end
35
+ end
36
+ end
37
+
38
+ it 'defines the ProductsIndex class' do
39
+ expect(ProductsIndex).to be < Esse::Index
40
+ expect(ProductsIndex::Product).to be < Esse::Index::Repository
41
+ end
42
+ ```
43
+
44
+ ### Stubbing search requests
45
+
46
+ ```ruby
47
+ before do
48
+ stub_esse_search(:default, "geos_*", body: {query: {match_all: {}}, size: 10}) do
49
+ {
50
+ "hits" => {
51
+ "total" => {
52
+ "value" => 1000
53
+ },
54
+ "hits" => [{}] * 20
55
+ }
56
+ }
57
+ end
58
+ end
59
+
60
+ it 'returns a Query using the stubbed response' do
61
+ query = ProductsIndex.search('geos_*', body: {query: {match_all: {}}, size: 10})
62
+ expect(query.responsee.total).to eq(1000)
63
+ end
64
+ ```
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Helper methods to create Index classes
4
+ module Esse
5
+ module RSpec
6
+ module ClassMethods
7
+ def stub_esse_index(name, superclass = nil, &block)
8
+ superclass ||= ::Esse::Index
9
+ klass_name = "#{::Esse::Hstring.new(name).camelize.sub(/Index$/, "")}Index"
10
+ klass = stub_esse_class(klass_name, superclass)
11
+ klass.class_eval(&block) if block
12
+ klass
13
+ end
14
+
15
+ def stub_esse_class(name, superclass = nil, &block)
16
+ klass = Class.new(superclass || Object, &block)
17
+ stub_const(Esse::Hstring.new(name).camelize.to_s, klass)
18
+ end
19
+
20
+ def stub_esse_search(cluster_name, *indexes, **definition)
21
+ cluster = Esse.cluster(cluster_name)
22
+ transport = cluster.api
23
+ definition[:index] ||= Esse::Search::Query.normalize_indices(*indexes)
24
+ response = yield
25
+ allow(cluster).to receive(:api).and_return(transport)
26
+ allow(transport).to receive(:search).with(**definition).and_return(response)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Esse
4
+ module RSpec
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
data/lib/esse/rspec.rb ADDED
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "esse"
4
+
5
+ require_relative "rspec/version"
6
+ require_relative "rspec/class_methods"
7
+
8
+ module Esse
9
+ module RSpec
10
+ end
11
+ end
12
+
13
+ ::RSpec.configure do |config|
14
+ config.include Esse::RSpec::ClassMethods
15
+ end
data/lib/esse-rspec.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "esse/rspec"
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: esse-rspec
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Marcos G. Zimmermann
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-11-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: esse
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.4
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.12'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: standard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.20'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.20'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-performance
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.11'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 1.11.5
93
+ type: :development
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '1.11'
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: 1.11.5
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop-rspec
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '2.4'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '2.4'
117
+ description: RSpec for Esse
118
+ email:
119
+ - mgzmaster@gmail.com
120
+ executables: []
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - ".rubocop.yml"
125
+ - CHANGELOG.md
126
+ - Gemfile
127
+ - Gemfile.lock
128
+ - LICENSE
129
+ - README.md
130
+ - lib/esse-rspec.rb
131
+ - lib/esse/rspec.rb
132
+ - lib/esse/rspec/class_methods.rb
133
+ - lib/esse/rspec/version.rb
134
+ homepage: https://github.com/marcosgz/esse-rspec
135
+ licenses:
136
+ - MIT
137
+ metadata:
138
+ homepage_uri: https://github.com/marcosgz/esse-rspec
139
+ source_code_uri: https://github.com/marcosgz/esse-rspec
140
+ changelog_uri: https://github.com/marcosgz/esse-rspec/blob/main/CHANGELOG.md
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: 2.5.0
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubygems_version: 3.3.7
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: RSpec for Esse
160
+ test_files: []