Question

Following the gem development guide, I have come to the part where I am checking the contents of a file. Because there are pounds and multiple lines, the contents being checked is escaped with \# and \n.

  Scenario: Recipes                                  # features/generator.feature:6
    When I run `foodie recipe dinner steak`          # aruba-0.5.3/lib/aruba/cucumber.rb:60
    Then the following files should exist:           # aruba-0.5.3/lib/aruba/cucumber.rb:256
      | dinner/steak.txt |
    Then the file "dinner/steak.txt" should contain: # aruba-0.5.3/lib/aruba/cucumber.rb:300
      """
      ##### Ingredients #####
      Ingredients for delicious steak go here.


      ##### Instructions #####
      Tips on how to make delicious steak go here.
      """
      expected: /\#\#\#\#\#\ Ingredients\ \#\#\#\#\#\nIngredients\ for\ delicious\ steak\ go\ here\.\n\n\n\#\#\#\#\#\ Instructions\ \#\#\#\#\#\nTips\ on\ how\ to\ make\ delicious\ steak\ go\ here\./
           got: "#### Ingredients ####\nIngredients for delicious steak go here.\n\n\n#### Indtructions ####\nTips on how to make delicious steak go here.\n" (using =~)
      Diff:
      @@ -1,2 +1,7 @@
      -/\#\#\#\#\#\ Ingredients\ \#\#\#\#\#\nIngredients\ for\ delicious\ steak\ go\ here\.\n\n\n\#\#\#\#\#\ Instructions\ \#\#\#\#\#\nTips\ on\ how\ to\ make\ delicious\ steak\ go\ here\./
      +#### Ingredients ####
      +Ingredients for delicious steak go here.
      +
      +
      +#### Indtructions ####
      +Tips on how to make delicious steak go here.
       (RSpec::Expectations::ExpectationNotMetError)
      features/generator.feature:10:in `Then the file "dinner/steak.txt" should contain:'

Failing Scenarios:
cucumber features/generator.feature:6 # Scenario: Recipes

3 scenarios (1 failed, 2 passed)
7 steps (1 failed, 6 passed)
0m0.950s

Is there something that I am doing wrong, or is this guide older and there should be something else that I should do to prevent the file from checking against escaped text?

Update:

If I change the file and the test to one line and remove the pound characters, the test will pass.

  Scenario: Recipes                                  # features/generator.feature:6
    When I run `foodie recipe dinner steak`          # aruba-0.5.3/lib/aruba/cucumber.rb:60
    Then the following files should exist:           # aruba-0.5.3/lib/aruba/cucumber.rb:256
      | dinner/steak.txt |
    Then the file "dinner/steak.txt" should contain: # aruba-0.5.3/lib/aruba/cucumber.rb:300
      """
      Ingredients: Delicious steak ingredients go here.
      """
Was it helpful?

Solution

Escaping is not your problem, you have a typo in your generator:

#### Indtructions ####

Pounds in expected part are escaped because it is a regular expression. got part is a string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top