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

Out with the old, in with the new #261

Merged
merged 3 commits into from
Feb 3, 2017
Merged

Out with the old, in with the new #261

merged 3 commits into from
Feb 3, 2017

Conversation

mcmire
Copy link
Collaborator

@mcmire mcmire commented Jun 10, 2016

This commit is long overdue. The main change is to upgrade shoulda's
hard dependency on shoulda-matchers from 2.x to 3.x. Since this by
itself is a pretty consequential change, though, I also took the
opportunity to make some more at the same time that I think are
reasonable:

  • Remove support for Rails 3, upgrading dependency to 4, modifying
    Appraisals file and fixing Cucumber specs to match.
  • Remove support for RSpec, along with related Cucumber specs. People
    who use RSpec won't be using the shoulda gem -- they'll be using
    shoulda-matchers instead. There's already a good collection of
    integration specs there, so we don't need the tests here.
  • Remove support for Ruby 1.9, along with the entry in .travis.yml.

Due to the backward-incompatible nature of these changes, my thought is
to release a version 4 of shoulda that includes them.


module RailsHelpers
def rails_version
Gem::Version.new(Bundler.definition.specs['rails'][0].version)

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think a type of quote is being used consistently in this project, although single quotes seems to be used more often. I'm going to ignore these warnings.

@mcmire
Copy link
Collaborator Author

mcmire commented Jul 13, 2016

@rmm5t Since you have done a lot of work on this for a while, what do you think about this change? I know you may not have context on this so let me know if you want me to give some.

@rmm5t
Copy link
Collaborator

rmm5t commented Jul 13, 2016

@mcmire Fine by me. I only rely on shoulda-matchers directly anymore. I just have one legacy project that still has a direct shoulda dependency, but upon quick glance, these dependency changes look sane to me.

@samuelpismel
Copy link

No merge?

@romdim
Copy link

romdim commented Jan 17, 2017

@rmm5t / @mcmire Could you please merge? Thanks!

@rmm5t
Copy link
Collaborator

rmm5t commented Jan 17, 2017

@romdim It's been a while since this branch's build ran green. I'm happy to merge, but I don't have the time this week to debug in the event that new versions of dependencies turn the build red. @mcmire Do you have time to merge and release a new gem version?

@mcmire
Copy link
Collaborator Author

mcmire commented Jan 18, 2017

@rmm5t Sure. I'll take a look at this some time this week.

@mcmire mcmire self-assigned this Jan 18, 2017

module RailsHelpers
def rails_version
Gem::Version.new(Bundler.definition.specs['rails'][0].version)

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

end

def append_to_gemfile(contents)
append_to('Gemfile', contents)

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.


module AppendHelpers
def append_to(path, contents)
cd('.') do

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -1,5 +1,8 @@
require 'aruba/cucumber'

PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze
APP_NAME = 'testapp'.freeze

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@@ -1,5 +1,8 @@
require 'aruba/cucumber'

PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
Line is too long. [85/80]


def append_to_gemfile(contents)
append_to('Gemfile', contents)
Then /^the output should indicate that (\d+) tests were run successfully$/ do |number|

Choose a reason for hiding this comment

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

Line is too long. [86/80]

end

When /^I configure a wildcard route$/ do
When 'I configure a wildcard route' do

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

When /^I configure the application to use shoulda-matchers$/ do
append_to_gemfile "gem 'shoulda-matchers', '~> 1.0'"
steps %{And I run `bundle install --local`}
append_to 'test/test_helper.rb', <<-TEXT

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.


When /^I configure the application to use rspec\-rails$/ do
append_to_gemfile "gem 'rspec-rails'"
When 'I configure the application to use Shoulda' do

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

APP_NAME = 'testapp'.freeze

When /^I generate a new rails application$/ do
When 'I generate a new Rails application' do

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

irrelevant_warnings_file.puts(line)
end
end
puts "Non #{project_name} warnings were raised during the test run. These have been written to #{irrelevant_warnings_file.path}."

Choose a reason for hiding this comment

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

Line is too long. [137/80]

end
end
print_divider('-', 75)
puts "#{project_name} warnings written to #{relevant_warnings_file.path}."

Choose a reason for hiding this comment

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

Line is too long. [82/80]

puts "\n--- ERROR IN AT_EXIT --------------------------------"
puts "#{error.class}: #{error.message}"
puts error.backtrace.join("\n")
puts "-----------------------------------------------------"

Choose a reason for hiding this comment

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

Prefer single-quoted strings when you don't need string interpolation or special symbols.

@fs = Filesystem.new
end

def updating(&block)

Choose a reason for hiding this comment

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

Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used. You can also write as updating(*) if you want the method to accept any arguments but don't care about them.


def formatted_actual_output
if actual_output.empty?
"Actual output: (empty)"

Choose a reason for hiding this comment

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

Prefer single-quoted strings when you don't need string interpolation or special symbols.

if matching_expected_output
"Expected output:\n#{matching_actual_output}"
else
"Expected output: (n/a)"

Choose a reason for hiding this comment

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

Prefer single-quoted strings when you don't need string interpolation or special symbols.

def create_rails_application
fs.clean

command = "bundle exec rails new #{fs.project_directory} --skip-bundle --no-rc"

Choose a reason for hiding this comment

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

Line is too long. [85/80]

This commit is long overdue. The main change is to upgrade shoulda's
hard dependency on shoulda-matchers from 2.x to 3.x. Since this by
itself is a pretty consequential change, though, I also took the
opportunity to make some more at the same time that I think are
reasonable:

* Remove support for Rails 3, Rails 4.0, and Rails 4.1, since they have
  been end-of-lifed; support Rails 4.2-5.0 instead.
* Remove support for Ruby 1.9 and 2.0; support Ruby 2.1-2.4 instead.
* Remove support for RSpec, along with related Cucumber specs. People
  who use RSpec won't be using the `shoulda` gem -- they'll be using
  `shoulda-matchers` instead. There's already a good collection of
  integration specs there, so we don't need the tests here.

Please note that we are using the Rails Git repo to refer to 4.2 because
the latest release of 4.2 isn't compatible with Ruby 2.4 just yet (but
it's fixed on the 4-2-stable branch).

def expected_output
total = series.inject(:+)
/#{total} (tests|runs), #{total} assertions, 0 failures, 0 errors(, 0 skips)?/

Choose a reason for hiding this comment

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

Line is too long. [86/80]

private

def expected_output
/#{number} (?:tests?|runs?|examples?)(?:, #{number} assertions)?, 0 failures(?:, 0 errors(?:, 0 skips)?)?/

Choose a reason for hiding this comment

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

Line is too long. [114/80]

def_delegators :partitioner, :relevant_warning_groups,
:irrelevant_warning_groups

def report_relevant_warning_groups

Choose a reason for hiding this comment

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

Assignment Branch Condition size for report_relevant_warning_groups is too high. [15.03/15]

attr_accessor :command_prefix, :run_quickly, :run_successfully, :retries,
:timeout

def initialize(*args)

Choose a reason for hiding this comment

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

Assignment Branch Condition size for initialize is too high. [18.06/15]

message = "Expected output to indicate that #{some_tests_were_run}.\n" +
"Expected output: #{expected_output}\n"

if actual_output.empty?

Choose a reason for hiding this comment

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

Use the return of the conditional for variable assignment and comparison.

files = []

if integrates_with_nunit_and_rails?(test_framework, libraries) ||
integrates_with_nunit_only?(test_framework)

Choose a reason for hiding this comment

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

Use 4 (not 2) spaces for indenting a condition in an if statement spanning multiple lines.

options[:test_frameworks].each do |test_framework|
libraries = options.fetch(:libraries, [])

test_helper_files_for(test_framework, libraries).each do |test_helper_file|

Choose a reason for hiding this comment

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

Line is too long. [83/80]

add_configuration_block_to(
test_helper_file,
test_framework,
library

Choose a reason for hiding this comment

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

Put a comma after the last parameter of a multiline method call.

@@ -0,0 +1,7 @@
require File.expand_path('../warnings_spy', __FILE__)

# Adapted from <http://myronmars.to/n/dev-blog/2011/08/making-your-gem-warning-free>

Choose a reason for hiding this comment

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

Line is too long. [84/80]


expect(result).to indicate_that_tests_were_run(unit: 1, functional: 1)
expect(result).to have_output(
'User should validate that :name cannot be empty/falsy'

Choose a reason for hiding this comment

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

Put a comma after the last parameter of a multiline method call.

add_gems_for_n_unit
add_shoulda_to_project(
test_frameworks: [:minitest],
libraries: [:rails]

Choose a reason for hiding this comment

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

Put a comma after the last parameter of a multiline method call.

Copy over the acceptance test framework that we are using for
shoulda-matchers. This is superior because as a part of running the
acceptance, we execute commands and we have it so that if one of those
commands fails, the output from that command is printed to the console
so that we can better debug the issue. This is something that Cucumber
(via Aruba) does not do.
def test_helper_files_for(test_framework, libraries)
files = []

if integrates_with_nunit_and_rails?(test_framework, libraries) || integrates_with_nunit_only?(test_framework)

Choose a reason for hiding this comment

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

Line is too long. [115/80]

def test_helper_files_for(test_framework, libraries)
files = []

if integrates_with_nunit_and_rails?(test_framework, libraries) || integrates_with_nunit_only?(test_framework)

Choose a reason for hiding this comment

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

Line is too long. [115/80]

end
FILE

run_rake_tasks!(["db:drop", "db:create", "db:migrate"])

Choose a reason for hiding this comment

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

Prefer single-quoted strings when you don't need string interpolation or special symbols.

end
FILE

run_rake_tasks!(["db:drop", "db:create", "db:migrate"])

Choose a reason for hiding this comment

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

Prefer single-quoted strings when you don't need string interpolation or special symbols.

@mcmire mcmire merged commit d9c504f into master Feb 3, 2017
@mcmire mcmire deleted the ew-out-with-the-old branch February 3, 2017 06:58
@sman591 sman591 mentioned this pull request Jul 1, 2018
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.

5 participants