Skip to content
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

Add step and API to add whole lines to a file #780

Merged
merged 4 commits into from
Jan 31, 2021

Conversation

mvz
Copy link
Contributor

@mvz mvz commented Jan 24, 2021

Summary

Add step and API to add whole lines to a file

Details

Due to how multi-line string literals work in Gherkin, it is easy to accidentally have fewer newlines than intended when building up a file using append_to_file.

To mitigate this while still allowing building up files without inserted newlines, this change introduces a new API method #append_lines_to_file and a corresponding step definition, that will ensure a newline is present between the original content and the added content.

Motivation and Context

Fixes #662.

How Has This Been Tested?

A new Cucumber scenario and RSpec specs were added.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • I've added tests for my code
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@mvz mvz force-pushed the issue-662-add-append-lines-functionality branch from 607f376 to 50bc4c1 Compare January 24, 2021 11:18
@@ -26,6 +26,28 @@ Feature: Append content to file
When I run `cucumber`
Then the features should all pass

Scenario: Append whole lines to a existing file
Copy link
Contributor

Choose a reason for hiding this comment

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

An existing

Copy link
Contributor

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

Looks good! Found an easy typo.

Due to how multi-line string literals work in Gherkin, it is easy to
accidentally have fewer newlines than intended when building up a file
using append_to_file.

To mitigate this while still allowing building up files without inserted
newlines, this change introduces a new API method #append_lines_to_file and
a corresponding step definition, that will ensure a newline is present
between the original content and the added content.
@mvz mvz force-pushed the issue-662-add-append-lines-functionality branch from 50bc4c1 to ac69b3e Compare January 24, 2021 18:08
Copy link
Contributor

@olleolleolle olleolleolle left a comment

Choose a reason for hiding this comment

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

Wanted to say YAY you have such drive!

Copy link
Contributor

@luke-hill luke-hill left a comment

Choose a reason for hiding this comment

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

Minor refactor, not needed here. Do if you want.

@@ -4,6 +4,23 @@
RSpec.describe Aruba::Api::Filesystem do
include_context "uses aruba API"

describe "#append_lines_to_file" do
let(:path) { @file_path }
Copy link
Contributor

Choose a reason for hiding this comment

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

pop these as top level? Seem to be used in nearly all of the examples (I scrolled down past L40)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense, yes.

@mvz mvz force-pushed the issue-662-add-append-lines-functionality branch from adef003 to 99e13be Compare January 31, 2021 11:09
@mvz mvz force-pushed the issue-662-add-append-lines-functionality branch from 99e13be to 6b65b2e Compare January 31, 2021 11:14
@mvz mvz merged commit 06566ee into master Jan 31, 2021
@mvz mvz deleted the issue-662-add-append-lines-functionality branch January 31, 2021 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The 'append to file' steps should add newlines
3 participants