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

When running tests, cucumber tries to load support/roles/file.rb and blows up #88

Closed
anujbiyani opened this issue Dec 15, 2012 · 7 comments

Comments

@anujbiyani
Copy link
Contributor

The Wiki says to put roles in ./support/roles/ so I created ./support/roles/base.rb with the contents

name 'base'
description 'shared role applied to all nodes'

run_list(
  "recipe[chef-client]",
  "recipe[git]"
)

Now if I run any cucumber-chef test (regardless of whether or not the test tries to upload a role), I get the error

$> cucumber
  * cucumber-chef v2.0.7 - connected to test lab
undefined method `name' for main:Object (NoMethodError)
<chef_repo>/features/support/roles/base.rb:1:in `<top (required)>'
<gemset_dir>/gems/cucumber-1.2.1/lib/cucumber/rb_support/rb_language.rb:129:in `load'
<gemset_dir>/gems/cucumber-1.2.1/lib/cucumber/rb_support/rb_language.rb:129:in `load_code_file'
<gemset_dir>/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:172:in `load_file'
<gemset_dir>/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:84:in `block in load_files!'
<gemset_dir>/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:83:in `each'
<gemset_dir>/gems/cucumber-1.2.1/lib/cucumber/runtime/support_code.rb:83:in `load_files!'
<gemset_dir>/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:175:in `load_step_definitions'
<gemset_dir>/gems/cucumber-1.2.1/lib/cucumber/runtime.rb:40:in `run!'
<gemset_dir>/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:43:in `execute!'
<gemset_dir>/gems/cucumber-1.2.1/lib/cucumber/cli/main.rb:20:in `execute'
<gemset_dir>/gems/cucumber-1.2.1/bin/cucumber:14:in `<top (required)>'
<gemset_dir>/bin/cucumber:23:in `load'
<gemset_dir>/bin/cucumber:23:in `<main>'

It seems to be because Cucumber automatically loads files in ./features/support, then tries to execute base.rb which then blows up.

Without monkey-patching Cucumber, I'm not sure what to do about fixing this unless Cucumber-Chef is changed so it doesn't load roles from a subdirectory of ./features/support.

Another related concern I have is that any role that I create for my project is in ./roles, but any roles that the feature tests use have to be in ./features/support/roles. This implies that any role that I use in production and want to use in a test would have to be duplicated in both directories.

Is there any reason why Cucumber-Chef shouldn't load roles from ./roles?

(For now I'm simply uploading roles by hand with cc-knife role from file FILE.)

@zpatten
Copy link
Collaborator

zpatten commented Dec 18, 2012

Ya this shouldn't be happening; I should have something for you in the next day or so.

@zpatten
Copy link
Collaborator

zpatten commented Jan 4, 2013

Sorry; holidays took most of my time so I wasn't able to work on this issue. Going to take a stab at it this weekend.

@anujbiyani
Copy link
Contributor Author

No problem, I'm quite happy so far with manually uploading roles since that's the same thing I have to do in production.

@zpatten
Copy link
Collaborator

zpatten commented Jan 16, 2013

Been working on CC; I think I know why your having issues. You need at add something along the lines of this to your cucumber.yml in the root of your chef-repo:

    ---
    default: -c -v --exclude support/cookbooks --exclude support/data_bags --exclude support/keys --exclude support/roles

Otherwise; cucumber tries to load all files under the features directory and since cucumber doesn't rightfully understand the Chef DSL it will proceed to blow up.

@zpatten
Copy link
Collaborator

zpatten commented Jan 16, 2013

Also; if you want to load roles directory from your repo; you should be able to. Instead of using ./features/support/roles/xyz, you should be able to just say ./roles/xyz.

@anujbiyani
Copy link
Contributor Author

The cucumber.yml addition worked perfectly, thanks!

I thought I had tried uploading from ./roles/xyz and found that it wasn't working, but I just tried it and it's working just fine. I must've screwed something up a while back or be misremembering.

I'll update the Wiki with the cucumber.yml info; I'm fairly new to Cucumber and so didn't know about that file, and I think it'd help people like me if this info were stated (or maybe just this issue linked to) from the Wiki.

Thanks again.

@zpatten
Copy link
Collaborator

zpatten commented Jan 16, 2013

Awesome; glad to hear that worked for you. I must admit the wiki needs some loving; thank you for adding the note to it, I appreciate it very much!

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

No branches or pull requests

2 participants