Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appveyor cucumber #653

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
17 changes: 7 additions & 10 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,8 @@ jobs:

strategy:
matrix:
ruby: ["3.0", jruby-9.2]
ruby: [2.7, "3.0"]
appraisal: [cucumber_7]
include:
- ruby: "2.5"
appraisal: cucumber_4
- ruby: "2.6"
appraisal: cucumber_5
- ruby: "2.7"
appraisal: cucumber_6

env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.appraisal }}.gemfile
Expand Down Expand Up @@ -63,7 +56,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [2.5, 2.6, 2.7, "3.0"]
ruby: [2.7, "3.0"]

runs-on: macos-latest

Expand All @@ -83,7 +76,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [2.5, 2.6, 2.7, "3.0"]
ruby: [2.7, "3.0"]

runs-on: windows-latest

Expand All @@ -96,8 +89,12 @@ jobs:
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Install ansicon to silence colour warnings
run: cinst ansicon
- name: Run specs
run: bundle exec rake spec
- name: Run cukes
run: bundle exec rake cucumber

checks:

Expand Down
7 changes: 1 addition & 6 deletions features/04_aruba_api/command/run_command.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ Feature: Run command
Given I use a fixture named "cli-app"

Scenario: Executable in the project's path
Given an executable named "bin/aruba-test-cli" with:
"""bash
#!/bin/bash
exit 0
"""
And a file named "spec/run_spec.rb" with:
Given a file named "spec/run_spec.rb" with:
"""ruby
require 'spec_helper'

Expand Down
39 changes: 17 additions & 22 deletions features/05_use_rspec_matchers/command/check_timeouts.feature
Original file line number Diff line number Diff line change
@@ -1,47 +1,42 @@
Feature: Check if a timeout occured during command execution

If you want to check if a command takes to long to finish it's work
If you want to check if a command takes too long to finish its work, you can
use the `run_too_long` and `have_finished_in_time` matchers.

Background:
Given I use a fixture named "cli-app"

Scenario: Check if command runs to long
Given an executable named "bin/aruba-test-cli" with:
"""
#!/bin/bash
sleep 1
"""
And a file named "spec/timeout_spec.rb" with:
Scenario: Check if command runs too long
Given a file named "spec/timeout_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Long running command', :type => :aruba do
before { aruba.config.exit_timeout = 0 }

before { run_command('aruba-test-cli') }
RSpec.describe 'Long running command', type: :aruba do
before { aruba.config.exit_timeout = 0.1 }

it { expect(last_command_started).to run_too_long }
it "runs too long" do
slow_command = which('sleep') ? 'sleep 0.2' : 'timeout 2'
run_command slow_command
expect(last_command_started).to run_too_long
end
end
"""
When I run `rspec`
Then the specs should all pass

Scenario: Check if command finishes in time
Given an executable named "bin/aruba-test-cli" with:
"""
#!/bin/bash
exit 0
"""
And a file named "spec/timeout_spec.rb" with:
Given a file named "spec/timeout_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Short running command', :type => :aruba do
RSpec.describe 'Short running command', type: :aruba do
before { aruba.config.exit_timeout = 5 }

before { run_command('aruba-test-cli') }
it "is done quickly" do
run_command('echo "Fast!"')

it { expect(last_command_started).to have_finished_in_time }
expect(last_command_started).to have_finished_in_time
end
end
"""
When I run `rspec`
Expand Down
104 changes: 19 additions & 85 deletions features/05_use_rspec_matchers/file/be_a_command_found_in_path.feature
Original file line number Diff line number Diff line change
@@ -1,114 +1,48 @@
Feature: Check if command can be found in PATH

If you need to check if a given command can be found in path, you can use the
`be_an_existing_executable`-matcher.

```ruby
require 'spec_helper'

RSpec.describe 'Check if command can be found in PATH', :type => :aruba do
let(:file) { 'file.sh' }
before { touch(file) }
before { chmod(0o755, file) }
before { prepend_environment_variable('PATH', format('%s:', expand_path('.')) }

it { expect(file).to be_an_existing_executable }
end
```
`be_a_command_found_in_path`-matcher.

Background:
Given I use a fixture named "cli-app"

Scenario: Expect single existing executable file
@unsupported-on-platform-windows
Scenario: Checking an existing executable file in PATH on Unix
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Check if command can be found in PATH', :type => :aruba do
let(:file) { 'file.sh' }

before { touch(file) }
before { chmod(0o755, file) }
before { prepend_environment_variable('PATH', format('%s:', expand_path('.'))) }

it { expect(file).to be_a_command_found_in_path }
end
"""
When I run `rspec`
Then the specs should all pass

Scenario: Expect single non-existing executable file
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Check if command can be found in PATH', :type => :aruba do
let(:file) { 'file.sh' }

before { prepend_environment_variable('PATH', format('%s:', expand_path('.'))) }

it { expect(file).not_to be_a_command_found_in_path }
end
"""
When I run `rspec`
Then the specs should all pass
RSpec.describe 'Check if command can be found in PATH', type: :aruba do
let(:file) { 'my-exe' }

Scenario: Expect single non-executable file
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Check if command can be found in PATH', :type => :aruba do
let(:file) { 'file.sh' }

before { touch(file) }
before { prepend_environment_variable('PATH', format('%s:', expand_path('.'))) }

it { expect(file).not_to be_a_command_found_in_path }
end
"""
When I run `rspec`
Then the specs should all pass

Scenario: Expect multiple existing executable files
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
let(:files) { %w(file1.sh file2.sh) }

before :each do
files.each do |f|
touch(f)
chmod(0o755, f)
end
before do
touch(file)
chmod(0o755, file)
prepend_environment_variable('PATH', format('%s:', expand_path('.')))
end

before { prepend_environment_variable('PATH', format('%s:', expand_path('.'))) }

it { expect(files).to all be_a_command_found_in_path }
it { expect(file).to be_a_command_found_in_path }
end
"""
When I run `rspec`
Then the specs should all pass

Scenario: Expect a least one existing executable file
@unsupported-on-platform-unix
Scenario: Checking an existing executable file in PATH on Windows
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
let(:files) { %w(file1.sh file2.sh) }
RSpec.describe 'Check if command can be found in PATH', type: :aruba do
let(:file) { 'foo.bat' }

before :each do
touch(files.first)
chmod(0o755, files.first)
before do
touch(file)
chmod(0o755, file)
prepend_environment_variable('PATH', format('%s:', expand_path('.')))
end

before { prepend_environment_variable('PATH', format('%s:', expand_path('.'))) }

it { expect(files).to include a_command_found_in_path }
it { expect(file).to be_a_command_found_in_path }
end
"""
When I run `rspec`
Expand Down
73 changes: 16 additions & 57 deletions features/05_use_rspec_matchers/file/be_existing_executable.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,85 +3,44 @@ Feature: Check if path exists and is an executable file
If you need to check if a given path exists and is a file, you can use the
`be_an_existing_executable`-matcher.

```ruby
require 'spec_helper'

RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
let(:file) { 'file.txt' }
before { touch(file) }
before { chmod(0o755, file) }

it { expect(file).to be_an_existing_executable }
end
```

Background:
Given I use a fixture named "cli-app"

Scenario: Expect single existing executable file
@unsupported-on-platform-windows
Scenario: Checking an executable file by permissions on Unix
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
let(:file) { 'file.txt' }
before { touch(file) }
before { chmod(0o755, file) }

it { expect(file).to be_an_existing_executable }
end
"""
When I run `rspec`
Then the specs should all pass

Scenario: Expect single non-existing executable file
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'
RSpec.describe 'Check if file exists and is an executable file', type: :aruba do
let(:file) { 'my-exe' }

RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
let(:file) { 'file.txt' }
it { expect(file).not_to be_an_existing_executable }
end
"""
When I run `rspec`
Then the specs should all pass

Scenario: Expect multiple existing executable files
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
let(:files) { %w(file1.txt file2.txt) }

before :each do
files.each do |f|
touch(f)
chmod(0o755, f)
end
before do
touch(file)
chmod(0o755, file)
end

it { expect(files).to all be_an_existing_executable }
it { expect(file).to be_an_existing_executable }
end
"""
When I run `rspec`
Then the specs should all pass

Scenario: Expect a least one existing executable file
@unsupported-on-platform-unix
Scenario: Checking an executable file by file name on Windows
Given a file named "spec/existing_executable_spec.rb" with:
"""
require 'spec_helper'

RSpec.describe 'Check if file exists and is an executable file', :type => :aruba do
let(:files) { %w(file1.txt file2.txt) }
RSpec.describe 'Check if file exists and is an executable file', type: :aruba do
let(:file) { 'foo.bat' }

before :each do
touch(files.first)
chmod(0o755, files.first)
before do
touch(file)
chmod(0o755, file)
end

it { expect(files).to include an_existing_executable }
it { expect(file).to be_an_existing_executable }
end
"""
When I run `rspec`
Expand Down
12 changes: 12 additions & 0 deletions features/step_definitions/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
skip_this_scenario
end

Before "@requires-bash" do
next unless Aruba.platform.which("bash").nil?

skip_this_scenario
end

Before "@requires-sleep" do
next unless Aruba.platform.which("sleep").nil?

skip_this_scenario
end

Before "@requires-posix-standard-tools" do
next unless Aruba.platform.which("printf").nil?

Expand Down
6 changes: 6 additions & 0 deletions fixtures/cli-app/bin/aruba-test-cli.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "./aruba-test-cli" %1 %2 %3 %4 %5%6 %7 %8 %9
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*
Loading