Skip to content

Convert from Litmus to Cucumber #89

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

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 0 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,3 @@ jobs:
with:
rake_task: "spec:coverage"
ruby_version: ${{ matrix.ruby_version }}

acceptance:
strategy:
fail-fast: false
matrix:
ruby_version:
- '2.7'
- '3.2'
- '3.3'
name: "acceptance (ruby ${{ matrix.ruby_version }})"
needs: "spec"
uses: "puppetlabs/cat-github-actions/.github/workflows/gem_acceptance.yml@main"
secrets: "inherit"
with:
ruby_version: ${{ matrix.ruby_version }}
9 changes: 3 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ source 'https://rubygems.org'
gemspec

group :test do
gem 'aruba', '~> 2.0'
gem 'cucumber', '~> 8.0'

gem 'rake'
gem 'rspec-its', '~> 1.0'

Expand All @@ -14,12 +17,6 @@ group :test do
gem 'simplecov-console', :require => false
end

group :acceptance do
gem 'serverspec'
gem 'puppetlabs_spec_helper'
gem 'puppet_litmus'
end

group :development do
gem 'github_changelog_generator', '~> 1.15.0', require: false
gem 'faraday-retry', require: false
Expand Down
9 changes: 5 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require 'rubocop/rake_task'
require 'github_changelog_generator/task'
require 'puppet-lint/version'
require 'rspec/core/rake_task'
require 'puppetlabs_spec_helper/tasks/fixtures'
require 'cucumber/rake/task'

begin
require 'github_changelog_generator/task'
Expand Down Expand Up @@ -39,7 +39,8 @@ RSpec::Core::RakeTask.new(:spec) do |t|
t.exclude_pattern = 'spec/acceptance/**/*_spec.rb'
end

desc 'Run acceptance tests'
task :acceptance do
Rake::Task['litmus:acceptance:localhost'].invoke
Cucumber::Rake::Task.new(:features) do |t|
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that right now this isn't run in CI because that explicitly calls spec.

t.cucumber_opts = "--format pretty" # Any valid command line option can go here.
end

task default: [:spec, :features]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note there is no rubocop because it's not defined, despite including rubocop/rake_task on line 2. Ideally that should actually be there.

38 changes: 38 additions & 0 deletions features/manifest.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Feature: With a manifest provided
Scenario: containing one problem
Given a file named "fail.pp" with:
"""
# foo
class test::foo { }
"""
When I run `puppet-lint fail.pp`
Then it has 1 error and 0 warnings

Scenario: containing a control statement
Given a file named "ignore.pp" with:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I first did have a version which loaded fixtures, but decided to inline things here for now.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is more readable to have the content here 💯 .

"""
"test" # lint:ignore:double_quoted_strings
"""
When I run `puppet-lint ignore.pp`
Then it has 0 errors and 0 warnings
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we can update the manifest:

Suggested change
Then it has 0 errors and 0 warnings
Then I should see 0 errors and 0 warnings


Scenario: containing one warning
Given a file named "test/manifests/warning.pp" with:
"""
# foo
define test::warning($foo='bar', $baz) { }
"""
When I run `puppet-lint test/manifests/warning.pp`
Then I should see 0 errors and 1 warning

Scenario: containing two warnings
Given a file named "test/manifests/two_warnings.pp" with:
"""
# foo
define test::two_warnings() {
$var1-with-dash = 42
$VarUpperCase = false
}
"""
When I run `puppet-lint test/manifests/two_warnings.pp`
Then I should see 0 errors and 2 warnings
14 changes: 14 additions & 0 deletions features/no_manifest.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Feature: Without a manifest provided
Scenario: no arguments
When I run `puppet-lint`
Then the exit status should be 1

Scenario: with --help
When I run `puppet-lint --help`
Then the exit status should be 0

Scenario: with --help
When I run `puppet-lint --version`
Then the exit status should be 0
# TODO: dynamically retrieve puppet-lint version
And the output should contain "puppet-lint 3.0.1"
7 changes: 7 additions & 0 deletions features/step_definitions/stepdefs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Then('I should see {int} error(s) and {int} warning(s)') do |error, warning|
expected_exit = error.zero? ? 0 : 1
step "the exit status should be #{expected_exit}"

output = last_command_started.public_send :stdout, wait_for_io: 0

Check failure on line 5 in features/step_definitions/stepdefs.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 3.3) / spec

Style/SendWithLiteralMethodName: Use `stdout` method call directly instead.

Check failure on line 5 in features/step_definitions/stepdefs.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 3.2) / spec

Style/SendWithLiteralMethodName: Use `stdout` method call directly instead.

Check failure on line 5 in features/step_definitions/stepdefs.rb

View workflow job for this annotation

GitHub Actions / spec (ruby 2.7) / spec

Style/SendWithLiteralMethodName: Use `stdout` method call directly instead.
expect(output).to have_errors(error).and(have_warnings(warning))
end
25 changes: 25 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'aruba/cucumber'

require 'rspec'

RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = :expect
end
end

RSpec::Matchers.define :have_errors do |expected|
match do |actual|
actual.split("\n").count { |line| line.include?('ERROR') } == expected
end

diffable
end

RSpec::Matchers.define :have_warnings do |expected|
match do |actual|
actual.split("\n").count { |line| line.include?('WARNING') } == expected
end

diffable
end
46 changes: 0 additions & 46 deletions spec/acceptance/puppet_lint_spec.rb

This file was deleted.

6 changes: 0 additions & 6 deletions spec/spec_helper_acceptance.rb

This file was deleted.

38 changes: 0 additions & 38 deletions spec/spec_helper_acceptance_local.rb

This file was deleted.

Loading