Skip to content

Update scaffold generator to care about --api flag. #1685

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

Merged
merged 2 commits into from
Aug 22, 2016
Merged

Update scaffold generator to care about --api flag. #1685

merged 2 commits into from
Aug 22, 2016

Conversation

k3rni
Copy link
Contributor

@k3rni k3rni commented Aug 5, 2016

  • don't generate view specs
  • don't generate route specs for new and edit
  • generate a slightly different controller spec, without redirects but
    with JSON expectations

Addresses #1672

@k3rni
Copy link
Contributor Author

k3rni commented Aug 7, 2016

The CI failures seem to be of two kinds:

  1. https://travis-ci.org/rspec/rspec-rails/jobs/150062031 - weird unrelated failure ?
  2. https://travis-ci.org/rspec/rspec-rails/jobs/150062007 - Rubocop complaints. BTW it seems that Rubocop is only enabled for rubies below 2.2, is that intentional?

How should I proceed? Do you have suggestions on what to extract out of the ScaffoldGenerator class, and how to address the weird errors?

@JonRowe
Copy link
Member

JonRowe commented Aug 8, 2016

I've bumped the broken build, you'll need to fix the rubocop failure though.

BTW it seems that Rubocop is only enabled for rubies below 2.2, is that intentional?

It's a side effect of the version we're running.

@k3rni
Copy link
Contributor Author

k3rni commented Aug 8, 2016

Per the linked issue, the easiest way to satisfy Rubocop here would be to just drop these methods. Is it okay, if that solution were to be accepted, to do that in this PR?

@JonRowe
Copy link
Member

JonRowe commented Aug 8, 2016

If you're sure they're not used, the build should fail if they are...

@fables-tales
Copy link
Member

@k3rni you'll need to update this for #1689 which removes assigns and assert templates from our specs. We definitely don't want those anymore. If you could do that, I can probably merge this down.

@k3rni
Copy link
Contributor Author

k3rni commented Aug 11, 2016

Rebasing to current master and updating.

@k3rni
Copy link
Contributor Author

k3rni commented Aug 11, 2016

I chose to test for response.location returning the newly created object's url in POST#create. This is to match testing redirect_to in regular controllers.

context "with invalid params" do
it "renders a JSON response with errors for the <%= ns_file_name %>" do
<% if RUBY_VERSION < '1.9.3' -%>
<%= file_name %> = <%= class_name %>.create! valid_attributes
Copy link
Member

Choose a reason for hiding this comment

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

@k3rni

you missed moving this file name assignment up to outside of the 1.9.3 conditional, so this does not work on ruby interpreters greater than or equal to 1.9.3, can you add a spec for this case and make it pass? Thanks

@fables-tales
Copy link
Member

@k3rni sorry about the slow review here, it's been a crazy week at work. I've left you a review note, but apart from that, I think this looks great and I'll merge it when you're done 👍 Thank you so much ✨

@k3rni
Copy link
Contributor Author

k3rni commented Aug 22, 2016

@samphippen so basically just move the assignment (line 140 above) up outside the conditional, and verify in tests, got it.

@JonRowe JonRowe merged commit e985c13 into rspec:master Aug 22, 2016
@JonRowe
Copy link
Member

JonRowe commented Aug 22, 2016

Thanks ❤️

JonRowe added a commit that referenced this pull request Aug 22, 2016
sebjacobs pushed a commit to futurelearn/rspec-rails that referenced this pull request Mar 15, 2019
* Update scaffold generator to care about --api flag.
* Fix misplaced assignment in update/invalid params test.
sebjacobs pushed a commit to futurelearn/rspec-rails that referenced this pull request Mar 15, 2019
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.

3 participants