Skip to content

Commit

Permalink
Merge branch 'master' into fix-349
Browse files Browse the repository at this point in the history
  • Loading branch information
tfausak committed Jan 15, 2016
2 parents 50ac2af + a3b3d35 commit 9506343
Show file tree
Hide file tree
Showing 22 changed files with 63 additions and 67 deletions.
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Documentation:
FileName:
Exclude:
- gemfiles/*
HandleExceptions:
Enabled: false
MultilineMethodCallIndentation:
EnforcedStyle: indented
MultilineOperationIndentation:
Enabled: false
PercentLiteralDelimiters:
Expand Down
2 changes: 1 addition & 1 deletion active_interaction.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Gem::Specification.new do |gem|
'kramdown' => ['~> 1.9'],
'rake' => ['~> 10.4'],
'rspec' => ['~> 3.4'],
'rubocop' => ['~> 0.35'],
'rubocop' => ['~> 0.36.0'],
'yard' => ['~> 0.8']
}.each do |name, versions|
gem.add_development_dependency name, *versions
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
string: '',
symbol: :'',
time: Time.at(0)
}
}.freeze

Benchmark.ips do |bm|
bm.report('lambda') { -> {}.call }
Expand Down
2 changes: 1 addition & 1 deletion lib/active_interaction/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def populate_filters(inputs)
begin
public_send("#{name}=", filter.clean(inputs[name], self))
rescue InvalidValueError, MissingValueError, NoDefaultError
# #type_check will add errors if appropriate.
nil # #type_check will add errors if appropriate.
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_interaction/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module ActiveInteraction
# Describes an input filter for an interaction.
class Filter
# @return [Hash{Symbol => Class}]
CLASSES = {}
CLASSES = {} # rubocop:disable Style/MutableConstant
private_constant :CLASSES

# @return [Hash{Symbol => Filter}]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module ActiveInteraction
#
# @private
class AbstractDateTimeFilter < AbstractFilter
alias_method :_cast, :cast
alias _cast cast
private :_cast

def cast(value, context)
Expand Down
2 changes: 1 addition & 1 deletion lib/active_interaction/filters/abstract_numeric_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module ActiveInteraction
#
# @private
class AbstractNumericFilter < AbstractFilter
alias_method :_cast, :cast
alias _cast cast
private :_cast

def cast(value, context)
Expand Down
2 changes: 1 addition & 1 deletion lib/active_interaction/filters/time_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Base
class TimeFilter < AbstractDateTimeFilter
register :time

alias_method :_klass, :klass
alias _klass klass
private :_klass

def initialize(name, options = {}, &block)
Expand Down
23 changes: 12 additions & 11 deletions spec/active_interaction/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ def execute
describe '.new(inputs = {})' do
it 'does not allow :_interaction_* as an option' do
key = :"_interaction_#{SecureRandom.hex}"
inputs.merge!(key => nil)
inputs[key] = nil
expect do
interaction
end.to raise_error ActiveInteraction::InvalidValueError
end

it 'does not allow "_interaction_*" as an option' do
key = "_interaction_#{SecureRandom.hex}"
inputs.merge!(key => nil)
inputs[key] = nil
expect do
interaction
end.to raise_error ActiveInteraction::InvalidValueError
Expand Down Expand Up @@ -75,7 +75,7 @@ def execute
end

context 'passing' do
before { inputs.merge!(thing: SecureRandom.hex) }
before { inputs[:thing] = SecureRandom.hex }

it 'returns a valid outcome' do
expect(interaction).to be_valid
Expand All @@ -85,7 +85,7 @@ def execute

context 'with a single input' do
let(:thing) { SecureRandom.hex }
before { inputs.merge!(thing: thing) }
before { inputs[:thing] = thing }

it 'sets the attribute' do
expect(interaction.thing).to eql thing
Expand All @@ -98,7 +98,7 @@ def execute

context 'validation' do
context 'failing' do
before { inputs.merge!(thing: thing) }
before { inputs[:thing] = thing }

context 'with an invalid value' do
let(:thing) { 'a' }
Expand All @@ -118,7 +118,7 @@ def execute
end

context 'passing' do
before { inputs.merge!(thing: 1) }
before { inputs[:thing] = 1 }

it 'returns a valid outcome' do
expect(interaction).to be_valid
Expand All @@ -127,7 +127,7 @@ def execute
end

context 'with a single input' do
before { inputs.merge!(thing: 1) }
before { inputs[:thing] = 1 }

it 'sets the attribute to the filtered value' do
expect(interaction.thing).to eql 1.0
Expand Down Expand Up @@ -248,7 +248,7 @@ def execute
end

context 'passing validations' do
before { inputs.merge!(thing: thing) }
before { inputs[:thing] = thing }

context 'failing runtime validations' do
before do
Expand Down Expand Up @@ -311,7 +311,7 @@ def execute
end

context 'passing validations' do
before { inputs.merge!(thing: thing) }
before { inputs[:thing] = thing }

it 'returns the result' do
expect(result[:thing]).to eql thing
Expand Down Expand Up @@ -341,7 +341,8 @@ def execute

context 'with valid composition' do
before do
inputs.merge!(x: x, z: z)
inputs[:x] = x
inputs[:z] = z
end

it 'is valid' do
Expand Down Expand Up @@ -485,7 +486,7 @@ def filters(klass)
let(:thing) { rand }

before do
inputs.merge!(thing: thing)
inputs[:thing] = thing
end

it 'returns true' do
Expand Down
2 changes: 1 addition & 1 deletion spec/active_interaction/concerns/runnable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
let(:result) { double }

it 'returns the result' do
expect(instance.result = result).to eql result
expect((instance.result = result)).to eql result
end

it 'sets the result' do
Expand Down
12 changes: 5 additions & 7 deletions spec/active_interaction/filters/date_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let(:format) { '%d/%m/%Y' }

before do
options.merge!(format: format)
options[:format] = format
end
end

Expand Down Expand Up @@ -116,12 +116,10 @@
describe '#default' do
context 'with a GroupedInput' do
before do
options.merge!(
default: ActiveInteraction::GroupedInput.new(
'1' => '2012',
'2' => '1',
'3' => '2'
)
options[:default] = ActiveInteraction::GroupedInput.new(
'1' => '2012',
'2' => '1',
'3' => '2'
)
end

Expand Down
18 changes: 8 additions & 10 deletions spec/active_interaction/filters/date_time_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let(:format) { '%d/%m/%Y %H:%M:%S %:z' }

before do
options.merge!(format: format)
options[:format] = format
end
end

Expand Down Expand Up @@ -124,15 +124,13 @@
describe '#default' do
context 'with a GroupedInput' do
before do
options.merge!(
default: ActiveInteraction::GroupedInput.new(
'1' => '2012',
'2' => '1',
'3' => '2',
'4' => '3',
'5' => '4',
'6' => '5'
)
options[:default] = ActiveInteraction::GroupedInput.new(
'1' => '2012',
'2' => '1',
'3' => '2',
'4' => '3',
'5' => '4',
'6' => '5'
)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/active_interaction/filters/decimal_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let(:digits) { 4 }

before do
options.merge!(digits: digits)
options[:digits] = digits
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/active_interaction/filters/hash_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
describe '#default' do
context 'with a Hash' do
before do
options.merge!(default: {})
options[:default] = {}
end

it 'returns the Hash' do
Expand All @@ -90,7 +90,7 @@

context 'with a non-empty Hash' do
before do
options.merge!(default: { a: {} })
options[:default] = { a: {} }
end

it 'raises an error' do
Expand Down
8 changes: 4 additions & 4 deletions spec/active_interaction/filters/object_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Things; end
it_behaves_like 'a filter'

before do
options.merge!(class: Thing)
options[:class] = Thing
end

describe '#cast' do
Expand Down Expand Up @@ -101,7 +101,7 @@ def self.name

context 'with class as a superclass' do
before do
options.merge!(class: Thing.superclass)
options[:class] = Thing.superclass
end

it 'returns the instance' do
Expand All @@ -111,7 +111,7 @@ def self.name

context 'with class as a String' do
before do
options.merge!(class: Thing.name)
options[:class] = Thing.name
end

it 'returns the instance' do
Expand All @@ -131,7 +131,7 @@ def self.name

context 'with class as an invalid String' do
before do
options.merge!(class: 'invalid')
options[:class] = 'invalid'
end

it 'raises an error' do
Expand Down
2 changes: 1 addition & 1 deletion spec/active_interaction/filters/string_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

shared_context 'without strip' do
before do
options.merge!(strip: false)
options[:strip] = false
end
end

Expand Down
18 changes: 8 additions & 10 deletions spec/active_interaction/filters/time_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
let(:format) { '%d/%m/%Y %H:%M:%S %z' }

before do
options.merge!(format: format)
options[:format] = format
end
end

Expand Down Expand Up @@ -146,15 +146,13 @@
describe '#default' do
context 'with a GroupedInput' do
before do
options.merge!(
default: ActiveInteraction::GroupedInput.new(
'1' => '2012',
'2' => '1',
'3' => '2',
'4' => '3',
'5' => '4',
'6' => '5'
)
options[:default] = ActiveInteraction::GroupedInput.new(
'1' => '2012',
'2' => '1',
'3' => '2',
'4' => '3',
'5' => '4',
'6' => '5'
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CollectionProxy
context 'with inputs[:a]' do
let(:a) { [[]] }

before { inputs.merge!(a: a) }
before { inputs[:a] = a }

it 'returns the correct value for :a' do
expect(result[:a]).to eql a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
context 'with inputs[:a]' do
let(:a) { { x: {} } }

before { inputs.merge!(a: a) }
before { inputs[:a] = a }

it 'returns the correct value for :a' do
expect(result[:a]).to eql a.with_indifferent_access
Expand Down
3 changes: 2 additions & 1 deletion spec/active_interaction/integration/time_interaction_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def self.at(*args)
def self.parse(*args)
TimeWithZone.new(Time.parse(*args))
rescue ArgumentError
nil
end
end

Expand Down Expand Up @@ -37,7 +38,7 @@ def ==(other)
let(:a) { nil }

before do
inputs.merge!(a: a)
inputs[:a] = a

allow(Time).to receive(:zone).and_return(TimeZone)
end
Expand Down

0 comments on commit 9506343

Please sign in to comment.