Skip to content

Commit

Permalink
Added tests for #192
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Ratcliffe committed Dec 24, 2018
1 parent 94628ac commit 2d7dae5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions features/run.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ Feature: Run rspec and acceptance test suites
When I run onceover command "run spec"
Then I should not see any errors

Scenario: Using regexes to define tests
Given initialized control repo "caching"
When I run onceover command "run spec"
Then I should see message pattern "apache::params"

Scenario: Run spec tests with misspelled module in Puppetfile
Given initialized control repo "basic"
And in Puppetfile is misspelled module's name
Expand Down
14 changes: 9 additions & 5 deletions features/step_definitions/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@
expect(@cmd.output.match err_msg_regexp).to_not be nil
end

Then(/^I should see message pattern "([^"]*)"$/) do |err_msg_regexp|
expect(@cmd.success?).to be true
puts @cmd.output unless @cmd.output =~ Regexp.new(err_msg_regexp)
expect(@cmd.output).to match(err_msg_regexp)
puts @cmd.output.match(err_msg_regexp).to_s
Then(/^I should see message pattern "([^"]*)"$/) do |msg_regexp|
output_surround = 30
match = Regexp.new(msg_regexp).match(@cmd.output)
expect(@cmd.output).to match(msg_regexp)
if match
puts match.pre_match[-output_surround..-1] + match.to_s + match.post_match[0..output_surround]
else
puts @cmd.output
end
end
3 changes: 2 additions & 1 deletion spec/fixtures/controlrepos/caching/spec/onceover.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ classes:
- role::database_server
- role::webserver
- role::example
- /apache::params/

# Nodes to tests classes on, this refers to a 'factset' or 'nodeset'
# depending on whether you are running 'spec' or 'acceptance' tests
Expand Down Expand Up @@ -50,4 +51,4 @@ test_matrix:
tests: 'spec'
- non_windows_nodes:
classes: 'all_classes'
tests: 'acceptance'
tests: 'acceptance'

0 comments on commit 2d7dae5

Please sign in to comment.