Skip to content

Rails 5.1 compatibility #1790

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 9 commits into from
Apr 9, 2017
Merged

Rails 5.1 compatibility #1790

merged 9 commits into from
Apr 9, 2017

Conversation

fables-tales
Copy link
Member

No description provided.

Sam Phippen added 2 commits February 24, 2017 11:31
Rails 5.1 removes `rails:template` in favour of `app:template` to
generate templates. This change sets our rakefile up to usee the
`app:template` command if the rails version is greater than or equal to
5.1
@fables-tales
Copy link
Member Author

@yui-knk btw, here's the current failure output when I run RAILS_VERSION=5.1.0.beta1 ./script/run_build in my clone of RSpec Rails: https://gist.github.com/samphippen/bcc02764dca82bb8f416a798f9561d8e

@myronmarston
Copy link
Member

@samphippen any reason not to update this to 5.1.0.rc1? That's going to be closer to the 5.1 final release, and it's possible the build failures are related to a regression in beta1 that's fixed in rc1.

@fables-tales
Copy link
Member Author

fables-tales commented Mar 23, 2017 via email

yui-knk added 2 commits March 24, 2017 10:33
From Rails 5.1, a form view which is generated by scaffold command
uses `form_with`.
`form_with` does not append id attribute for form tags or input tags.
So our templates should not use id selectors.

rails/rails@d3b798b
@yui-knk
Copy link
Contributor

yui-knk commented Mar 24, 2017

I create #1797. Can you merge this to run CI?

Sam Phippen added 4 commits March 24, 2017 11:59
Bump up Rails version to 5.1.0.rc1
`render :text` has been deprecated for a while now, and is removed in
rails 5.1. It has been replaced by either `render :plain` or `render
:html` (depending on which `Content-Encoding` header you want). This
patch uses our existing cucumber tags `@rails_pre_5` and `@rails_post_5`
to switch which we use depending on the Rails verison. We can't simply
replace all the references here because Rails 3 does not have this
option.
@fables-tales fables-tales changed the title WIP: Rails 5.1 compatibility Rails 5.1 compatibility Mar 25, 2017
@fables-tales
Copy link
Member Author

@rspec/rspec this is now ready for review. I've tested it locally against 5.1 and 5.0 and everything still works. Travis is cooking the other versions, but I don't expect much variance there.

When I run `rspec spec/requests/widget_management_spec.rb`
Then the example should pass


Copy link
Member

Choose a reason for hiding this comment

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

Extra ws here

@@ -136,7 +162,6 @@ Feature: `have_http_status` matcher
visit "/widgets/new"
expect(page).to have_http_status(200)

fill_in "Name", :with => "My Widget"
Copy link
Member

Choose a reason for hiding this comment

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

unrelated?

Copy link
Member Author

Choose a reason for hiding this comment

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

has no effect and breaks in Rails 5.1 for really weird reasons.

Copy link
Member

@JonRowe JonRowe Apr 3, 2017

Choose a reason for hiding this comment

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

Is that indicative that we have an issue here?

Copy link
Member Author

Choose a reason for hiding this comment

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

There's no issue here. In rails 5.1 they've changed the form generation logic so this finder fails. However, this fill_in has nothing to do with the test. I think we should remove it

  1. for compatibility
  2. because it doesn't aid in being documenting of this feature

@@ -16,8 +16,12 @@
assert_select "form[action=?][method=?]", <%= ns_file_name %>_path(@<%= ns_file_name %>), "post" do
<% for attribute in output_attributes -%>
<%- name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name %>
<% if Rails.version.to_f >= 5.1 -%>
Copy link
Member

Choose a reason for hiding this comment

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

Worth indenting to match above? Makes it slightly clearer too.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem here is that indentation here affects the output. We want the output to look 'normal' do we don't indent here.

Copy link
Member

Choose a reason for hiding this comment

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

You could indent inside the tag if thats your concern?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you show how you'd like this to look, I'm not sure I fully follow?

@@ -15,8 +15,12 @@
assert_select "form[action=?][method=?]", <%= index_helper %>_path, "post" do
<% for attribute in output_attributes -%>
<%- name = attribute.respond_to?(:column_name) ? attribute.column_name : attribute.name %>
<% if Rails.version.to_f >= 5.1 -%>
Copy link
Member

Choose a reason for hiding this comment

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

As above

Copy link
Member Author

Choose a reason for hiding this comment

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

same

@JonRowe
Copy link
Member

JonRowe commented Mar 26, 2017

Seems sane to me but I've not run it, if you're happy with it I'm happy with it. I've left a few non blocking comments on style.

Rakefile Outdated
@@ -11,6 +11,15 @@ require 'rspec'
require 'rspec/core/rake_task'
require 'cucumber/rake/task'

def rails_template_command
require "rails"
if Rails.version.to_f >= 5.1
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if Rails.version.to_f >= 5.0 is better, because "rails:template" was deprecated on Rails 5.0.

Copy link
Member Author

Choose a reason for hiding this comment

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

if it passes on CI it's good with me :)

@fables-tales
Copy link
Member Author

@JonRowe I've just pushed some review tweaks and answered a few of your review pieces. WDYT?

@fables-tales
Copy link
Member Author

@JonRowe I'm gonna go ahead and merge this. If you feel particularly strongly on the indentation or the deleted line, I think we can open a fresh PR.

@fables-tales fables-tales merged commit 23c891e into master Apr 9, 2017
@fables-tales fables-tales deleted the rails-5.1-compat branch April 9, 2017 23:47
fables-tales pushed a commit that referenced this pull request Apr 9, 2017
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.

4 participants