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
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: ['3.2', '3.3']
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake test
- name: Upload coverage to Codecov
if: matrix.ruby == '3.3'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/coverage.json
fail_ci_if_error: false
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release

on:
push:
tags: ['v*']

jobs:
publish:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: Verify version matches tag
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
GEM_VERSION=$(ruby -e "require './lib/rspock/version'; puts RSpock::VERSION")
if [ "$TAG_VERSION" != "$GEM_VERSION" ]; then
echo "::error::Tag ($TAG_VERSION) does not match gem version ($GEM_VERSION)"
exit 1
fi
- uses: rubygems/configure-rubygems-credentials@main
- name: Build and publish gem
run: |
gem build rspock.gemspec
gem push rspock-*.gem
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

110 changes: 43 additions & 67 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,96 +1,72 @@
PATH
remote: .
specs:
rspock (1.0.0)
ast_transform (~> 1.0)
rspock (2.0.0)
ast_transform (~> 2.0)
minitest (~> 5.0)
mocha (~> 1.0)
parser (~> 2.5)
unparser (~> 0.4)
mocha (>= 1.0)
parser (>= 3.0)
unparser (>= 0.6)

GEM
remote: https://rubygems.org/
specs:
abstract_type (0.0.7)
adamantium (0.2.0)
ice_nine (~> 0.11.0)
memoizable (~> 0.4.0)
ansi (1.5.0)
ast (2.4.1)
ast_transform (1.0.0)
parser (~> 2.5)
unparser (~> 0.4)
builder (3.2.4)
byebug (11.1.3)
ast (2.4.3)
ast_transform (2.0.0)
parser (>= 3.0)
unparser (>= 0.6)
builder (3.3.0)
coderay (1.1.3)
concord (0.1.5)
adamantium (~> 0.2.0)
equalizer (~> 0.0.9)
coveralls (0.8.23)
json (>= 1.8, < 3)
simplecov (~> 0.16.1)
term-ansicolor (~> 1.3)
thor (>= 0.19.4, < 2.0)
tins (~> 1.6)
diff-lcs (1.4.4)
docile (1.3.2)
equalizer (0.0.11)
ice_nine (0.11.2)
json (2.3.1)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
method_source (1.0.0)
minitest (5.14.1)
minitest-reporters (1.4.2)
diff-lcs (1.6.2)
docile (1.4.1)
io-console (0.8.2)
method_source (1.1.0)
minitest (5.27.0)
minitest-reporters (1.7.1)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
mocha (1.11.2)
parser (2.7.1.4)
mocha (3.0.2)
ruby2_keywords (>= 0.0.5)
parser (3.3.10.2)
ast (~> 2.4.1)
procto (0.0.3)
pry (0.13.1)
racc
prism (1.9.0)
pry (0.16.0)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.9.0)
byebug (~> 11.0)
pry (~> 0.13.0)
rake (13.0.1)
ruby-progressbar (1.10.1)
simplecov (0.16.1)
reline (>= 0.6.0)
racc (1.8.1)
rake (13.3.1)
reline (0.6.3)
io-console (~> 0.5)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
simplecov (0.22.0)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
sync (0.5.0)
term-ansicolor (1.7.1)
tins (~> 1.0)
thor (1.0.1)
thread_safe (0.3.6)
tins (1.25.0)
sync
unparser (0.4.7)
abstract_type (~> 0.0.7)
adamantium (~> 0.2.0)
concord (~> 0.1.5)
diff-lcs (~> 1.3)
equalizer (~> 0.0.9)
parser (>= 2.6.5)
procto (~> 0.0.2)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.2)
simplecov_json_formatter (0.1.4)
unparser (0.8.1)
diff-lcs (~> 1.6)
parser (>= 3.3.0)
prism (>= 1.5.1)

PLATFORMS
arm64-darwin-24
ruby

DEPENDENCIES
bundler (~> 2.1)
coveralls (~> 0.8)
bundler (>= 2.1)
minitest (~> 5.14)
minitest-reporters (~> 1.4)
pry (~> 0.13)
pry-byebug (~> 3.9)
pry (>= 0.14)
rake (~> 13.0)
rspock!
simplecov (~> 0.22)

BUNDLED WITH
2.1.4
2.5.22
34 changes: 31 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Build Status](https://travis-ci.org/rspockframework/rspock.svg?branch=master)](https://travis-ci.org/rspockframework/rspock)
[![Coverage Status](https://coveralls.io/repos/github/rspockframework/rspock/badge.svg?branch=master)](https://coveralls.io/github/rspockframework/rspock?branch=master)
[![CI](https://github.com/rspockframework/rspock/actions/workflows/ci.yml/badge.svg)](https://github.com/rspockframework/rspock/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/rspockframework/rspock/branch/main/graph/badge.svg)](https://codecov.io/gh/rspockframework/rspock)

# RSpock

Expand Down Expand Up @@ -440,7 +440,35 @@ end

After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
To install this gem onto your local machine, run `bundle exec rake install`.

## Releasing a New Version

There are two ways to create a release. Both require that `version.rb` has already been updated and merged to main.

### Via GitHub UI

1. Update `VERSION` in `lib/rspock/version.rb`, commit, open a PR, and merge to main
2. Go to the repo on GitHub → **Releases** → **Draft a new release**
3. Enter a new tag (e.g. `v2.0.0`), select `main` as the target branch
4. Add a title and release notes (GitHub can auto-generate these from merged PRs)
5. Click **Publish release**

### Via CLI

1. Update `VERSION` in `lib/rspock/version.rb`, commit, open a PR, and merge to main
2. Tag and push:
```
git checkout main && git pull
git tag v2.0.0
git push origin v2.0.0
```

In both cases, the [release workflow](.github/workflows/release.yml) validates that the tag matches `version.rb`, builds the gem, and publishes it to [rubygems.org](https://rubygems.org) via [Trusted Publishing](https://guides.rubygems.org/trusted-publishing/) (no API key needed). If there's a mismatch, the workflow fails before publishing.

### One-time setup

Configure the gem as a trusted publisher on rubygems.org so that the release workflow can publish automatically. See the [Trusted Publishing guide](https://guides.rubygems.org/trusted-publishing/pushing-a-new-gem-with-a-trusted-publisher/) for details.

## Contributing

Expand Down
3 changes: 2 additions & 1 deletion lib/rspock/ast/test_method_def_transformation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def run(node)
end

def on_str(node)
node.updated(:dstr, [node, SPACE_STR_AST, TEST_INDEX_AST, LINE_NUMBER_STR_AST, LINE_NUMBER_AST])
merged = s(:str, "#{node.children[0]} ")
node.updated(:dstr, [merged, TEST_INDEX_AST, LINE_NUMBER_STR_AST, LINE_NUMBER_AST])
end

def on_dstr(node)
Expand Down
11 changes: 10 additions & 1 deletion lib/rspock/ast/test_method_dstr_transformation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ class TestMethodDstrTransformation < ASTTransform::AbstractTransformation
LINE_NUMBER_STR_AST = s(:str, " line ")

def on_dstr(node)
children = [*process_all(node), SPACE_STR_AST, TEST_INDEX_AST, LINE_NUMBER_STR_AST, LINE_NUMBER_AST]
children = process_all(node).dup
last = children.last

if last&.type == :str
children[-1] = s(:str, "#{last.children[0]} ")
else
children << SPACE_STR_AST
end

children.push(TEST_INDEX_AST, LINE_NUMBER_STR_AST, LINE_NUMBER_AST)
node.updated(nil, children)
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/rspock/ast/transformation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def process_casgn_block(node)
end

def process_rspock(node)
children = [source_map_rescue_wrapper(s(:begin, *[EXTEND_RSPOCK_DECLARATIVE, *process_all(node)]))]
processed = process_all(node).compact
children = [source_map_rescue_wrapper(s(:begin, *[EXTEND_RSPOCK_DECLARATIVE, *processed]))]
node.updated(nil, children)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rspock/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RSpock
VERSION = "1.0.0"
VERSION = "2.0.0"
end
27 changes: 9 additions & 18 deletions rspock.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,28 @@ Gem::Specification.new do |spec|

spec.summary = 'Data-driven testing framework.'
spec.description = spec.summary
spec.homepage = 'https://github.com/jpduchesne/rspock'
spec.homepage = 'https://github.com/rspockframework/rspock'
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.required_ruby_version = '~> 2.5'

if ENV['TRAVIS']
if ENV['TRAVIS_TAG'].nil? || ENV['TRAVIS_TAG'].empty?
spec.version = "#{spec.version}-alpha-#{ENV['TRAVIS_BUILD_NUMBER']}"
elsif ENV['TRAVIS_TAG'] != spec.version.to_s
raise "Tag name (#{ENV['TRAVIS_TAG']}) and Gem version (#{spec.version}) are different"
end
end
spec.required_ruby_version = '>= 3.2'

# Development dependencies
spec.add_development_dependency "bundler", "~> 2.1"
spec.add_development_dependency "coveralls", "~> 0.8"
spec.add_development_dependency "bundler", ">= 2.1"
spec.add_development_dependency "minitest", "~> 5.14"
spec.add_development_dependency "minitest-reporters", "~> 1.4"
spec.add_development_dependency "pry", "~> 0.13"
spec.add_development_dependency "pry-byebug", "~> 3.9"
spec.add_development_dependency "pry", ">= 0.14"
spec.add_development_dependency "rake", "~> 13.0"
spec.add_development_dependency "simplecov", "~> 0.22"

# Runtime dependencies
spec.add_runtime_dependency "ast_transform", "~> 1.0"
spec.add_runtime_dependency "ast_transform", "~> 2.0"
spec.add_runtime_dependency "minitest", "~> 5.0"
spec.add_runtime_dependency "mocha", "~> 1.0"
spec.add_runtime_dependency "parser", "~> 2.5"
spec.add_runtime_dependency "unparser", "~> 0.4"
spec.add_runtime_dependency "mocha", ">= 1.0"
spec.add_runtime_dependency "parser", ">= 3.0"
spec.add_runtime_dependency "unparser", ">= 0.6"
end
2 changes: 1 addition & 1 deletion test/rspock/ast/interaction_transformation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def setup
HEREDOC

expected = <<~HEREDOC
receiver.expects(:message).with(param1, *param2, p3: param3).times(1)
receiver.expects(:message).with(param1, *param2, { p3: param3 }).times(1)
HEREDOC

assert_equal strip_end_line(expected), transform(source)
Expand Down
6 changes: 2 additions & 4 deletions test/rspock/ast/test_method_def_transformation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def setup

expected = s(:send, nil, :test,
s(:dstr,
s(:str, "Test Name"),
s(:str, " "),
s(:str, "Test Name "),
s(:begin, s(:lvar, :_test_index_)),
s(:str, " line "),
s(:begin, s(:lvar, :_line_number_))))
Expand All @@ -50,8 +49,7 @@ def setup
expected = s(:send, nil, :test,
s(:dstr,
s(:begin, s(:lvar, :a)),
s(:str, "Test Name"),
s(:str, " "),
s(:str, "Test Name "),
s(:begin, s(:lvar, :_test_index_)),
s(:str, " line "),
s(:begin, s(:lvar, :_line_number_))))
Expand Down
Loading