Skip to content

Commit 25b569f

Browse files
authored
feat: parity with JavaScript SDK (#2)
1 parent cc0f285 commit 25b569f

File tree

13 files changed

+1285
-175
lines changed

13 files changed

+1285
-175
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,5 @@ desktop.ini
9494
/config/application.yml
9595

9696
example-1
97+
monorepo
98+
specs

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.PHONY: install build test setup-monorepo update-monorepo
2+
13
install:
24
bundle install
35

@@ -6,3 +8,15 @@ build:
68

79
test:
810
bundle exec rspec spec/
11+
12+
setup-monorepo:
13+
mkdir -p monorepo
14+
if [ ! -d "monorepo/.git" ]; then \
15+
git clone [email protected]:featurevisor/featurevisor.git monorepo; \
16+
else \
17+
(cd monorepo && git fetch origin main && git checkout main && git pull origin main); \
18+
fi
19+
(cd monorepo && make install && make build)
20+
21+
update-monorepo:
22+
(cd monorepo && git pull origin main)

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ This SDK is compatible with [Featurevisor](https://featurevisor.com/) v2.0 proje
4141
- [Close](#close)
4242
- [CLI usage](#cli-usage)
4343
- [Test](#test)
44+
- [Test against local monorepo's example-1](#test-against-local-monorepos-example-1)
4445
- [Benchmark](#benchmark)
4546
- [Assess distribution](#assess-distribution)
4647
- [Development](#development)
@@ -383,7 +384,7 @@ require 'json'
383384
def update_datafile(f, datafile_url)
384385
loop do
385386
sleep(5 * 60) # 5 minutes
386-
387+
387388
begin
388389
response = Net::HTTP.get_response(URI(datafile_url))
389390
datafile_content = JSON.parse(response.body)
@@ -683,10 +684,27 @@ Additional options that are available:
683684
```bash
684685
$ bundle exec featurevisor test \
685686
--projectDirectoryPath="/absolute/path/to/your/featurevisor/project" \
686-
--quiet|verbose \
687+
--quiet|--verbose \
687688
--onlyFailures \
688689
--keyPattern="myFeatureKey" \
689-
--assertionPattern="#1"
690+
--assertionPattern="#1" \
691+
--with-scopes \
692+
--with-tags
693+
```
694+
695+
`--with-scopes` and `--with-tags` make the Ruby test runner build scoped/tagged datafiles in memory (via `npx featurevisor build --json`) and evaluate matching assertions against those exact datafiles.
696+
697+
If an assertion references `scope` and `--with-scopes` is not provided, the runner still evaluates the assertion by merging that scope's configured context into the assertion context (without building scoped datafiles).
698+
699+
For compatibility, camelCase aliases are also supported: `--withScopes` and `--withTags`.
700+
701+
### Test against local monorepo's example-1
702+
703+
```bash
704+
$ cd /absolute/path/to/featurevisor-ruby
705+
$ bundle exec featurevisor test --projectDirectoryPath=./monorepo/examples/example-1
706+
$ bundle exec featurevisor test --projectDirectoryPath=./monorepo/examples/example-1 --with-scopes
707+
$ bundle exec featurevisor test --projectDirectoryPath=./monorepo/examples/example-1 --with-tags
690708
```
691709

692710
### Benchmark

bin/cli.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Options
77
attr_accessor :command, :assertion_pattern, :context, :environment, :feature,
88
:key_pattern, :n, :only_failures, :quiet, :variable, :variation,
99
:verbose, :inflate, :show_datafile, :schema_version, :project_directory_path,
10-
:populate_uuid
10+
:populate_uuid, :with_scopes, :with_tags
1111

1212
def initialize
1313
@n = 1000
@@ -86,6 +86,14 @@ def self.parse(args)
8686
options.schema_version = v
8787
end
8888

89+
opts.on("--with-scopes", "--withScopes", "Test scoped assertions against scoped datafiles") do
90+
options.with_scopes = true
91+
end
92+
93+
opts.on("--with-tags", "--withTags", "Test tagged assertions against tagged datafiles") do
94+
options.with_tags = true
95+
end
96+
8997
opts.on("--projectDirectoryPath=PATH", "Project directory path") do |v|
9098
options.project_directory_path = v
9199
end

0 commit comments

Comments
 (0)