Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
015638e
Add basic functional tests for command-line interface
hahwul Feb 5, 2025
c39b387
Add Rake tasks for running functional and unit tests
hahwul Feb 5, 2025
c60eb99
Add Rake task to set up the test environment
hahwul Feb 5, 2025
185986a
Add Gemfile and Gemfile.lock for RSpec and Aruba dependencies
hahwul Feb 5, 2025
4a7f2df
Remove setup task from Rakefile for the test environment
hahwul Feb 5, 2025
0eaaf96
Add GitHub Actions workflow for functional testing
hahwul Feb 5, 2025
6bccd8d
Update Gemfile to specify Rake and RSpec versions
hahwul Feb 5, 2025
9a73004
Simplify GitHub Actions workflow by removing matrix strategy for Ruby…
hahwul Feb 5, 2025
298772b
Update Gemfile to specify Aruba and Rake versions
hahwul Feb 5, 2025
c4f2299
Add logger gem and enhance functional test setup in Rakefile
hahwul Feb 5, 2025
7cad504
Add Go module vendor command to functional test setup in Rakefile
hahwul Feb 5, 2025
c6a6722
Update functional test task to use bundle exec for RSpec
hahwul Feb 5, 2025
409195d
Add RSpec task for running functional tests in Rakefile
hahwul Feb 5, 2025
18ef7c5
Update GitHub Actions workflow to enhance Ruby setup and caching
hahwul Mar 2, 2025
50ec49a
Add test for help URL command in basic_spec.rb
hahwul Mar 2, 2025
f9c719d
Rename RSpec task for functional tests in Rakefile
hahwul Mar 2, 2025
6cda8f1
Refactor Rakefile to encapsulate functional RSpec task within a test …
hahwul Mar 2, 2025
1e9b116
Enhance GitHub Actions workflow for functional tests with improved ca…
hahwul Mar 2, 2025
259a56e
Fix?
hahwul Mar 2, 2025
7525e1f
Enhance GitHub Actions workflow with debugging steps and update RSpec…
hahwul Mar 2, 2025
78e7fe7
Update GitHub Actions workflow to run RSpec tests directly instead of…
hahwul Mar 3, 2025
91361cf
Fix?
hahwul Mar 3, 2025
652add9
Update GitHub Actions workflow to install RSpec dependencies directly
hahwul Mar 3, 2025
19ec047
Fix typo in RSpec dependency installation in GitHub Actions workflow
hahwul Mar 3, 2025
dda985e
Update GitHub Actions workflow and Rakefile to use RSpec for function…
hahwul Mar 3, 2025
88afd64
✨ Linting
hahwul Mar 3, 2025
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
32 changes: 32 additions & 0 deletions .github/workflows/test-functional.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Functional Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24' # Match your go.mod
- name: Build dalfox
run: go build -o dalfox .
- name: Setup Ruby
uses: ruby/setup-ruby@v1.213.0
with:
ruby-version: 3.4.0 # Match bundle path
bundler-cache: true
cache-version: 1
- name: Install Ruby dependencies
run: bundle install # Default gem location
- name: Run RSpec tests
run: bundle exec rspec
env:
PATH: ${{ github.workspace }}:$PATH # Ensure dalfox is in PATH
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true
source 'https://rubygems.org'

gem 'aruba', '~> 2.3'
gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.13'
gem 'rspec-core', '~> 3.13' # Explicitly include rspec-core
gem 'logger'
92 changes: 92 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
GEM
remote: https://rubygems.org/
specs:
aruba (2.3.0)
bundler (>= 1.17, < 3.0)
contracts (>= 0.16.0, < 0.18.0)
cucumber (>= 8.0, < 10.0)
rspec-expectations (~> 3.4)
thor (~> 1.0)
bigdecimal (3.1.9)
builder (3.3.0)
contracts (0.17.2)
cucumber (9.2.1)
builder (~> 3.2)
cucumber-ci-environment (> 9, < 11)
cucumber-core (> 13, < 14)
cucumber-cucumber-expressions (~> 17.0)
cucumber-gherkin (> 24, < 28)
cucumber-html-formatter (> 20.3, < 22)
cucumber-messages (> 19, < 25)
diff-lcs (~> 1.5)
mini_mime (~> 1.1)
multi_test (~> 1.1)
sys-uname (~> 1.2)
cucumber-ci-environment (10.0.1)
cucumber-core (13.0.3)
cucumber-gherkin (>= 27, < 28)
cucumber-messages (>= 20, < 23)
cucumber-tag-expressions (> 5, < 7)
cucumber-cucumber-expressions (17.1.0)
bigdecimal
cucumber-gherkin (27.0.0)
cucumber-messages (>= 19.1.4, < 23)
cucumber-html-formatter (21.9.0)
cucumber-messages (> 19, < 28)
cucumber-messages (22.0.0)
cucumber-tag-expressions (6.1.2)
diff-lcs (1.5.1)
ffi (1.17.1)
ffi (1.17.1-aarch64-linux-gnu)
ffi (1.17.1-aarch64-linux-musl)
ffi (1.17.1-arm-linux-gnu)
ffi (1.17.1-arm-linux-musl)
ffi (1.17.1-arm64-darwin)
ffi (1.17.1-x86-linux-gnu)
ffi (1.17.1-x86-linux-musl)
ffi (1.17.1-x86_64-darwin)
ffi (1.17.1-x86_64-linux-gnu)
ffi (1.17.1-x86_64-linux-musl)
logger (1.6.5)
mini_mime (1.1.5)
multi_test (1.1.0)
rake (13.2.1)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.2)
sys-uname (1.3.1)
ffi (~> 1.1)
thor (1.3.2)

PLATFORMS
aarch64-linux-gnu
aarch64-linux-musl
arm-linux-gnu
arm-linux-musl
arm64-darwin
ruby
x86-linux-gnu
x86-linux-musl
x86_64-darwin
x86_64-linux-gnu
x86_64-linux-musl

DEPENDENCIES
aruba (~> 2.3)
logger
rake (~> 13.0)
rspec (~> 3.13)
rspec-core (~> 3.13)

BUNDLED WITH
2.6.3
28 changes: 27 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# frozen_string_literal: true

require 'rspec/core/rake_task'

namespace :test do
desc 'Set up the test environment for functional tests'
task :functional_setup do
sh 'go mod vendor'
sh 'go build -o dalfox .' # Explicitly name the output binary
end

desc 'Run the functional tests'
RSpec::Core::RakeTask.new(functional: :functional_setup) do |t|
t.pattern = 'spec/functional_tests/**/*_spec.rb'
t.verbose = true # More output for debugging
end

desc 'Run the unit tests'
task :unit do
sh 'go test ./...'
end

desc 'Run all tests'
task :all do
Rake::Task['test:functional'].invoke
Rake::Task['test:unit'].invoke
end
end

namespace :docs do
desc 'Serve the documentation site'
task :serve do
Expand All @@ -8,7 +35,6 @@ namespace :docs do
puts "Bundler is not installed or dependencies are not met. Please run 'rake docs:install'."
exit 1
end

sh 'bundle exec jekyll s'
end
end
Expand Down
27 changes: 27 additions & 0 deletions spec/functional_tests/basic_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Basic Run', type: :aruba do
before(:all) do
@binary_path = File.expand_path('../../dalfox', __dir__)
end

it 'prints the help' do
run_command("#{@binary_path} -h")
expect(last_command_started).to have_output(/Usage:/)
expect(last_command_started).to be_successfully_executed
end

it 'prints the help url mode' do
run_command("#{@binary_path} help url")
expect(last_command_started).to have_output(/Usage:/)
expect(last_command_started).to be_successfully_executed
end

it 'returns an error for unknown commands' do
run_command("#{@binary_path} invalid-command")
expect(last_command_started).to have_output(/unknown command/i)
expect(last_command_started).not_to be_successfully_executed
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'aruba/rspec'