Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 21 23:29

    mattwynne on main

    Delete Makefile No need for th… (compare)

  • Nov 21 23:28

    mattwynne on main

    Delete Makefile No longer need… (compare)

  • Nov 14 15:12
    dependabot[bot] opened #241
  • Nov 14 15:12
    dependabot[bot] labeled #241
  • Nov 14 15:12

    dependabot[bot] on bundler

    Update cucumber-messages requir… (compare)

  • Nov 09 15:06
    dependabot[bot] labeled #240
  • Nov 09 15:06
    dependabot[bot] opened #240
  • Nov 09 15:06

    dependabot[bot] on bundler

    Update cucumber-gherkin require… (compare)

  • Nov 08 12:41
    mpkorstanje edited #157
  • Oct 25 16:51
    mattwynne commented #239
  • Oct 25 16:51
    mattwynne commented #239
  • Oct 25 16:51
    aslakhellesoy commented #239
  • Oct 25 16:51

    mattwynne on main

    Restore support for matching a … (compare)

  • Oct 25 16:51
    mattwynne closed #239
  • Oct 25 12:58
    botandrose commented #239
  • Oct 25 12:56
    botandrose synchronize #239
  • Oct 20 21:38
    mattwynne synchronize #555
  • Oct 20 21:38

    mattwynne on remove-gh-templates

    Github Actions release workflow… Use VERSION file Ref #546 Prepare release v2.6.1 Created… and 6 more (compare)

  • Oct 20 14:42
    mattwynne review_requested #239
  • Oct 13 05:21
    mattwynne closed #546
greybox99
@greybox99
how is this not duplication?
Eric Kessler
@enkessler
That's not a Ruby loop. That's copy pasting Gherkin over and over, which was not my suggestion.
greybox99
@greybox99
instead of just
"""
uptime
days
"""
Eric Kessler
@enkessler
When you get the multi-line block in your step def, #split it on newlines and loop through the resulting array.
greybox99
@greybox99
@enkessler can you show me?
Eric Kessler
@enkessler
Then(/your pattern here/) do |expected_words|
  expected_words.split("\n").each do |word|
    expect(@previously_captured_output).to include(word)
  end
end
Something like that.
greybox99
@greybox99

@enkessler
expected nil to include "days", but it does not respond to include? (RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/lines_steps.rb:3:in block (2 levels) in <top (required)>' ./features/step_definitions/lines_steps.rb:2:ineach'
./features/step_definitions/lines_steps.rb:2:in `/^the output should include:$/'

on

Then(/^the output should include:$/) do |expected_words|
expected_words.split("\n").each do |word|
expect(@previously_captured_output).to include(word)
end
end

Eric Kessler
@enkessler
So...did you save the captured output into @previously_captured_output?
greybox99
@greybox99
yeah defined @previously_captured_output before the test
Eric Kessler
@enkessler
And yet it is nil.
greybox99
@greybox99
test is
@previously_captured_output
Scenario: Verify w
When I successfully run w
Then the output should include:
"""
days
"""
Eric Kessler
@enkessler
You applied @previously_captured_output as a tag on the test?
greybox99
@greybox99
is that not the way to save it?
Eric Kessler
@enkessler
That is not the way to save it.
A Gherkin tag and a Ruby Instance variable have nothing to do with each other.
greybox99
@greybox99
why do the step def need to search for the output within that tag? should be captured under all
Eric Kessler
@enkessler
@previously_captured_output is not a tag. It is an instance variable.
Rather, in Gherkin it is a tag but in Ruby it is an instance variable.
You are working with two languages.
greybox99
@greybox99
my apologies, so how do I set this?
Eric Kessler
@enkessler
What does your When step definition look like?
greybox99
@greybox99
@enkessler it's a built in method from Aruba which allows you to run bash commands directly from Gherkin
@enkessler is there any way I can avoid specifying @previously_captured_output and just search in all?
Eric Kessler
@enkessler
I don't know. I am not familiar with Aruba.
But they appear to have a room as well: https://gitter.im/cucumber/aruba
greybox99
@greybox99
@enkessler thanks, does seem inactive though.
so expect will need a output def? you can't do it without?
greybox99
@greybox99
@enkessler doesn't a test have a test output defined?
Eric Kessler
@enkessler
Not by default, no.
greybox99
@greybox99
@enkessler is there a test wide setting I can set?
Eric Kessler
@enkessler
A setting for what?
greybox99
@greybox99
@enkessler to save the output for @previously_captured_output
from any test
Eric Kessler
@enkessler
No.
greybox99
@greybox99
hmm
Eric Kessler
@enkessler
Cucumber is just a framework for executing Gherkin. It has no idea what you might write or try do in a step definition.Very little, if anything, happens by default.
Aruba appears to be similar to Rails in the sense that it is a box of predefined magic that is built on top of underlying functionality.
You will have to find the step definition for the Aruba sep that you are using and see how it does what it does.
Eric Kessler
@enkessler
Alternatively, you could write your own step definition using any one of the methods that I linked to and then you would not be relying on magic.
greybox99
@greybox99
last_command_started
@enkessler
Then the output should include: # features/step_definitions/lines_steps.rb:1
  """
  days
  uptime
  """
  expected #<Aruba::Command(#<Aruba::Processes::SpawnProcess:9551740 commandline="w": output=" 17:00:53 up 15 days,  3:17,  1 user,  load average: 0.01, 0.02, 0.05
  USER  ...">)> to include "days", but it does not respond to `include?`
  Diff:
  @@ -1,2 +1,3 @@
  -["days"]
  +#<Aruba::Processes::SpawnProcess:9551740 commandline="w": output=" 17:00:53 up 15 days,  3:17,  1 user,  load average: 0.01, 0.02, 0.05
  +USER  ...">
   (RSpec::Expectations::ExpectationNotMetError)
  ./features/step_definitions/lines_steps.rb:3:in `block (2 levels) in <top (required)>'
  ./features/step_definitions/lines_steps.rb:2:in `each'
  ./features/step_definitions/lines_steps.rb:2:in `/^the output should include:$/'
Eric Kessler
@enkessler
Try this step:
Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/)
It takes a table instead of a multiline string.
greybox99
@greybox99
so
Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) do |expected_words|
expected_words.split("\n").each do |word|
expect(last_command_started).to include(word)
end
end
Eric Kessler
@enkessler
I think that it is already defined. Just use it in your Gherkin.
greybox99
@greybox99
oh

Ambiguous match of "the output should contain all of these lines:":

aruba-0.14.2/lib/aruba/cucumber/command.rb:356:in /^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/' features/step_definitions/lines_steps.rb:1:in/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/'