Implement chef test unit command that can run ChefSpec #18
Comments
👍 for |
we could easily put rspec in /opt/chefdk/bin and setup a symlink from /usr/bin to there, but i worry a bit about it getting into fights with rspec installed into system gems (more so that i worry about any of the binaries that are specific to the chef ecosystem that we have in there so far). |
Running tests via the |
So, ChefSpec is just RSpec. I'm generally 👎 on a separate binary called |
@sethvargo I totally understand that, but when we put "includes ChefSpec" on the tin and then hide it in the embedded directory and tell people to f with their paths and what-not, it doesn't feel like a good experience. @lamont-granquist already mentioned the possible problems with just putting I just want a command that's easily and reliably available to run my unit specs on my cookbooks. It can be called |
ln -sf /opt/chef/embedded/bin/rspec /usr/bin/sethspec must.... resist... urge... to... submit... patch... i think we should probably have a 'chef run ' that just throws /opt/chef/bin + /opt/chef/embedded/bin in the PATH and then execs the command (and sets ruby env vars to escape rvm, etc). i don't think that's the final solution, but this isn't likely to be the first time we hit this, and it gives us a stock answer in the general case. could also be 'chef exec ' or other names... |
I wrote some thoughts about that here: #16 |
@lamont-granquist I really like that |
I like dan's thoughts about having commands to either drop into .bashrc and/or to setup .bashrc to manage the PATH as well. But managing state like that will probably cause issues, and i still kinda like the idea of just executing an arbitrary command with the right environment, which we can get right more often than not. I'd sort of like the all-of-the-above solution -
|
I personally think
With the .bash* options, what if I use ZSH? Or FISH? And that's MY .bashrc - you're basically telling me that Chef now owns my laptop, and I'm not sure I'm on board with that. On the flip side, if I have no idea what shell I want to use, you've added an additional layer of abstraction. What the heck is a I think the profile approach just isn't sustainable. Like @lamont-granquist said, maintaining that state will be hard and a source of headache. Just a sample ideaish thing of what I'm thinking: #!/bin/sh
GEM_HOME=/opt/chefdk/embedded/lib/ruby/gems/whatever GEM_ROOT=/some/path $@ Just like Just a note - I'm preferential to |
Yeah, I was just not sure if there was a better logical feature for |
And yeah, from the perspective of, say, answering a question on stack exchange. I don't really want to have to walk the user through setting up bash/zsh/fish/whatever first. If I can just have them fire off a |
@sethvargo I don't think supporting bash and zsh is hard, and anyone using any other shell will probably be a power user who can get a path into their PATH with no problem. I don't think chefdk should modify your shellrc, but it's pretty easy to put "add That said, I think a |
I like |
There's a WIP patch for the |
Yeah, I think we agree to do all-the-things. |
|
Added |
what is the preferred way to run chefspecs if I only have chefdk installed? Right now providing the full path to where the gem was installed is my only option. Thanks! |
@jperry At the moment, either |
@danielsdeleo - ah great. Thanks! I am grabbing this one: https://opscode-omnibus-packages.s3.amazonaws.com/mac_os_x/10.9/x86_64/chefdk-0.2.0-1.dmg |
@danielsdeleo - seems to have issues after running rspec with 0.2.0
my Path
|
The root cause of this is that chefspec 3.4.0 requires rspec ~> 2.14, but running |
thanks I'll give that a try. |
@danielsdeleo - did the
I tried doing chef shell-init bash and when I do that it can't find rspec. Any other ideas? |
Update: I wasn't running the chef shell-init with eval which was my second problem. Now after running |
@jperry Can you file a new issue for this, since it's only tangentially related to adding a |
sure will do. |
It's still subject to change but you can see commits to delivery-cli about prototyping something very close to this functionality now in chef-boneyard/delivery-cli@51974bb . |
In order to run my ChefSpec tests I have to use /opt/chefdk/embedded/bin/rspec. This is weird. It would be nice if I could just run
chefspec
(as some kind of alias to chefdk'srspec
) or a command likechef test unit
.The text was updated successfully, but these errors were encountered: