Skip to content

Use keyword args for HTTP methods in controller specs only on Rails 5 #1710

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 3 commits into from
Apr 11, 2017

Conversation

yujinakayama
Copy link
Member

This closes #1669.

@yujinakayama yujinakayama force-pushed the fix-http-method-arg-error-on-older-rails branch from 7bc12a9 to 9fffe39 Compare September 30, 2016 12:04
@JonRowe
Copy link
Member

JonRowe commented Sep 30, 2016

These aren't keyword arguments tho, they're keyword argument on Rails 5, but new style hash access on Rails 4, I'm still unsure why it breaks and this doesn't fix the fact that specs don't pick it up...

@yujinakayama
Copy link
Member Author

Should we replace the skip in the spec with empty hash?

  let(:valid_attributes) {
-   skip("Add a hash of attributes valid for your model")
+   {}
  }

@JonRowe
Copy link
Member

JonRowe commented Sep 30, 2016

I tried that in #1680, (basically we don't want to remove them from peoples scaffolded specs, but we do want them to run in our specs) but it passes and I'm not sure it's working correctly

@yujinakayama
Copy link
Member Author

It seems that the scaffold specs are not executed in cukes since they're always removed before each scenario.

# We want fresh `example_app` project with empty `spec` dir except helpers.
# FileUtils.cp_r on Ruby 1.9.2 doesn't preserve permissions.
system('cp', '-r', example_app_dir, aruba_dir)
helpers = %w[spec/spec_helper.rb spec/rails_helper.rb]
Dir["#{aruba_dir}/spec/*"].each do |path|
next if helpers.any? { |helper| path.end_with?(helper) }
FileUtils.rm_rf(path)
end

@yujinakayama yujinakayama force-pushed the fix-http-method-arg-error-on-older-rails branch from 9fffe39 to f9828b4 Compare November 5, 2016 05:37
yujinakayama added a commit to rspec/rspec-dev that referenced this pull request Nov 5, 2016
This is for running example_app specs in rspec-rails repo:

* rspec/rspec-rails#1710
* rspec/rspec-rails#1680
@mrageh
Copy link

mrageh commented Feb 5, 2017

@yujinakayama and @JonRowe I think we should merge this PR, because in Rails 5 HTTP request methods use keyword args to process requests. Whereas any version below Rails 5 uses does not use keyword args. That means our scaffold generator will produce invalid controller specs.

For more context please refer to this PR.

@JonRowe
Copy link
Member

JonRowe commented Feb 5, 2017

@mrageh as per my earlier comments this shouldn't be merged, Rails 5 swapped option hashes for keyword args, the api is supposed to be compatible without any changes to the user

@JonRowe
Copy link
Member

JonRowe commented Feb 5, 2017

@mrageh However if you'd like to work on getting our generated specs being tested as part of the build I'd welcome the help in a seperate PR.

@yujinakayama
Copy link
Member Author

@JonRowe

the api is supposed to be compatible without any changes to the user

No, get '/', params: {} does not work on Rails 4.2. Try the reproducible example in #1669 (comment).

@mrageh
Copy link

mrageh commented Feb 6, 2017

@JonRowe I may have missed something, but I'm fairly certain the Rails 5 api change is not backwards compatible. Can you send me some docs/github discussion anything that says otherwise?

@yujinakayama yujinakayama force-pushed the fix-http-method-arg-error-on-older-rails branch from f9828b4 to 6ff6c73 Compare April 10, 2017 06:20
Since Rails 5 does not support Ruby 1.8,
we no longer need to check RUBY_VERSION.

This closes #1669.
@yujinakayama yujinakayama force-pushed the fix-http-method-arg-error-on-older-rails branch from 6ff6c73 to bb12f85 Compare April 10, 2017 06:37
@yujinakayama
Copy link
Member Author

yujinakayama commented Apr 10, 2017

This should be rebased once #1680 is merged.

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.

Scaffold generator generates invalid controller specs on versions prior to Rails 5
3 participants