fix(rubocop): Satisfy Style/StringLiterals with single_quotes [ci skip]

This commit is contained in:
Kapil Sachdev 2020-09-04 20:08:31 +05:30 committed by Elliot Winkler
parent fddf43c057
commit 97722f67cb
34 changed files with 330 additions and 330 deletions

View File

@ -8,14 +8,14 @@ require_relative 'spec/support/tests/current_bundle'
RSpec::Core::RakeTask.new('spec:unit') do |t|
t.ruby_opts = '-w -r ./spec/report_warnings'
t.pattern = "spec/unit/**/*_spec.rb"
t.pattern = 'spec/unit/**/*_spec.rb'
t.rspec_opts = '--color --format progress'
t.verbose = false
end
RSpec::Core::RakeTask.new('spec:acceptance') do |t|
t.ruby_opts = '-w -r ./spec/report_warnings'
t.pattern = "spec/acceptance/**/*_spec.rb"
t.pattern = 'spec/acceptance/**/*_spec.rb'
t.rspec_opts = '--color --format progress'
t.verbose = false
end
@ -26,7 +26,7 @@ task :default do
sh 'rake spec:acceptance --trace'
else
if ENV['CI']
exec "appraisal install && appraisal rake --trace"
exec 'appraisal install && appraisal rake --trace'
else
appraisal = Tests::CurrentBundle.instance.latest_appraisal
exec "appraisal install && appraisal #{appraisal} rake --trace"

View File

@ -8,7 +8,7 @@ def javascripts
end
def class_list(root = Registry.root, tree = TreeContext.new)
out = String.new("")
out = String.new('')
children = run_verifier(root.children)
if root == Registry.root
children += @items.select {|o| o.namespace.is_a?(CodeObjects::Proxy) }
@ -24,12 +24,12 @@ def class_list(root = Registry.root, tree = TreeContext.new)
out << " &lt; #{child.superclass.name}" if child.is_a?(CodeObjects::ClassObject) && child.superclass
out << "<small class='search_info'>"
out << child.namespace.title
out << "</small>"
out << "</div>"
out << '</small>'
out << '</div>'
tree.nest do
out << "<ul>#{class_list(child, tree)}</ul>" if has_children
end
out << "</li>"
out << '</li>'
end
out
end

View File

@ -17,7 +17,7 @@ def diskfile
end
data = htmlify(contents, @file.attributes[:markup])
"<div id='filecontents'>" + data + "</div>"
"<div id='filecontents'>" + data + '</div>'
end
def preprocess_index(contents)

View File

@ -1,36 +1,36 @@
# This file was generated by Appraisal
source "https://rubygems.org"
source 'https://rubygems.org'
gem "activeresource", "4.0.0"
gem "appraisal", "2.2.0"
gem "bcrypt", "~> 3.1.7"
gem "bundler", "~> 1.1"
gem "coffee-rails", "~> 4.1.0"
gem "fssm"
gem "jbuilder", "~> 2.0"
gem "jquery-rails"
gem "json", "~> 1.4"
gem "pg", "~> 0.18"
gem "protected_attributes", "~> 1.0.6"
gem "pry"
gem "pry-byebug"
gem "rails", "4.2.11.1"
gem "rake", "13.0.1"
gem "redcarpet"
gem "rouge"
gem "rspec", "~> 3.9"
gem "rspec-rails", "~> 3.9"
gem "rubocop", require: false
gem "rubocop-rails", require: false
gem "sass-rails", "~> 5.0"
gem "sdoc", "~> 0.4.0", group: :doc
gem "shoulda-context", "~> 1.2.0"
gem "spring"
gem "spring-commands-rspec"
gem "sqlite3", "~> 1.3.6"
gem "turbolinks"
gem "uglifier", ">= 1.3.0"
gem "warnings_logger"
gem "yard"
gem "zeus", require: false
gem 'activeresource', '4.0.0'
gem 'appraisal', '2.2.0'
gem 'bcrypt', '~> 3.1.7'
gem 'bundler', '~> 1.1'
gem 'coffee-rails', '~> 4.1.0'
gem 'fssm'
gem 'jbuilder', '~> 2.0'
gem 'jquery-rails'
gem 'json', '~> 1.4'
gem 'pg', '~> 0.18'
gem 'protected_attributes', '~> 1.0.6'
gem 'pry'
gem 'pry-byebug'
gem 'rails', '4.2.11.1'
gem 'rake', '13.0.1'
gem 'redcarpet'
gem 'rouge'
gem 'rspec', '~> 3.9'
gem 'rspec-rails', '~> 3.9'
gem 'rubocop', require: false
gem 'rubocop-rails', require: false
gem 'sass-rails', '~> 5.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'shoulda-context', '~> 1.2.0'
gem 'spring'
gem 'spring-commands-rspec'
gem 'sqlite3', '~> 1.3.6'
gem 'turbolinks'
gem 'uglifier', '>= 1.3.0'
gem 'warnings_logger'
gem 'yard'
gem 'zeus', require: false

View File

@ -1,34 +1,34 @@
# This file was generated by Appraisal
source "https://rubygems.org"
source 'https://rubygems.org'
gem "appraisal", "2.2.0"
gem "bcrypt", "~> 3.1.7"
gem "bundler", "~> 1.1"
gem "fssm"
gem "jbuilder", "~> 2.5"
gem "jquery-rails"
gem "listen", "~> 3.0.5"
gem "pg", "~> 0.18"
gem "pry"
gem "pry-byebug"
gem "puma", "~> 3.0"
gem "rails", "5.0.7.2"
gem "rails-controller-testing", ">= 1.0.1"
gem "rake", "13.0.1"
gem "redcarpet"
gem "rouge"
gem "rspec", "~> 3.9"
gem "rspec-rails", "~> 3.9"
gem "rubocop", require: false
gem "rubocop-rails", require: false
gem "sass-rails", "~> 5.0"
gem "shoulda-context", "~> 1.2.0"
gem "spring"
gem "spring-commands-rspec"
gem "spring-watcher-listen", "~> 2.0.0"
gem "sqlite3", "~> 1.3.6"
gem "turbolinks", "~> 5"
gem "warnings_logger"
gem "yard"
gem "zeus", require: false
gem 'appraisal', '2.2.0'
gem 'bcrypt', '~> 3.1.7'
gem 'bundler', '~> 1.1'
gem 'fssm'
gem 'jbuilder', '~> 2.5'
gem 'jquery-rails'
gem 'listen', '~> 3.0.5'
gem 'pg', '~> 0.18'
gem 'pry'
gem 'pry-byebug'
gem 'puma', '~> 3.0'
gem 'rails', '5.0.7.2'
gem 'rails-controller-testing', '>= 1.0.1'
gem 'rake', '13.0.1'
gem 'redcarpet'
gem 'rouge'
gem 'rspec', '~> 3.9'
gem 'rspec-rails', '~> 3.9'
gem 'rubocop', require: false
gem 'rubocop-rails', require: false
gem 'sass-rails', '~> 5.0'
gem 'shoulda-context', '~> 1.2.0'
gem 'spring'
gem 'spring-commands-rspec'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'sqlite3', '~> 1.3.6'
gem 'turbolinks', '~> 5'
gem 'warnings_logger'
gem 'yard'
gem 'zeus', require: false

View File

@ -1,35 +1,35 @@
# This file was generated by Appraisal
source "https://rubygems.org"
source 'https://rubygems.org'
gem "appraisal", "2.2.0"
gem "bcrypt", "~> 3.1.7"
gem "bundler", "~> 1.1"
gem "capybara", "~> 2.13"
gem "fssm"
gem "jbuilder", "~> 2.5"
gem "listen", ">= 3.0.5", "< 3.2"
gem "pg", "~> 0.18"
gem "pry"
gem "pry-byebug"
gem "puma", "~> 3.7"
gem "rails", "5.1.7"
gem "rails-controller-testing", ">= 1.0.1"
gem "rake", "13.0.1"
gem "redcarpet"
gem "rouge"
gem "rspec", "~> 3.9"
gem "rspec-rails", "~> 3.9"
gem "rubocop", require: false
gem "rubocop-rails", require: false
gem "sass-rails", "~> 5.0"
gem "selenium-webdriver"
gem "shoulda-context", "~> 1.2.0"
gem "spring"
gem "spring-commands-rspec"
gem "spring-watcher-listen", "~> 2.0.0"
gem "sqlite3", "~> 1.3.6"
gem "turbolinks", "~> 5"
gem "warnings_logger"
gem "yard"
gem "zeus", require: false
gem 'appraisal', '2.2.0'
gem 'bcrypt', '~> 3.1.7'
gem 'bundler', '~> 1.1'
gem 'capybara', '~> 2.13'
gem 'fssm'
gem 'jbuilder', '~> 2.5'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'pg', '~> 0.18'
gem 'pry'
gem 'pry-byebug'
gem 'puma', '~> 3.7'
gem 'rails', '5.1.7'
gem 'rails-controller-testing', '>= 1.0.1'
gem 'rake', '13.0.1'
gem 'redcarpet'
gem 'rouge'
gem 'rspec', '~> 3.9'
gem 'rspec-rails', '~> 3.9'
gem 'rubocop', require: false
gem 'rubocop-rails', require: false
gem 'sass-rails', '~> 5.0'
gem 'selenium-webdriver'
gem 'shoulda-context', '~> 1.2.0'
gem 'spring'
gem 'spring-commands-rspec'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'sqlite3', '~> 1.3.6'
gem 'turbolinks', '~> 5'
gem 'warnings_logger'
gem 'yard'
gem 'zeus', require: false

View File

@ -1,37 +1,37 @@
# This file was generated by Appraisal
source "https://rubygems.org"
source 'https://rubygems.org'
gem "appraisal", "2.2.0"
gem "bcrypt", "~> 3.1.7"
gem "bootsnap", ">= 1.1.0", require: false
gem "bundler", "~> 1.1"
gem "capybara", "~> 3.1.1"
gem "chromedriver-helper"
gem "fssm"
gem "jbuilder", "~> 2.5"
gem "listen", ">= 3.0.5", "< 3.2"
gem "pg", "~> 0.18"
gem "pry"
gem "pry-byebug"
gem "puma", "~> 3.11"
gem "rails", "5.2.4.1"
gem "rails-controller-testing", ">= 1.0.1"
gem "rake", "13.0.1"
gem "redcarpet"
gem "rouge"
gem "rspec", "~> 3.9"
gem "rspec-rails", "~> 3.9"
gem "rubocop", require: false
gem "rubocop-rails", require: false
gem "sass-rails", "~> 5.0"
gem "selenium-webdriver"
gem "shoulda-context", "~> 1.2.0"
gem "spring"
gem "spring-commands-rspec"
gem "spring-watcher-listen", "~> 2.0.0"
gem "sqlite3", "~> 1.3.6"
gem "turbolinks", "~> 5"
gem "warnings_logger"
gem "yard"
gem "zeus", require: false
gem 'appraisal', '2.2.0'
gem 'bcrypt', '~> 3.1.7'
gem 'bootsnap', '>= 1.1.0', require: false
gem 'bundler', '~> 1.1'
gem 'capybara', '~> 3.1.1'
gem 'chromedriver-helper'
gem 'fssm'
gem 'jbuilder', '~> 2.5'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'pg', '~> 0.18'
gem 'pry'
gem 'pry-byebug'
gem 'puma', '~> 3.11'
gem 'rails', '5.2.4.1'
gem 'rails-controller-testing', '>= 1.0.1'
gem 'rake', '13.0.1'
gem 'redcarpet'
gem 'rouge'
gem 'rspec', '~> 3.9'
gem 'rspec-rails', '~> 3.9'
gem 'rubocop', require: false
gem 'rubocop-rails', require: false
gem 'sass-rails', '~> 5.0'
gem 'selenium-webdriver'
gem 'shoulda-context', '~> 1.2.0'
gem 'spring'
gem 'spring-commands-rspec'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'sqlite3', '~> 1.3.6'
gem 'turbolinks', '~> 5'
gem 'warnings_logger'
gem 'yard'
gem 'zeus', require: false

View File

@ -1,38 +1,38 @@
# This file was generated by Appraisal
source "https://rubygems.org"
source 'https://rubygems.org'
gem "actiontext", "~> 6.0.2.1"
gem "appraisal", "2.2.0"
gem "bcrypt", "~> 3.1.7"
gem "bootsnap", ">= 1.4.2", require: false
gem "bundler", "~> 1.1"
gem "capybara", ">= 2.15"
gem "fssm"
gem "jbuilder", "~> 2.7"
gem "listen", ">= 3.0.5", "< 3.2"
gem "pg", ">= 0.18", "< 2.0"
gem "pry"
gem "pry-byebug"
gem "puma", "~> 4.1"
gem "rails", "6.0.2.1"
gem "rails-controller-testing", ">= 1.0.1"
gem "rake", "13.0.1"
gem "redcarpet"
gem "rouge"
gem "rspec", "~> 3.9"
gem "rspec-rails", "~> 3.9"
gem "rubocop", require: false
gem "rubocop-rails", require: false
gem "sass-rails", ">= 6"
gem "selenium-webdriver"
gem "shoulda-context", "~> 1.2.0"
gem "spring"
gem "spring-commands-rspec"
gem "spring-watcher-listen", "~> 2.0.0"
gem "sqlite3", "~> 1.4"
gem "turbolinks", "~> 5"
gem "warnings_logger"
gem "webdrivers"
gem "yard"
gem "zeus", require: false
gem 'actiontext', '~> 6.0.2.1'
gem 'appraisal', '2.2.0'
gem 'bcrypt', '~> 3.1.7'
gem 'bootsnap', '>= 1.4.2', require: false
gem 'bundler', '~> 1.1'
gem 'capybara', '>= 2.15'
gem 'fssm'
gem 'jbuilder', '~> 2.7'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'pg', '>= 0.18', '< 2.0'
gem 'pry'
gem 'pry-byebug'
gem 'puma', '~> 4.1'
gem 'rails', '6.0.2.1'
gem 'rails-controller-testing', '>= 1.0.1'
gem 'rake', '13.0.1'
gem 'redcarpet'
gem 'rouge'
gem 'rspec', '~> 3.9'
gem 'rspec-rails', '~> 3.9'
gem 'rubocop', require: false
gem 'rubocop-rails', require: false
gem 'sass-rails', '>= 6'
gem 'selenium-webdriver'
gem 'shoulda-context', '~> 1.2.0'
gem 'spring'
gem 'spring-commands-rspec'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'sqlite3', '~> 1.4'
gem 'turbolinks', '~> 5'
gem 'warnings_logger'
gem 'webdrivers'
gem 'yard'
gem 'zeus', require: false

View File

@ -603,8 +603,8 @@ pass, or do something else entirely.
def inspected_values_to_set
Shoulda::Matchers::Util.inspect_values(values_to_set).to_sentence(
two_words_connector: " or ",
last_word_connector: ", or "
two_words_connector: ' or ',
last_word_connector: ', or '
)
end

View File

@ -36,9 +36,9 @@ module Shoulda
description << Shoulda::Matchers::Util.inspect_value(value_written)
if attribute_changed_value?
description << " -- which was read back as "
description << ' -- which was read back as '
description << Shoulda::Matchers::Util.inspect_value(value_read)
description << " --"
description << ' --'
end
description

View File

@ -144,11 +144,11 @@ module Shoulda
def comparison_expectation
case @operator
when :> then "greater than"
when :>= then "greater than or equal to"
when :== then "equal to"
when :< then "less than"
when :<= then "less than or equal to"
when :> then 'greater than'
when :>= then 'greater than or equal to'
when :== then 'equal to'
when :< then 'less than'
when :<= then 'less than or equal to'
when :!= then 'other than'
end
end

View File

@ -238,8 +238,8 @@ module Shoulda
def inspected_array
Shoulda::Matchers::Util.inspect_values(@array).to_sentence(
two_words_connector: " nor ",
last_word_connector: ", nor "
two_words_connector: ' nor ',
last_word_connector: ', nor '
)
end
end

View File

@ -609,8 +609,8 @@ EOT
def inspected_array
Shoulda::Matchers::Util.inspect_values(@array).to_sentence(
two_words_connector: " or ",
last_word_connector: ", or "
two_words_connector: ' or ',
last_word_connector: ', or '
)
end
end

View File

@ -1,29 +1,29 @@
require "shoulda/matchers/active_record/association_matcher"
require "shoulda/matchers/active_record/association_matchers"
require "shoulda/matchers/active_record/association_matchers/counter_cache_matcher"
require "shoulda/matchers/active_record/association_matchers/inverse_of_matcher"
require "shoulda/matchers/active_record/association_matchers/join_table_matcher"
require "shoulda/matchers/active_record/association_matchers/order_matcher"
require "shoulda/matchers/active_record/association_matchers/through_matcher"
require "shoulda/matchers/active_record/association_matchers/dependent_matcher"
require "shoulda/matchers/active_record/association_matchers/required_matcher"
require "shoulda/matchers/active_record/association_matchers/optional_matcher"
require "shoulda/matchers/active_record/association_matchers/source_matcher"
require "shoulda/matchers/active_record/association_matchers/model_reflector"
require "shoulda/matchers/active_record/association_matchers/model_reflection"
require "shoulda/matchers/active_record/association_matchers/option_verifier"
require "shoulda/matchers/active_record/have_db_column_matcher"
require "shoulda/matchers/active_record/have_db_index_matcher"
require "shoulda/matchers/active_record/have_implicit_order_column"
require "shoulda/matchers/active_record/have_readonly_attribute_matcher"
require "shoulda/matchers/active_record/have_rich_text_matcher"
require "shoulda/matchers/active_record/have_secure_token_matcher"
require "shoulda/matchers/active_record/serialize_matcher"
require "shoulda/matchers/active_record/accept_nested_attributes_for_matcher"
require "shoulda/matchers/active_record/define_enum_for_matcher"
require "shoulda/matchers/active_record/uniqueness"
require "shoulda/matchers/active_record/validate_uniqueness_of_matcher"
require "shoulda/matchers/active_record/have_attached_matcher"
require 'shoulda/matchers/active_record/association_matcher'
require 'shoulda/matchers/active_record/association_matchers'
require 'shoulda/matchers/active_record/association_matchers/counter_cache_matcher'
require 'shoulda/matchers/active_record/association_matchers/inverse_of_matcher'
require 'shoulda/matchers/active_record/association_matchers/join_table_matcher'
require 'shoulda/matchers/active_record/association_matchers/order_matcher'
require 'shoulda/matchers/active_record/association_matchers/through_matcher'
require 'shoulda/matchers/active_record/association_matchers/dependent_matcher'
require 'shoulda/matchers/active_record/association_matchers/required_matcher'
require 'shoulda/matchers/active_record/association_matchers/optional_matcher'
require 'shoulda/matchers/active_record/association_matchers/source_matcher'
require 'shoulda/matchers/active_record/association_matchers/model_reflector'
require 'shoulda/matchers/active_record/association_matchers/model_reflection'
require 'shoulda/matchers/active_record/association_matchers/option_verifier'
require 'shoulda/matchers/active_record/have_db_column_matcher'
require 'shoulda/matchers/active_record/have_db_index_matcher'
require 'shoulda/matchers/active_record/have_implicit_order_column'
require 'shoulda/matchers/active_record/have_readonly_attribute_matcher'
require 'shoulda/matchers/active_record/have_rich_text_matcher'
require 'shoulda/matchers/active_record/have_secure_token_matcher'
require 'shoulda/matchers/active_record/serialize_matcher'
require 'shoulda/matchers/active_record/accept_nested_attributes_for_matcher'
require 'shoulda/matchers/active_record/define_enum_for_matcher'
require 'shoulda/matchers/active_record/uniqueness'
require 'shoulda/matchers/active_record/validate_uniqueness_of_matcher'
require 'shoulda/matchers/active_record/have_attached_matcher'
module Shoulda
module Matchers

View File

@ -81,7 +81,7 @@ module Shoulda
if model.implicit_order_column.to_s != column_name.to_s
message =
if model.implicit_order_column.nil?
"implicit_order_column is not set"
'implicit_order_column is not set'
else
"it is :#{model.implicit_order_column}"
end

View File

@ -626,9 +626,9 @@ module Shoulda
reason << inspected_scopes.to_sentence
if inspected_scopes.many?
reason << " do not seem to be attributes"
reason << ' do not seem to be attributes'
else
reason << " does not seem to be an attribute"
reason << ' does not seem to be an attribute'
end
reason << " on #{model.name}."
@ -650,9 +650,9 @@ module Shoulda
reason << inspected_scopes.to_sentence
if inspected_scopes.many?
reason << " seem to be attributes"
reason << ' seem to be attributes'
else
reason << " seems to be an attribute"
reason << ' seems to be an attribute'
end
reason << " on #{model.name}."
@ -951,7 +951,7 @@ module Shoulda
prefix << "#{existing_value_read.inspect}"
end
prefix << ", and saving it as the existing record, then"
prefix << ', and saving it as the existing record, then'
else
if attribute_setter_for_existing_record
prefix << "Given an existing #{model.name},"

View File

@ -18,7 +18,7 @@ module Shoulda
end
def message
""
''
end
def inspect

View File

@ -219,9 +219,9 @@ module Shoulda
end
if expects_to_allow_nil_delegate_object?
string << ", allowing "
string << ', allowing '
string << formatted_delegate_object_reader_method_name
string << " to return nil"
string << ' to return nil'
end
string
@ -344,7 +344,7 @@ module Shoulda
if options[:include_module]
class_under_test.to_s
else
""
''
end
end
@ -439,7 +439,7 @@ module Shoulda
end
def formatted_calls_on_delegate_object
string = ""
string = ''
if calls_on_delegate_object.any?
string << "\n\n"
@ -449,7 +449,7 @@ module Shoulda
string << "#{i+1}) #{name}(#{args})\n"
end
else
string << " (none)"
string << ' (none)'
end
string.rstrip!

View File

@ -5,8 +5,8 @@ module Shoulda
# @private
def self.warn(message)
header = "Warning from shoulda-matchers:"
divider = "*" * TERMINAL_MAX_WIDTH
header = 'Warning from shoulda-matchers:'
divider = '*' * TERMINAL_MAX_WIDTH
wrapped_message = word_wrap(message)
full_message = [
divider,

View File

@ -75,7 +75,7 @@ module AcceptanceTests
if matching_expected_output
"Expected output:\n#{matching_actual_output}"
else
"Expected output: (n/a)"
'Expected output: (n/a)'
end
end
@ -85,7 +85,7 @@ module AcceptanceTests
def formatted_actual_output
if actual_output.empty?
"Actual output: (empty)"
'Actual output: (empty)'
else
"Actual output:\n#{actual_output}"
end

View File

@ -40,7 +40,7 @@ EOT
def current_appraisal
if appraisal_in_use?
File.basename(path, ".gemfile")
File.basename(path, '.gemfile')
end
end

View File

@ -10,7 +10,7 @@ module UnitTests
stripped_message = message.strip_heredoc.strip
if one_line
stripped_message.tr("\n", " ").squeeze(" ")
stripped_message.tr("\n", ' ').squeeze(' ')
else
word_wrap(stripped_message)
end

View File

@ -50,7 +50,7 @@ module UnitTests
def actual_warning
if captured_stderr.empty?
"nothing"
'nothing'
else
"\n #{captured_stderr}"
end

View File

@ -1,25 +1,25 @@
require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RouteParams, type: :controller do
describe "#normalize" do
context "when the route parameters is a hash" do
it "stringifies the values in the hash" do
describe '#normalize' do
context 'when the route parameters is a hash' do
it 'stringifies the values in the hash' do
expect(build_route_params(controller: :examples, action: 'example', id: '1').normalize).
to eq({ controller: "examples", action: "example", id: "1" })
to eq({ controller: 'examples', action: 'example', id: '1' })
end
end
context "when the route parameters is a string and a hash" do
it "produces a hash of route parameters" do
expect(build_route_params("examples#example", id: '1').normalize).
to eq({ controller: "examples", action: "example", id: "1" })
context 'when the route parameters is a string and a hash' do
it 'produces a hash of route parameters' do
expect(build_route_params('examples#example', id: '1').normalize).
to eq({ controller: 'examples', action: 'example', id: '1' })
end
end
context "when the route params is a string" do
it "produces a hash of route params" do
expect(build_route_params("examples#index").normalize).
to eq({ controller: "examples", action: "index"})
context 'when the route params is a string' do
it 'produces a hash of route params' do
expect(build_route_params('examples#index').normalize).
to eq({ controller: 'examples', action: 'index'})
end
end
end

View File

@ -9,7 +9,7 @@ describe Shoulda::Matchers::ActiveModel, type: :model do
end
describe Shoulda::Matchers::ActiveModel::AllowValueMatcher, type: :model do
context "#description" do
context '#description' do
it 'describes itself with two values' do
matcher = allow_value('foo', 'bar').for(:baz)
@ -43,7 +43,7 @@ describe Shoulda::Matchers::ActiveModel::AllowValueMatcher, type: :model do
end
it 'truncates the description when long' do
matcher = allow_value("A" * 10000).for(:baz)
matcher = allow_value('A' * 10000).for(:baz)
expect(matcher.description).to eq "allow :baz to be \"#{"A" * 499}..."
end
@ -325,7 +325,7 @@ errors instead:
record = record_with_custom_validation(options) do
if self.attr == 'xyz'
self.errors.add :attr, "some other error"
self.errors.add :attr, 'some other error'
end
end
@ -385,7 +385,7 @@ errors instead:
context 'if the messages do not match' do
it 'technically accepts' do
builder = builder_for_record_with_different_error_attribute(
message: "a different error"
message: 'a different error'
)
invalid_value = "#{builder.valid_value} (invalid)"
@ -394,7 +394,7 @@ errors instead:
not_to allow_value(invalid_value).
for(builder.attribute_to_validate).
with_message(
"some error",
'some error',
against: builder.attribute_that_receives_error
)
end
@ -440,20 +440,20 @@ indeed invalid, but it produced these validation errors instead:
end
end
context "an attribute with a context-dependent validation" do
context "without the validation context" do
it "allows a bad value" do
expect(validating_format(with: /abc/, on: :customisable)).to allow_value("xyz").for(:attr)
context 'an attribute with a context-dependent validation' do
context 'without the validation context' do
it 'allows a bad value' do
expect(validating_format(with: /abc/, on: :customisable)).to allow_value('xyz').for(:attr)
end
end
context "with the validation context" do
it "allows a good value" do
expect(validating_format(with: /abc/, on: :customisable)).to allow_value("abcde").for(:attr).on(:customisable)
context 'with the validation context' do
it 'allows a good value' do
expect(validating_format(with: /abc/, on: :customisable)).to allow_value('abcde').for(:attr).on(:customisable)
end
it "rejects a bad value" do
expect(validating_format(with: /abc/, on: :customisable)).not_to allow_value("xyz").for(:attr).on(:customisable)
it 'rejects a bad value' do
expect(validating_format(with: /abc/, on: :customisable)).not_to allow_value('xyz').for(:attr).on(:customisable)
end
end
end
@ -490,7 +490,7 @@ indeed invalid, but it produced these validation errors instead:
ignoring_interference_by_writer
end
it "does not match given good values along with bad values" do
it 'does not match given good values along with bad values' do
message = <<-MESSAGE.strip_heredoc
After setting :attr to "12345", the matcher expected the Example to be
invalid, but it was valid instead.
@ -503,7 +503,7 @@ invalid, but it was valid instead.
expect(&assertion).to fail_with_message(message)
end
it "does not match given bad values along with good values" do
it 'does not match given bad values along with good values' do
message = <<-MESSAGE.strip_heredoc
After setting :attr to "12345", the matcher expected the Example to be
invalid, but it was valid instead.

View File

@ -11,20 +11,20 @@ describe Shoulda::Matchers::ActiveModel::DisallowValueMatcher, type: :model do
end
end
context "an attribute with a context-dependent validation" do
context "without the validation context" do
it "does not match" do
expect(validating_format(with: /abc/, on: :customisable)).not_to matcher("xyz").for(:attr)
context 'an attribute with a context-dependent validation' do
context 'without the validation context' do
it 'does not match' do
expect(validating_format(with: /abc/, on: :customisable)).not_to matcher('xyz').for(:attr)
end
end
context "with the validation context" do
it "disallows a bad value" do
expect(validating_format(with: /abc/, on: :customisable)).to matcher("xyz").for(:attr).on(:customisable)
context 'with the validation context' do
it 'disallows a bad value' do
expect(validating_format(with: /abc/, on: :customisable)).to matcher('xyz').for(:attr).on(:customisable)
end
it "does not match a good value" do
expect(validating_format(with: /abc/, on: :customisable)).not_to matcher("abcde").for(:attr).on(:customisable)
it 'does not match a good value' do
expect(validating_format(with: /abc/, on: :customisable)).not_to matcher('abcde').for(:attr).on(:customisable)
end
end
end

View File

@ -28,7 +28,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateAbsenceOfMatcher, type: :model
available_column_types.each do |type|
context "when column is of type #{type}" do
it "accepts" do
it 'accepts' do
expect(validating_absence_of(:attr, {}, type: type)).
to validate_absence_of(:attr)
end
@ -198,12 +198,12 @@ could not be proved.
end
end
context "an i18n translation containing %{attribute} and %{model}" do
context 'an i18n translation containing %{attribute} and %{model}' do
after { I18n.backend.reload! }
it "does not raise an exception" do
stub_translation("activerecord.errors.messages.present",
"%{attribute} must be blank in a %{model}")
it 'does not raise an exception' do
stub_translation('activerecord.errors.messages.present',
'%{attribute} must be blank in a %{model}')
expect {
expect(validating_absence_of(:attr)).to validate_absence_of(:attr)
@ -211,15 +211,15 @@ could not be proved.
end
end
context "an attribute with a context-dependent validation" do
context "without the validation context" do
it "does not match" do
context 'an attribute with a context-dependent validation' do
context 'without the validation context' do
it 'does not match' do
expect(validating_absence_of(:attr, on: :customisable)).not_to validate_absence_of(:attr)
end
end
context "with the validation context" do
it "matches" do
context 'with the validation context' do
it 'matches' do
expect(validating_absence_of(:attr, on: :customisable)).to validate_absence_of(:attr).on(:customisable)
end
end

View File

@ -237,14 +237,14 @@ could not be proved.
context 'using translations' do
after { I18n.backend.reload! }
context "a too_long translation containing %{attribute}, %{model}" do
context 'a too_long translation containing %{attribute}, %{model}' do
before do
stub_translation(
"activerecord.errors.messages.too_long",
"The %{attribute} of your %{model} is too long (maximum is %{count} characters)")
'activerecord.errors.messages.too_long',
'The %{attribute} of your %{model} is too long (maximum is %{count} characters)')
end
it "does not raise an exception" do
it 'does not raise an exception' do
expect {
expect(validating_length(maximum: 4)).
to validate_length_of(:attr).is_at_most(4)
@ -252,28 +252,28 @@ could not be proved.
end
end
context "a too_short translation containing %{attribute}, %{model}" do
context 'a too_short translation containing %{attribute}, %{model}' do
before do
stub_translation(
"activerecord.errors.messages.too_short",
"The %{attribute} of your %{model} is too short (minimum is %{count} characters)")
'activerecord.errors.messages.too_short',
'The %{attribute} of your %{model} is too short (minimum is %{count} characters)')
end
it "does not raise an exception" do
it 'does not raise an exception' do
expect {
expect(validating_length(minimum: 4)).to validate_length_of(:attr).is_at_least(4)
}.to_not raise_exception
end
end
context "a wrong_length translation containing %{attribute}, %{model}" do
context 'a wrong_length translation containing %{attribute}, %{model}' do
before do
stub_translation(
"activerecord.errors.messages.wrong_length",
"The %{attribute} of your %{model} is the wrong length (should be %{count} characters)")
'activerecord.errors.messages.wrong_length',
'The %{attribute} of your %{model} is the wrong length (should be %{count} characters)')
end
it "does not raise an exception" do
it 'does not raise an exception' do
expect {
expect(validating_length(is: 4)).
to validate_length_of(:attr).is_equal_to(4)

View File

@ -2022,7 +2022,7 @@ could not be proved.
end
context 'qualified with odd + is_greater_than_or_equal_to' do
it "describes that it allows odd numbers greater than or equal to a certain value" do
it 'describes that it allows odd numbers greater than or equal to a certain value' do
matcher = validate_numericality_of(:attr).
odd.
is_greater_than_or_equal_to(18)

View File

@ -882,16 +882,16 @@ could not be proved.
end
end
context "an i18n translation containing %{attribute} and %{model}" do
context 'an i18n translation containing %{attribute} and %{model}' do
before do
stub_translation(
"activerecord.errors.messages.blank",
"Please enter a %{attribute} for your %{model}")
'activerecord.errors.messages.blank',
'Please enter a %{attribute} for your %{model}')
end
after { I18n.backend.reload! }
it "does not raise an exception" do
it 'does not raise an exception' do
expect {
expect(validating_presence).to validate_presence_of(:attr)
}.to_not raise_exception
@ -932,15 +932,15 @@ validation exception on failure, but this could not be proved.
end
end
context "an attribute with a context-dependent validation" do
context "without the validation context" do
it "does not match" do
context 'an attribute with a context-dependent validation' do
context 'without the validation context' do
it 'does not match' do
expect(validating_presence(on: :customisable)).not_to matcher
end
end
context "with the validation context" do
it "matches" do
context 'with the validation context' do
it 'matches' do
expect(validating_presence(on: :customisable)).to matcher.on(:customisable)
end
end

View File

@ -895,7 +895,7 @@ within the scope of :scope1, but this could not be proved.
end
end
context "when an existing record that is not the first has a nil value for the scoped attribute" do
context 'when an existing record that is not the first has a nil value for the scoped attribute' do
# This fails intermittently
# it 'still works' do
# model = define_model_validating_uniqueness(scopes: [:scope])

View File

@ -1,8 +1,8 @@
require 'spec_helper'
require 'shoulda/matchers/util/word_wrap'
describe Shoulda::Matchers, ".word_wrap" do
it "can wrap a simple paragraph" do
describe Shoulda::Matchers, '.word_wrap' do
it 'can wrap a simple paragraph' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat
MESSAGE
@ -13,7 +13,7 @@ ipsum sit amet efficitur feugiat
MESSAGE
end
it "does not split words up when wrapping" do
it 'does not split words up when wrapping' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean lusciousness, ipsum sit amet efficitur feugiat
MESSAGE
@ -24,7 +24,7 @@ lusciousness, ipsum sit amet efficitur feugiat
MESSAGE
end
it "considers punctuation as part of a word" do
it 'considers punctuation as part of a word' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luscious, ipsum sit amet efficitur feugiat
MESSAGE
@ -35,7 +35,7 @@ luscious, ipsum sit amet efficitur feugiat
MESSAGE
end
it "does not break at the maximum line length, but afterward" do
it 'does not break at the maximum line length, but afterward' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luscius, ipsum sit amet efficitur feugiat
MESSAGE
@ -46,7 +46,7 @@ ipsum sit amet efficitur feugiat
MESSAGE
end
it "re-wraps entire paragraphs" do
it 're-wraps entire paragraphs' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
@ -62,7 +62,7 @@ posuere diam ex ut velit.
MESSAGE
end
it "can wrap multiple paragraphs" do
it 'can wrap multiple paragraphs' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla erat, sed posuere diam ex ut velit.
@ -79,7 +79,7 @@ risus, non faucibus sem.
MESSAGE
end
it "can wrap a bulleted list" do
it 'can wrap a bulleted list' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
* Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla erat, sed posuere diam ex ut velit.
* And the beat goes on.
@ -93,7 +93,7 @@ risus, non faucibus sem.
MESSAGE
end
it "re-wraps bulleted lists" do
it 're-wraps bulleted lists' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
* Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
@ -112,7 +112,7 @@ risus, non faucibus sem.
MESSAGE
end
it "can wrap a numbered list" do
it 'can wrap a numbered list' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
1. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla erat, sed posuere diam ex ut velit.
2. And the beat goes on.
@ -126,7 +126,7 @@ risus, non faucibus sem.
MESSAGE
end
it "re-wraps numbered lists" do
it 're-wraps numbered lists' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
1. Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
@ -145,7 +145,7 @@ risus, non faucibus sem.
MESSAGE
end
it "can wrap a numbered list, using x) instead of x. as the leader" do
it 'can wrap a numbered list, using x) instead of x. as the leader' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
1) Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat, dolor mauris fringilla erat, sed posuere diam ex ut velit.
2) And the beat goes on.
@ -159,7 +159,7 @@ risus, non faucibus sem.
MESSAGE
end
it "re-wraps numbered lists using x) instead of x. as the leader" do
it 're-wraps numbered lists using x) instead of x. as the leader' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
1) Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
@ -196,9 +196,9 @@ And now we return.
MESSAGE
end
context "given a string with a word longer than the max character limit" do
context "which stands on its own" do
it "simply returns the string" do
context 'given a string with a word longer than the max character limit' do
context 'which stands on its own' do
it 'simply returns the string' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
Foo bar baz and stuff and things Loremipsumdolorsitamet,consecteturadipiscingelit.Aeneanluctus,ipsumsitametefficiturfeugiat,
MESSAGE
@ -210,8 +210,8 @@ Loremipsumdolorsitamet,consecteturadipiscingelit.Aeneanluctus,ipsumsitameteffici
end
end
context "which is preceded by some text" do
it "leaves the word on its own line" do
context 'which is preceded by some text' do
it 'leaves the word on its own line' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
Foo bar baz and stuff and things Loremipsumdolorsitamet,consecteturadipiscingelit.Aeneanluctus,ipsumsitametefficiturfeugiat,
MESSAGE
@ -223,8 +223,8 @@ Loremipsumdolorsitamet,consecteturadipiscingelit.Aeneanluctus,ipsumsitameteffici
end
end
context "which is followed by some text" do
it "leaves the word on its own line" do
context 'which is followed by some text' do
it 'leaves the word on its own line' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
Loremipsumdolorsitamet,consecteturadipiscingelit.Aeneanluctus,ipsumsitametefficiturfeugiat, and something goes after this
MESSAGE
@ -237,8 +237,8 @@ and something goes after this
end
end
context "when :indent is given" do
it "uses the given indentation level when determining where to wrap lines" do
context 'when :indent is given' do
it 'uses the given indentation level when determining where to wrap lines' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.strip, indent: 2)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat
MESSAGE

View File

@ -34,8 +34,8 @@ RSpec.configure do |config|
config.include UnitTests::Matchers
config.infer_spec_type_from_file_location!
config.example_status_persistence_file_path = "spec/examples.txt"
config.alias_it_behaves_like_to(:it_supports, "it supports")
config.example_status_persistence_file_path = 'spec/examples.txt'
config.alias_it_behaves_like_to(:it_supports, 'it supports')
config.before(:all, type: :controller) do
self.class.controller(ApplicationController) { }

View File

@ -23,11 +23,11 @@ module Shoulda
desc 'Generate docs for a particular version'
task :generate, [:version, :latest_version] => :setup do |t, args|
unless args.version
raise ArgumentError, "Missing version"
raise ArgumentError, 'Missing version'
end
unless args.latest_version
raise ArgumentError, "Missing latest_version"
raise ArgumentError, 'Missing latest_version'
end
publisher.generate_docs_for(args.version, latest_version: args.latest_version)
@ -37,7 +37,7 @@ module Shoulda
task :autogenerate do
require 'fssm'
project_directory = File.expand_path(File.dirname(__FILE__) + "/..")
project_directory = File.expand_path(File.dirname(__FILE__) + '/..')
regenerate_docs = proc do
print 'Regenerating docs... '
@ -64,11 +64,11 @@ module Shoulda
desc 'Generate docs for a particular version and push them to GitHub'
task :publish, [:version, :latest_version] => :setup do |t, args|
unless args.version
raise ArgumentError, "Missing version"
raise ArgumentError, 'Missing version'
end
unless args.latest_version
raise ArgumentError, "Missing latest_version"
raise ArgumentError, 'Missing latest_version'
end
publisher.generate_docs_for(args.version, latest_version: args.latest_version)