zirconia 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 +7 -0
- data/.rspec +1 -0
- data/.rubocop.yml +69 -0
- data/.ruby-version +1 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +115 -0
- data/LICENSE.txt +21 -0
- data/README.md +131 -0
- data/Rakefile +10 -0
- data/Steepfile +15 -0
- data/lib/zirconia/application.rb +57 -0
- data/lib/zirconia/rspec.rb +29 -0
- data/lib/zirconia/version.rb +3 -0
- data/lib/zirconia.rb +7 -0
- data/sig/dir.rbs +3 -0
- data/sig/pathname.rbs +17 -0
- data/sig/rspec.rbs +3 -0
- data/sig/zirconia/application.rbs +29 -0
- data/sig/zirconia.rbs +3 -0
- data/zirconia.gemspec +33 -0
- metadata +69 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 83981e69d14fe2bbfa9a7a0058ddf5422cb987d0693d516fda42defd59795cab
|
|
4
|
+
data.tar.gz: 4b4fe6bd399d63f2225a205a2da28b3483b459449d7dd89d1133c45faa4fc525
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 45088c025d1e60ce8e57be3e8725e80edaaf7546976bf8c8a36e46f3ba98237885c6295162423249d75450aa94909ad5915599fe3cae47de450b82dea35531d0
|
|
7
|
+
data.tar.gz: 65b9f8e5797bd0842ad727380d6d0055b6e38487635b61612670d1f1717e55a82c053cf050ee7645ee7e8ed63805694d72bdc6bfd133ee8d8361ae89ad20df2d
|
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-rspec
|
|
3
|
+
|
|
4
|
+
AllCops:
|
|
5
|
+
NewCops: enable
|
|
6
|
+
SuggestExtensions: false
|
|
7
|
+
|
|
8
|
+
Gemspec/RequireMFA:
|
|
9
|
+
Enabled: false
|
|
10
|
+
|
|
11
|
+
Layout/ExtraSpacing:
|
|
12
|
+
AllowForAlignment: true
|
|
13
|
+
Layout/LineLength:
|
|
14
|
+
Max: 80
|
|
15
|
+
Layout/MultilineMethodCallIndentation:
|
|
16
|
+
Enabled: false
|
|
17
|
+
|
|
18
|
+
Lint/AmbiguousBlockAssociation:
|
|
19
|
+
AllowedMethods:
|
|
20
|
+
- change
|
|
21
|
+
Lint/ConstantDefinitionInBlock:
|
|
22
|
+
Exclude:
|
|
23
|
+
- spec/spec_helper.rb
|
|
24
|
+
Lint/MissingSuper:
|
|
25
|
+
Enabled: false
|
|
26
|
+
|
|
27
|
+
Naming/MethodParameterName:
|
|
28
|
+
AllowedNames:
|
|
29
|
+
- by
|
|
30
|
+
- to
|
|
31
|
+
|
|
32
|
+
Style/CharacterLiteral:
|
|
33
|
+
Enabled: false
|
|
34
|
+
Style/Documentation:
|
|
35
|
+
Enabled: false
|
|
36
|
+
Style/ExplicitBlockArgument:
|
|
37
|
+
Enabled: false
|
|
38
|
+
Style/FormatStringToken:
|
|
39
|
+
EnforcedStyle: template
|
|
40
|
+
Style/FrozenStringLiteralComment:
|
|
41
|
+
Enabled: false
|
|
42
|
+
Style/RescueStandardError:
|
|
43
|
+
EnforcedStyle: implicit
|
|
44
|
+
Style/StringLiterals:
|
|
45
|
+
EnforcedStyle: double_quotes
|
|
46
|
+
|
|
47
|
+
RSpec/AnyInstance:
|
|
48
|
+
Enabled: false
|
|
49
|
+
RSpec/ContextWording:
|
|
50
|
+
Prefixes:
|
|
51
|
+
- when
|
|
52
|
+
- with
|
|
53
|
+
- without
|
|
54
|
+
- if
|
|
55
|
+
- unless
|
|
56
|
+
- and
|
|
57
|
+
- but
|
|
58
|
+
RSpec/DescribedClass:
|
|
59
|
+
SkipBlocks: true
|
|
60
|
+
RSpec/ExpectChange:
|
|
61
|
+
EnforcedStyle: block
|
|
62
|
+
RSpec/LetSetup:
|
|
63
|
+
Enabled: false
|
|
64
|
+
RSpec/MultipleMemoizedHelpers:
|
|
65
|
+
Max: 10
|
|
66
|
+
RSpec/NestedGroups:
|
|
67
|
+
Enabled: false
|
|
68
|
+
RSpec/SharedExamples:
|
|
69
|
+
Enabled: false
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.2.0
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
zirconia (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
activesupport (7.0.8)
|
|
10
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
11
|
+
i18n (>= 1.6, < 2)
|
|
12
|
+
minitest (>= 5.1)
|
|
13
|
+
tzinfo (~> 2.0)
|
|
14
|
+
ast (2.4.2)
|
|
15
|
+
base64 (0.1.1)
|
|
16
|
+
concurrent-ruby (1.2.2)
|
|
17
|
+
csv (3.2.7)
|
|
18
|
+
diff-lcs (1.5.0)
|
|
19
|
+
ffi (1.16.2)
|
|
20
|
+
fileutils (1.7.1)
|
|
21
|
+
i18n (1.14.1)
|
|
22
|
+
concurrent-ruby (~> 1.0)
|
|
23
|
+
json (2.6.3)
|
|
24
|
+
language_server-protocol (3.17.0.3)
|
|
25
|
+
listen (3.8.0)
|
|
26
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
27
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
|
28
|
+
logger (1.5.3)
|
|
29
|
+
minitest (5.20.0)
|
|
30
|
+
parallel (1.23.0)
|
|
31
|
+
parser (3.2.2.4)
|
|
32
|
+
ast (~> 2.4.1)
|
|
33
|
+
racc
|
|
34
|
+
racc (1.7.1)
|
|
35
|
+
rainbow (3.1.1)
|
|
36
|
+
rake (13.0.6)
|
|
37
|
+
rb-fsevent (0.11.2)
|
|
38
|
+
rb-inotify (0.10.1)
|
|
39
|
+
ffi (~> 1.0)
|
|
40
|
+
rbs (3.2.2)
|
|
41
|
+
regexp_parser (2.8.2)
|
|
42
|
+
rexml (3.2.6)
|
|
43
|
+
rspec (3.12.0)
|
|
44
|
+
rspec-core (~> 3.12.0)
|
|
45
|
+
rspec-expectations (~> 3.12.0)
|
|
46
|
+
rspec-mocks (~> 3.12.0)
|
|
47
|
+
rspec-core (3.12.2)
|
|
48
|
+
rspec-support (~> 3.12.0)
|
|
49
|
+
rspec-expectations (3.12.3)
|
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
51
|
+
rspec-support (~> 3.12.0)
|
|
52
|
+
rspec-mocks (3.12.6)
|
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
54
|
+
rspec-support (~> 3.12.0)
|
|
55
|
+
rspec-support (3.12.1)
|
|
56
|
+
rubocop (1.57.1)
|
|
57
|
+
base64 (~> 0.1.1)
|
|
58
|
+
json (~> 2.3)
|
|
59
|
+
language_server-protocol (>= 3.17.0)
|
|
60
|
+
parallel (~> 1.10)
|
|
61
|
+
parser (>= 3.2.2.4)
|
|
62
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
63
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
64
|
+
rexml (>= 3.2.5, < 4.0)
|
|
65
|
+
rubocop-ast (>= 1.28.1, < 2.0)
|
|
66
|
+
ruby-progressbar (~> 1.7)
|
|
67
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
|
68
|
+
rubocop-ast (1.29.0)
|
|
69
|
+
parser (>= 3.2.1.0)
|
|
70
|
+
rubocop-capybara (2.19.0)
|
|
71
|
+
rubocop (~> 1.41)
|
|
72
|
+
rubocop-factory_bot (2.24.0)
|
|
73
|
+
rubocop (~> 1.33)
|
|
74
|
+
rubocop-rspec (2.24.1)
|
|
75
|
+
rubocop (~> 1.33)
|
|
76
|
+
rubocop-capybara (~> 2.17)
|
|
77
|
+
rubocop-factory_bot (~> 2.22)
|
|
78
|
+
ruby-progressbar (1.13.0)
|
|
79
|
+
securerandom (0.2.2)
|
|
80
|
+
steep (1.5.3)
|
|
81
|
+
activesupport (>= 5.1)
|
|
82
|
+
concurrent-ruby (>= 1.1.10)
|
|
83
|
+
csv (>= 3.0.9)
|
|
84
|
+
fileutils (>= 1.1.0)
|
|
85
|
+
json (>= 2.1.0)
|
|
86
|
+
language_server-protocol (>= 3.15, < 4.0)
|
|
87
|
+
listen (~> 3.0)
|
|
88
|
+
logger (>= 1.3.0)
|
|
89
|
+
parser (>= 3.1)
|
|
90
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
91
|
+
rbs (>= 3.1.0)
|
|
92
|
+
securerandom (>= 0.1)
|
|
93
|
+
strscan (>= 1.0.0)
|
|
94
|
+
terminal-table (>= 2, < 4)
|
|
95
|
+
strscan (3.0.6)
|
|
96
|
+
terminal-table (3.0.2)
|
|
97
|
+
unicode-display_width (>= 1.1.1, < 3)
|
|
98
|
+
tzinfo (2.0.6)
|
|
99
|
+
concurrent-ruby (~> 1.0)
|
|
100
|
+
unicode-display_width (2.5.0)
|
|
101
|
+
|
|
102
|
+
PLATFORMS
|
|
103
|
+
arm64-darwin-21
|
|
104
|
+
x86_64-linux
|
|
105
|
+
|
|
106
|
+
DEPENDENCIES
|
|
107
|
+
rake (~> 13.0)
|
|
108
|
+
rspec (~> 3.0)
|
|
109
|
+
rubocop (~> 1.21)
|
|
110
|
+
rubocop-rspec
|
|
111
|
+
steep
|
|
112
|
+
zirconia!
|
|
113
|
+
|
|
114
|
+
BUNDLED WITH
|
|
115
|
+
2.4.1
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Chris Welham
|
|
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,131 @@
|
|
|
1
|
+
# Zirconia: A Ruby Gem Synthesiser for RSpec
|
|
2
|
+
|
|
3
|
+
Zirconia is a lightweight testing utility that is capable of generating\ temporary Ruby Gem applications from within the test suite.
|
|
4
|
+
|
|
5
|
+
Zirconia offers an intuitive interface around the synthetic gem allowing them to be configured and coded from within the test environment.
|
|
6
|
+
|
|
7
|
+
Use cases include:
|
|
8
|
+
- Testing frameworks written in Ruby
|
|
9
|
+
- Testing autoloaders
|
|
10
|
+
- Testing gem-gem interaction
|
|
11
|
+
- Testing metaprogramming-heavy modules and classes
|
|
12
|
+
|
|
13
|
+
Currently, only `RSpec` is supported.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
- Add `zirconia` to your Gemfile:
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
source "https://rubygems.org"
|
|
22
|
+
|
|
23
|
+
gem "zirconia"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- Require `zirconia/rspec` in your spec_helper:
|
|
27
|
+
```ruby
|
|
28
|
+
require "zirconia/rspec"
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- Instantiate a Zirconia Gem in your spec using the `with_gem: gem_name` metadata:
|
|
32
|
+
```rspec
|
|
33
|
+
require 'spec_helper'
|
|
34
|
+
|
|
35
|
+
RSpec.describe "Some Gem", with_gem: :some_gem do
|
|
36
|
+
it "instantiates a Zirconia Gem" do
|
|
37
|
+
expect(gem).to be_a(Zirconia::Application)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
That's it! You can now interact with your newly spun up gem (through `gem`) in `before`/`after` hooks or in the tests themselves.
|
|
43
|
+
|
|
44
|
+
Note that calling `:with_gem` without a name argument is valid as well. In this case the gem name will be set to the default (`SomeGem`).
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Overview
|
|
48
|
+
|
|
49
|
+
Interaction, configuration and coding of your fake gem is executed through the `gem` variable set by Zirconia when the `with_gem` RSpec metadata is specified.
|
|
50
|
+
|
|
51
|
+
Gems are created using the `bundle gem` command within your system's temp directory. As gem creation is delegated to `bundler`, your local system `bundler` configuration will be respected. Gems are removed and Gem modules unsourced around each test.
|
|
52
|
+
|
|
53
|
+
Adding code to the fake gem is achieved by writing files to their respective path before loading the gem into memory. The `gem` object (an instance of `Zirconia::Application`) defines several instance methods that return `Pathname` objects at canonical locations in the gem filetree. Conventionally these are:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
|-+temp_dir/ gem.dir
|
|
57
|
+
|-+ some_gem/ gem.gem_path
|
|
58
|
+
|-+ lib/ gem.lib_path
|
|
59
|
+
|-- some_gem.rb gem.main_file
|
|
60
|
+
|-+ some_gem/ gem.path
|
|
61
|
+
|-- foobar.rb gem.path("foobar")
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Path Methods
|
|
65
|
+
|
|
66
|
+
These path methods are return a `Pathname` objects. `Pathname` is a Ruby standard library, and offers a simple interface for paths in a filetree. Of importance may be:
|
|
67
|
+
- `write(string)`: Writes `string` to the file at path
|
|
68
|
+
- `read`: Reads the contents of the file at path
|
|
69
|
+
- `exist?`: Returns whether a file
|
|
70
|
+
- `mkdir`: Make (non recursive) a directory at the current path
|
|
71
|
+
|
|
72
|
+
The `_path` methods can be called with a variable amount of string path fragments and an optional extension. String fragments will be joined into the path, whilst the extension will be appended to the path
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
### Methods
|
|
76
|
+
|
|
77
|
+
#### dir
|
|
78
|
+
- The (temporary) directory that contains the gem
|
|
79
|
+
|
|
80
|
+
#### gem_path
|
|
81
|
+
- Returns `Pathname` objects for paths in the root gem directory
|
|
82
|
+
- In a conventional Ruby gem filetree this is `some_gem/*.ext`
|
|
83
|
+
|
|
84
|
+
#### lib_path
|
|
85
|
+
- Returns `Pathname` objects for paths in the gem lib directory
|
|
86
|
+
- In a conventional Ruby gem filetree this is `some_gem/lib/*.ext`
|
|
87
|
+
|
|
88
|
+
#### path
|
|
89
|
+
- Returns `Pathname` objects for paths in the gem named lib directory
|
|
90
|
+
- In a conventional Ruby gem filetree this is `some_gem/lib/some_gem/*.ext`
|
|
91
|
+
|
|
92
|
+
#### main_file
|
|
93
|
+
- Returns a `Pathname` object
|
|
94
|
+
- This is the entrypoint to the gem application:
|
|
95
|
+
- In a conventional Ruby gem filetree this is `some_gem/lib/some_gem.rb`
|
|
96
|
+
|
|
97
|
+
#### load!
|
|
98
|
+
- This method requires the fake gem into your current Ruby scope.
|
|
99
|
+
- Note that this process is not idempotent as gems will not be reloaded.
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
## Example
|
|
103
|
+
|
|
104
|
+
Say we are creating a fancy new testing framework `spectacular`, and we want to test how it behaves when included in target Ruby gem applications. `spectacular` defines an `Initialiser` class that is run when the gem is included into its target gem.
|
|
105
|
+
|
|
106
|
+
With `zirconia`, we can spin up a target Gem, write some Ruby code to be injected into the Gem entrypoint, and then test how it behaves when run. This could look something like:
|
|
107
|
+
|
|
108
|
+
```ruby
|
|
109
|
+
RSpec.describe Spectacular::Initialiser, :with_gem do
|
|
110
|
+
before do
|
|
111
|
+
gem.main_file.write(<<~RUBY)
|
|
112
|
+
require "spectacular"
|
|
113
|
+
|
|
114
|
+
module SomeGem
|
|
115
|
+
extend Spectacular::Initialiser
|
|
116
|
+
end
|
|
117
|
+
RUBY
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
describe "requiring Spectacular" do
|
|
121
|
+
subject(:require_spectacular) { gem.load! }
|
|
122
|
+
|
|
123
|
+
it "loads the gem" do
|
|
124
|
+
expect { require_spectacular }
|
|
125
|
+
.to change { Object.const_defined?(:SomeGem) }
|
|
126
|
+
.from(false)
|
|
127
|
+
.to(true)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
```
|
data/Rakefile
ADDED
data/Steepfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
target :lib do
|
|
2
|
+
signature "sig"
|
|
3
|
+
|
|
4
|
+
check "lib"
|
|
5
|
+
|
|
6
|
+
# Too much RSpec interfacing to type.
|
|
7
|
+
ignore "lib/zirconia/rspec.rb"
|
|
8
|
+
|
|
9
|
+
configure_code_diagnostics do |hash|
|
|
10
|
+
hash[Steep::Diagnostic::Ruby::FallbackAny] = nil
|
|
11
|
+
hash[Steep::Diagnostic::Ruby::UnknownConstant] = :error
|
|
12
|
+
hash[Steep::Diagnostic::Ruby::MethodDefinitionMissing] = nil
|
|
13
|
+
hash[Steep::Diagnostic::Ruby::UnsupportedSyntax] = :hint
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module Zirconia
|
|
2
|
+
class Application
|
|
3
|
+
attr_reader :dir, :name
|
|
4
|
+
|
|
5
|
+
def initialize(dir:, name:)
|
|
6
|
+
@dir = Pathname.new(dir).join(name)
|
|
7
|
+
@name = name
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def create!
|
|
11
|
+
`bundle gem #{dir}`
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def load!
|
|
15
|
+
require main_file.to_s
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def gem_path(*, ext: nil)
|
|
19
|
+
build_path(*, dir:, ext:)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def lib_path(*, ext: :rb)
|
|
23
|
+
build_path(*, dir: lib_dir, ext:)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def path(*, ext: :rb)
|
|
27
|
+
build_path(*, dir: gem_dir, ext:)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def main_file
|
|
31
|
+
@main_file ||= lib_path(name, ext: :rb)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def to_sym
|
|
35
|
+
name.split("_").map(&:capitalize).join.to_sym
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def lib_dir
|
|
41
|
+
@lib_dir ||= dir.join("lib")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def gem_dir
|
|
45
|
+
@gem_dir ||= lib_dir.join(name)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def build_path(*fragments, dir:, ext:)
|
|
49
|
+
return dir if fragments.empty?
|
|
50
|
+
|
|
51
|
+
file = fragments.pop || raise
|
|
52
|
+
file = "#{file}.#{ext}" if ext
|
|
53
|
+
|
|
54
|
+
dir.join(*fragments, file)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
|
|
3
|
+
module Zirconia
|
|
4
|
+
module RSpec
|
|
5
|
+
require "zirconia/application"
|
|
6
|
+
|
|
7
|
+
DEFAULT_NAME = "some_gem".freeze
|
|
8
|
+
|
|
9
|
+
::RSpec.configure do |config|
|
|
10
|
+
config.around(with_gem: true) do |spec|
|
|
11
|
+
self.class.class_eval { attr_reader :gem }
|
|
12
|
+
|
|
13
|
+
name = ::RSpec.current_example.metadata[:with_gem]
|
|
14
|
+
name = DEFAULT_NAME if name == true
|
|
15
|
+
name = name.to_s
|
|
16
|
+
|
|
17
|
+
Dir.mktmpdir do |dir|
|
|
18
|
+
@gem = Zirconia::Application.new(dir:, name:).tap(&:create!)
|
|
19
|
+
|
|
20
|
+
spec.run
|
|
21
|
+
|
|
22
|
+
if Object.const_defined?(gem.to_sym)
|
|
23
|
+
Object.send(:remove_const, gem.to_sym)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/zirconia.rb
ADDED
data/sig/dir.rbs
ADDED
data/sig/pathname.rbs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class Pathname
|
|
2
|
+
def initialize: (String path) -> void
|
|
3
|
+
|
|
4
|
+
def read: -> String
|
|
5
|
+
|
|
6
|
+
def write: (String contents) -> void
|
|
7
|
+
|
|
8
|
+
def basename: (?String) -> Pathname
|
|
9
|
+
|
|
10
|
+
def dirname: -> Pathname
|
|
11
|
+
|
|
12
|
+
def exist?: -> bool
|
|
13
|
+
|
|
14
|
+
def join: (*String) -> Pathname
|
|
15
|
+
|
|
16
|
+
def to_s: -> String
|
|
17
|
+
end
|
data/sig/rspec.rbs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Zirconia
|
|
2
|
+
class Application
|
|
3
|
+
attr_reader dir: Pathname
|
|
4
|
+
attr_reader name: String
|
|
5
|
+
|
|
6
|
+
def initialize: (dir: String, name: String) -> void
|
|
7
|
+
|
|
8
|
+
def create!: -> void
|
|
9
|
+
|
|
10
|
+
def load!: -> void
|
|
11
|
+
|
|
12
|
+
def gem_path: (*String, ?ext: Symbol?) -> Pathname
|
|
13
|
+
|
|
14
|
+
def lib_path: (*String, ?ext: Symbol?) -> Pathname
|
|
15
|
+
|
|
16
|
+
def path: (*String, ?ext: Symbol?) -> Pathname
|
|
17
|
+
|
|
18
|
+
def to_sym: -> Symbol
|
|
19
|
+
|
|
20
|
+
attr_reader main_file: Pathname
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
attr_reader lib_dir: Pathname
|
|
25
|
+
attr_reader gem_dir: Pathname
|
|
26
|
+
|
|
27
|
+
def build_path: (*String, dir: Pathname, ext: Symbol?) -> Pathname
|
|
28
|
+
end
|
|
29
|
+
end
|
data/sig/zirconia.rbs
ADDED
data/zirconia.gemspec
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require_relative "lib/zirconia/version"
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "zirconia"
|
|
5
|
+
spec.version = Zirconia::VERSION
|
|
6
|
+
spec.authors = ["Chris Welham"]
|
|
7
|
+
spec.email = ["71787007+apexatoll@users.noreply.github.com"]
|
|
8
|
+
|
|
9
|
+
spec.summary = "Lightweight testing utility for synthesising Ruby gems"
|
|
10
|
+
|
|
11
|
+
spec.description = <<~DESCRIPTION
|
|
12
|
+
Zirconia is a lightweight testing utility that is capable of generating\
|
|
13
|
+
temporary Ruby Gem applications from within the test suite.
|
|
14
|
+
|
|
15
|
+
Zirconia offers an intuitive interface around the synthetic gem allowing
|
|
16
|
+
them to be configured and coded from within the test environment.
|
|
17
|
+
DESCRIPTION
|
|
18
|
+
|
|
19
|
+
spec.homepage = "https://github.com/apexatoll/zirconia"
|
|
20
|
+
spec.license = "MIT"
|
|
21
|
+
spec.required_ruby_version = ">= 3.2.0"
|
|
22
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
23
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
24
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
25
|
+
|
|
26
|
+
spec.files = Dir.chdir(__dir__) do
|
|
27
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
28
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|spec)/|\.(?:git))})
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
spec.require_paths = ["lib"]
|
|
33
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: zirconia
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Chris Welham
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: |
|
|
14
|
+
Zirconia is a lightweight testing utility that is capable of generatingtemporary Ruby Gem applications from within the test suite.
|
|
15
|
+
|
|
16
|
+
Zirconia offers an intuitive interface around the synthetic gem allowing
|
|
17
|
+
them to be configured and coded from within the test environment.
|
|
18
|
+
email:
|
|
19
|
+
- 71787007+apexatoll@users.noreply.github.com
|
|
20
|
+
executables: []
|
|
21
|
+
extensions: []
|
|
22
|
+
extra_rdoc_files: []
|
|
23
|
+
files:
|
|
24
|
+
- ".rspec"
|
|
25
|
+
- ".rubocop.yml"
|
|
26
|
+
- ".ruby-version"
|
|
27
|
+
- Gemfile
|
|
28
|
+
- Gemfile.lock
|
|
29
|
+
- LICENSE.txt
|
|
30
|
+
- README.md
|
|
31
|
+
- Rakefile
|
|
32
|
+
- Steepfile
|
|
33
|
+
- lib/zirconia.rb
|
|
34
|
+
- lib/zirconia/application.rb
|
|
35
|
+
- lib/zirconia/rspec.rb
|
|
36
|
+
- lib/zirconia/version.rb
|
|
37
|
+
- sig/dir.rbs
|
|
38
|
+
- sig/pathname.rbs
|
|
39
|
+
- sig/rspec.rbs
|
|
40
|
+
- sig/zirconia.rbs
|
|
41
|
+
- sig/zirconia/application.rbs
|
|
42
|
+
- zirconia.gemspec
|
|
43
|
+
homepage: https://github.com/apexatoll/zirconia
|
|
44
|
+
licenses:
|
|
45
|
+
- MIT
|
|
46
|
+
metadata:
|
|
47
|
+
allowed_push_host: https://rubygems.org
|
|
48
|
+
homepage_uri: https://github.com/apexatoll/zirconia
|
|
49
|
+
source_code_uri: https://github.com/apexatoll/zirconia
|
|
50
|
+
post_install_message:
|
|
51
|
+
rdoc_options: []
|
|
52
|
+
require_paths:
|
|
53
|
+
- lib
|
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
|
+
requirements:
|
|
56
|
+
- - ">="
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: 3.2.0
|
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '0'
|
|
64
|
+
requirements: []
|
|
65
|
+
rubygems_version: 3.4.1
|
|
66
|
+
signing_key:
|
|
67
|
+
specification_version: 4
|
|
68
|
+
summary: Lightweight testing utility for synthesising Ruby gems
|
|
69
|
+
test_files: []
|