Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Added feature spec for no barcode purchase #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

madisonlemmond
Copy link

Resolves #4

Description

Added a feature spec to test for when a purchase is entered with a barcode that does not yet exist.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

This issue was to add a test

@nihonjinrxs
Copy link
Member

@madisonlemmond Looks like you have a code style/formatting issue. You can see these locally by running:

bundle exec rubocop

Here's the error (which you can see by clicking Details on one of the failed builds at the bottom in the merge area or by clicking the red X next to the commit ID above):

spec/features/purchase_spec.rb:146:1: C: Layout/EmptyLines: Extra blank line detected.

If you delete the extra line at 146 (there are 2 empty lines between those 2 tests) rubocop should be happy and all should pass. Commit that change on the same branch and push to the remote, and Travis should automatically kick off a rebuild that should pass.

@armahillo
Copy link
Collaborator

armahillo commented Feb 28, 2019

If you do rubocop -a it will attempt to autocorrect, too (which can save you a lot of time on a bigger diff)

One caveat -- commit your work before running rubocop -a, then git add . (to stage it for commit), then run git diff --cached (runs a diff against the staged changes) to check the diff and see what rubocop wants to change.

Copy link
Collaborator

@armahillo armahillo left a comment

Choose a reason for hiding this comment

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

You're VERY close. What you've created looks great!

See my notes -- there are 2 things that need to be added to ensure we're actually testing what we intend to test.

# form updates
pending "TODO: adding items with a new barcode"
raise
expect(page).to have_xpath("//input[@id='_barcode-lookup-new_line_items']")
Copy link
Collaborator

Choose a reason for hiding this comment

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

What would happen if the user fills out the form and the barcode info submits, but then it fails to save the barcode?

Copy link
Author

Choose a reason for hiding this comment

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

So I should test to see if the new barcode item is saved at the end?

expect(page).to have_field "barcode_item_value", with: "0"
# fill that in
fill_in "barcode_item_quantity", with: "10"
select Item.alphabetized.first.name, from: "barcode_item_barcodeable_id"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This probably won't successfully submit a barcode because no barcode value (barcode_item_value) is set -- you can provide any alphanumeric string (no spaces) and it should accept it.

@madisonlemmond madisonlemmond force-pushed the 4-add-feature-spec-no-barcode branch from cc1af53 to 22ab344 Compare March 19, 2019 23:02
@nihonjinrxs
Copy link
Member

@armahillo ping

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[3:1] Write a feature spec for the when a Purchase is entered with no exisiting barcode (see notes)
3 participants