-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
Path Content #250
Path Content #250
Conversation
Ok. I liked the name |
I think reading from a file is a fundamentally different thing that getting a list of files and directories for a given path. I don't like the two responsibilities collapsed in one method. I prefer single responsibility principle and separation of concern. |
So you would prefer to have something like |
I agree with @jarl-dk. How about |
Great. Good idea. Will fix this. |
ooh, or even maybe |
aaah... we should decide how we name commands... ;-) |
... and one thing I forgot... |
So I prefer to have 3 separate commands:
Since all other commands are written in full, I would prefer list written in full as well. |
Sure, do it. I just though it would be fun to emulate bash commands. |
How about instead of having |
@mattwynne My first thought was "cool, I like this", but then "what if we decided to implement it differently then the shell command is implemented". I think, if we decide to do that we need to provide it either as a separate module to include or rename all other methods where a similar bash command exists.
@jarl-dk I like the idea, but would say it's another command and could be used internally as well. I know, that a custom matcher would be better, but this reads good as well, doesn't it? it { expect(list('dir.d')). to include 'file.txt' } |
BTW: |
|
@mattwynne This one, too. Please. |
# Return content of directory | ||
# | ||
# @return [Array] | ||
# The content of file or directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this comment wrong now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Fixed.
def relative?(path) | ||
Pathname.new(path).relative? | ||
end | ||
|
||
# Return all existing paths (directories, files) in current dir | ||
# | ||
# @return [Array] | ||
# List of files and directories | ||
def all_paths |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this method? If we have list
and expand_path
I think people can compose this themselves. Seems like API noise to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't noticed that you mean all_paths
. This one was added by me to reduce code duplication in check_file_presence
and in Then /^(?:a|the) file matching %r<(.*?)> should (not )?exist$/ do |pattern, expect_match|
. And of course users can compose this, but I really like to write in RSpec
`expect(all_paths).to include ('dir.d'). It reads well and reduces the boilerplate code needed to set this up. And this one was added ealier 😄.
Apart from minor comments this looks great @dg-ratiodata. I really like how you're making the effort to document and spec everything. You're a great asset to the team! |
Please merge this in when you're ready. |
Thanks a lot!
Thanks again. I started to refactor the whole feature suite. Will push this soon. |
I leave |
This reads content from
And returns an array of content. Next step would be to use it "everywhere" in the code.
rubcop
complains if I useArgumentError
although that should be ok. For now I disabled the check.