Skip to content

Pr 4#4

Open
CheezItMan wants to merge 2 commits intomasterfrom
pr-4
Open

Pr 4#4
CheezItMan wants to merge 2 commits intomasterfrom
pr-4

Conversation

@CheezItMan
Copy link

This method finds the 1st xml file in the folder.

require 'minitest/reporters'
require 'minitest/skip_dsl'
require 'awesome_print'
# Add simplecov

Choose a reason for hiding this comment

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

include simplecov!


describe "find_xml_file" do
it "should return nil if there are no xml files" do
expect(find_xml_file('.')).must_be_nil
Copy link

Choose a reason for hiding this comment

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

Looks good

if filename.match "\.xml$"
xml_file = filename
break
end

Choose a reason for hiding this comment

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

This will iterate through "files", break and return the first match and not all matches, is that your intention?

@@ -0,0 +1,15 @@

def find_xml_file(folder)
files = Dir.entries(folder)
Copy link

Choose a reason for hiding this comment

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

please include to describe what this does

files.each do |filename|
if filename.match "\.xml$"
xml_file = filename
break
Copy link

Choose a reason for hiding this comment

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

use return instead of break

@@ -0,0 +1,15 @@

def find_xml_file(folder)
files = Dir.entries(folder)
Copy link

Choose a reason for hiding this comment

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

What is Dir? Please add comment to explain where this comes from

end
end

return xml_file
Copy link

Choose a reason for hiding this comment

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

what is xml_file is still nil (i.e., no match) - do you want to return an informative statement in this case?


files.each do |filename|
if filename.match "\.xml$"
xml_file = filename

Choose a reason for hiding this comment

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

Are you only looking for the last xml file? This will replace the xml file each time it finds one

@@ -0,0 +1,15 @@

Choose a reason for hiding this comment

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

Consider adding a comment to describe the purpose of this function

expect(find_xml_file('.')).must_be_nil
end

it "should return an xml file if it's in the folder" do

Choose a reason for hiding this comment

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

Is "example.xml" the only xml file in your test data folder? Consider clarifying which xml file you are expecting it to find

require 'minitest/reporters'
require 'minitest/skip_dsl'
require 'awesome_print'
# Add simplecov

Choose a reason for hiding this comment

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

simplecov doesn't look like it was added

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.

8 participants