-
-
Notifications
You must be signed in to change notification settings - Fork 197
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
Conversation
features/support/env.rb
Outdated
|
||
module RailsHelpers | ||
def rails_version | ||
Gem::Version.new(Bundler.definition.specs['rails'][0].version) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@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. |
@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. |
No merge? |
@rmm5t Sure. I'll take a look at this some time this week. |
features/support/env.rb
Outdated
|
||
module RailsHelpers | ||
def rails_version | ||
Gem::Version.new(Bundler.definition.specs['rails'][0].version) |
There was a problem hiding this comment.
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.
features/support/env.rb
Outdated
end | ||
|
||
def append_to_gemfile(contents) | ||
append_to('Gemfile', contents) |
There was a problem hiding this comment.
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.
features/support/env.rb
Outdated
|
||
module AppendHelpers | ||
def append_to(path, contents) | ||
cd('.') do |
There was a problem hiding this comment.
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.
features/support/env.rb
Outdated
@@ -1,5 +1,8 @@ | |||
require 'aruba/cucumber' | |||
|
|||
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze | |||
APP_NAME = 'testapp'.freeze |
There was a problem hiding this comment.
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.
features/support/env.rb
Outdated
@@ -1,5 +1,8 @@ | |||
require 'aruba/cucumber' | |||
|
|||
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')).freeze |
There was a problem hiding this comment.
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| |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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}." |
There was a problem hiding this comment.
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}." |
There was a problem hiding this comment.
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]
spec/warnings_spy.rb
Outdated
puts "\n--- ERROR IN AT_EXIT --------------------------------" | ||
puts "#{error.class}: #{error.message}" | ||
puts error.backtrace.join("\n") | ||
puts "-----------------------------------------------------" |
There was a problem hiding this comment.
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.
spec/support/tests/bundle.rb
Outdated
@fs = Filesystem.new | ||
end | ||
|
||
def updating(&block) |
There was a problem hiding this comment.
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)" |
There was a problem hiding this comment.
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)" |
There was a problem hiding this comment.
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.
14d09fa
to
9fc3490
Compare
def create_rails_application | ||
fs.clean | ||
|
||
command = "bundle exec rails new #{fs.project_directory} --skip-bundle --no-rc" |
There was a problem hiding this comment.
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]
9fc3490
to
d31eb64
Compare
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).
d31eb64
to
04e4ad2
Compare
|
||
def expected_output | ||
total = series.inject(:+) | ||
/#{total} (tests|runs), #{total} assertions, 0 failures, 0 errors(, 0 skips)?/ |
There was a problem hiding this comment.
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)?)?/ |
There was a problem hiding this comment.
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]
0eca60d
to
27151cf
Compare
def_delegators :partitioner, :relevant_warning_groups, | ||
:irrelevant_warning_groups | ||
|
||
def report_relevant_warning_groups |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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| |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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.
27151cf
to
d9c504f
Compare
def test_helper_files_for(test_framework, libraries) | ||
files = [] | ||
|
||
if integrates_with_nunit_and_rails?(test_framework, libraries) || integrates_with_nunit_only?(test_framework) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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"]) |
There was a problem hiding this comment.
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"]) |
There was a problem hiding this comment.
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.
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:
Appraisals file and fixing Cucumber specs to match.
who use RSpec won't be using the
shoulda
gem -- they'll be usingshoulda-matchers
instead. There's already a good collection ofintegration specs there, so we don't need the tests here.
Due to the backward-incompatible nature of these changes, my thought is
to release a version 4 of shoulda that includes them.