-
Notifications
You must be signed in to change notification settings - Fork 18
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
|
@@ -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| | ||
t.cucumber_opts = "--format pretty" # Any valid command line option can go here. | ||
end | ||
|
||
task default: [:spec, :features] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note there is no rubocop because it's not defined, despite including |
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: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. then we can update the manifest:
Suggested change
|
||||||
|
||||||
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 |
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" |
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
|
||
expect(output).to have_errors(error).and(have_warnings(warning)) | ||
end |
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 |
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
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
.