Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,5 @@ desktop.ini
/config/application.yml

example-1
monorepo
specs
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.PHONY: install build test setup-monorepo update-monorepo

install:
bundle install

Expand All @@ -6,3 +8,15 @@ build:

test:
bundle exec rspec spec/

setup-monorepo:
mkdir -p monorepo
if [ ! -d "monorepo/.git" ]; then \
git clone git@github.com:featurevisor/featurevisor.git monorepo; \
else \
(cd monorepo && git fetch origin main && git checkout main && git pull origin main); \
fi
(cd monorepo && make install && make build)

update-monorepo:
(cd monorepo && git pull origin main)
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ This SDK is compatible with [Featurevisor](https://featurevisor.com/) v2.0 proje
- [Close](#close)
- [CLI usage](#cli-usage)
- [Test](#test)
- [Test against local monorepo's example-1](#test-against-local-monorepos-example-1)
- [Benchmark](#benchmark)
- [Assess distribution](#assess-distribution)
- [Development](#development)
Expand Down Expand Up @@ -383,7 +384,7 @@ require 'json'
def update_datafile(f, datafile_url)
loop do
sleep(5 * 60) # 5 minutes

begin
response = Net::HTTP.get_response(URI(datafile_url))
datafile_content = JSON.parse(response.body)
Expand Down Expand Up @@ -683,10 +684,27 @@ Additional options that are available:
```bash
$ bundle exec featurevisor test \
--projectDirectoryPath="/absolute/path/to/your/featurevisor/project" \
--quiet|verbose \
--quiet|--verbose \
--onlyFailures \
--keyPattern="myFeatureKey" \
--assertionPattern="#1"
--assertionPattern="#1" \
--with-scopes \
--with-tags
```

`--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.

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).

For compatibility, camelCase aliases are also supported: `--withScopes` and `--withTags`.

### Test against local monorepo's example-1

```bash
$ cd /absolute/path/to/featurevisor-ruby
$ bundle exec featurevisor test --projectDirectoryPath=./monorepo/examples/example-1
$ bundle exec featurevisor test --projectDirectoryPath=./monorepo/examples/example-1 --with-scopes
$ bundle exec featurevisor test --projectDirectoryPath=./monorepo/examples/example-1 --with-tags
```

### Benchmark
Expand Down
10 changes: 9 additions & 1 deletion bin/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Options
attr_accessor :command, :assertion_pattern, :context, :environment, :feature,
:key_pattern, :n, :only_failures, :quiet, :variable, :variation,
:verbose, :inflate, :show_datafile, :schema_version, :project_directory_path,
:populate_uuid
:populate_uuid, :with_scopes, :with_tags

def initialize
@n = 1000
Expand Down Expand Up @@ -86,6 +86,14 @@ def self.parse(args)
options.schema_version = v
end

opts.on("--with-scopes", "--withScopes", "Test scoped assertions against scoped datafiles") do
options.with_scopes = true
end

opts.on("--with-tags", "--withTags", "Test tagged assertions against tagged datafiles") do
options.with_tags = true
end

opts.on("--projectDirectoryPath=PATH", "Project directory path") do |v|
options.project_directory_path = v
end
Expand Down
Loading