rspec-prosopite 0.1.0

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: 54fc0df85ee71be1d78527d323716260477e4e260ce0bd99e3a6db2d854ebe12
4
+ data.tar.gz: ecdf05b07786bc132d765c2c98faadfe1d7a33e68d4310f59ff2f38e24420455
5
+ SHA512:
6
+ metadata.gz: 90bd5947ba8530f8cc77b05f72acb496a6d97ae1c75872929eca9f4442c62993a4a2c14a668aca6dd71628fb61bad15dc853a5aee95f72d72702a2d395a6993d
7
+ data.tar.gz: c5df55b6cc1ee3857fbda1dba487828717f40ce934e24588731b585f5b031af1c0d87d4f2df7a7e1325f6f2d195ea658caa3bf04a2da55857bd66b12263a910d
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,9 @@
1
+ fix: true
2
+ parallel: true
3
+ format: progress
4
+ ruby_version: 2.7
5
+ default_ignores: false
6
+
7
+ ignore:
8
+ - 'spec/**/*':
9
+ - Layout/AlignHash
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-09-13
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ gem "rake", "~> 13.0"
8
+ gem "rspec", "~> 3.0"
9
+ gem "standard", "~> 1.3"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Hiroshi Kajisha
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,53 @@
1
+ # RSpec::Prosopite
2
+
3
+ ## Installation
4
+
5
+ Install the gem and add to the application's Gemfile by executing:
6
+
7
+ $ bundle add rspec-prosopite
8
+
9
+ If bundler is not being used to manage dependencies, install the gem by executing:
10
+
11
+ $ gem install rspec-prosopite
12
+
13
+ ## Usage
14
+
15
+ ### perform_queries matcher
16
+
17
+ Use `perform_queries` matcher to detect N+1 query in your spec.
18
+
19
+ ```ruby
20
+ it "N+1" do
21
+ expect { suspicious_something }.to perform_queries
22
+ end
23
+ ```
24
+
25
+ ### allow_stack_paths
26
+
27
+ If you want to allow some N+1, use allow_stack_paths or ignore_queries, like this:
28
+
29
+ Except N+1 query in the method:
30
+ ```ruby
31
+ expect { suspicious_something }.to perform_queries.allow_stack_paths([/method_name/])
32
+ ```
33
+
34
+ Except N+1 query by SQL:
35
+ ```ruby
36
+ expect { suspicious_something }.to perform_queries.ignore_queries([/SELECT \* FROM users/])
37
+ ```
38
+
39
+ More details about `allow_stack_paths` and `ignore_queries`, see [prosopite](https://github.com/charkost/prosopite).
40
+
41
+ ## Development
42
+
43
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
44
+
45
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kajisha/rspec-prosopite.
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[spec standard]
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ ::RSpec::Matchers.define :perform_queries do
4
+ supports_block_expectations
5
+
6
+ chain :ignore_queries do |queries|
7
+ Prosopite.ignore_queries = queries
8
+ end
9
+
10
+ chain :allow_stack_paths do |paths|
11
+ Prosopite.allow_stack_paths = paths
12
+ end
13
+
14
+ match(notify_expectation_failures: true) do |actual|
15
+ raise ArgumentError, "Block is required" unless actual.is_a?(Proc)
16
+
17
+ begin
18
+ Prosopite.scan { actual.call }
19
+ ensure
20
+ Prosopite.ignore_queries = []
21
+ Prosopite.allow_stack_paths = []
22
+ end
23
+ end
24
+ end
25
+
26
+ ::RSpec.configure do |config|
27
+ config.before(:suite) do
28
+ Prosopite.raise = true
29
+ end
30
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec
4
+ module Prosopite
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rspec-prosopite/rspec/prosopite"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "prosopite"
4
+ require "rspec"
5
+ require "rspec/expectations"
6
+
7
+ require_relative "rspec/prosopite/version"
8
+ require_relative "rspec/matchers/perform_queries"
9
+
10
+ module RSpec
11
+ module Prosopite
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rspec/prosopite/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rspec-prosopite"
7
+ spec.version = RSpec::Prosopite::VERSION
8
+ spec.authors = ["Hiroshi Kajisha"]
9
+ spec.email = ["kajisha@gmail.com"]
10
+
11
+ spec.summary = "RSpec matcher for Prosopite"
12
+ spec.description = "RSpec matcher for Prosopite"
13
+ spec.homepage = "https://github.com/kajisha/rspec-prosopite"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.7.0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "prosopite"
32
+ spec.add_dependency "rspec"
33
+ end
@@ -0,0 +1,6 @@
1
+ module Rspec
2
+ module Prosopite
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-prosopite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hiroshi Kajisha
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-09-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: prosopite
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '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: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: RSpec matcher for Prosopite
42
+ email:
43
+ - kajisha@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rspec"
49
+ - ".standard.yml"
50
+ - CHANGELOG.md
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - lib/rspec-prosopite.rb
56
+ - lib/rspec/matchers/perform_queries.rb
57
+ - lib/rspec/prosopite.rb
58
+ - lib/rspec/prosopite/version.rb
59
+ - rspec-prosopite.gemspec
60
+ - sig/rspec/prosopite.rbs
61
+ homepage: https://github.com/kajisha/rspec-prosopite
62
+ licenses:
63
+ - MIT
64
+ metadata:
65
+ homepage_uri: https://github.com/kajisha/rspec-prosopite
66
+ source_code_uri: https://github.com/kajisha/rspec-prosopite
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 2.7.0
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.3.7
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: RSpec matcher for Prosopite
86
+ test_files: []