Skip to content

#1403 : string description for feature specs #1426

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

Closed
wants to merge 3 commits into from

Conversation

sivagollapalli
Copy link

#1403 string description for feature specs

@sivagollapalli sivagollapalli changed the title #1403 : string description for feature description #1403 : string description for feature specs Jul 28, 2015
@cupakromer
Copy link
Member

Thanks for submitting this ❤️

Looks like the issue is with one of the rubocop's. I think simply changing collect to map will fix it.

@@ -8,8 +8,9 @@ class FeatureGenerator < Base

def generate_feature_spec
return unless options[:feature_specs]
file_name = table_name.split(" ").collect(&:downcase).join("_")
Copy link
Member

Choose a reason for hiding this comment

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

Since this is in a generator both Rails and Active Support have already been loaded. Perhaps change this to the following to provide a wider range of character conversion support:

file_name = table_name.parameterize.underscore

Thoughts?

@sivagollapalli
Copy link
Author

@cupakromer Thanks for your suggestion. I have updated my PR with latest changes. Please check.

@cupakromer
Copy link
Member

Looking good so far. I double checked and I think table_name isn't what we want here. Issue #1403 is asking about not pluralizing the names. As written this PR update will not fix that.

I think what you want is simply name instead of table_name. I believe that should be what the user passes in on the command line. Additionally the generator template will need an update to not pluralize the name there as well.

However, thinking about this a little more this change would break existing functionality for generators that map to expected constants or routes. Here are some command samples with the file and spec name I would expect to get generated:

$ bin/rails g rspec:feature Admin::WidgetsController

# spec/features/admin/widgets_controller_spec.rb
RSpec.feature "Admin::WidgetsController", type: :feature do
  # ...
end


$ bin/rails g rspec:feature api/v1/widgets

# spec/features/api/v1/widgets_spec.rb
RSpec.feature "api/v1/widgets", type: :feature do
  # ...
end


$ bin/rails g rspec:feature "Hello! This is my first RSpec::Rails feature"

# spec/features/hello_this_is_my_first_rspec_rails_feature_spec.rb
RSpec.feature "Hello! This is my first RSpec::Rails feature", type: :feature do
  # ...
end

@sivagollapalli
Copy link
Author

@cupakromer I am thinking to modify table_name.parameterize.underscore to name.camelize.demodulize.parameterize.underscore. But this line would satisfy following one scenario:

$ bin/rails g rspec:feature api/v1/widgets

# spec/features/api/v1/widgets_spec.rb
RSpec.feature "api/v1/widgets", type: :feature do
  # ...
end

I am stuck to how to get it pass the remaining two scenarios. Could you help me?

@sivagollapalli
Copy link
Author

@cupakromer Could you please reply?

@cupakromer
Copy link
Member

😿 sorry I completely dropped the ball on this one. Closing in favor of #1503

@cupakromer cupakromer closed this Dec 10, 2015
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.

2 participants