summaryrefslogtreecommitdiff
path: root/spec/rubocop/migration_helpers_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubocop/migration_helpers_spec.rb')
-rw-r--r--spec/rubocop/migration_helpers_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/rubocop/migration_helpers_spec.rb b/spec/rubocop/migration_helpers_spec.rb
index 6e6c3a7a0b9..56b7b6aa76b 100644
--- a/spec/rubocop/migration_helpers_spec.rb
+++ b/spec/rubocop/migration_helpers_spec.rb
@@ -2,6 +2,7 @@
require 'fast_spec_helper'
require 'rspec-parameterized'
+require 'rubocop/ast'
require_relative '../../rubocop/migration_helpers'
@@ -69,4 +70,27 @@ RSpec.describe RuboCop::MigrationHelpers do
it { expect(fake_cop.time_enforced?(node)).to eq(expected) }
end
end
+
+ describe '#array_column?' do
+ let(:name) { nil }
+ let(:node) { double(:node, each_descendant: [pair_node]) }
+ let(:pair_node) { double(child_nodes: child_nodes) }
+
+ context 'when it matches array: true' do
+ let(:child_nodes) do
+ [
+ RuboCop::AST::SymbolNode.new(:sym, [:array]),
+ RuboCop::AST::Node.new(:true) # rubocop:disable Lint/BooleanSymbol
+ ]
+ end
+
+ it { expect(fake_cop.array_column?(node)).to eq(true) }
+ end
+
+ context 'when it matches a variable => 100' do
+ let(:child_nodes) { [RuboCop::AST::Node.new(:lvar, [:variable]), RuboCop::AST::IntNode.new(:int, [100])] }
+
+ it { expect(fake_cop.array_column?(node)).to eq(false) }
+ end
+ end
end