require 'spec_helper' describe Benches::Routine do describe 'initialize' do context 'no method arguments' do let(:bench) { Benches::Routine.new("test_string", 'split', 50000) } it 'assigns instance correctly' do expect(bench.instance_variable_get('@instance')).to eql 'test_string' end it 'assigns method correctly' do expect(bench.instance_variable_get('@method')).to eql 'split' end it 'assigns repetitions correctly' do expect(bench.instance_variable_get('@repetitions')).to eql 50000 end it 'sets args to empty array' do expect(bench.instance_variable_get('@args')).to eql [] end end context 'method has arguments' do let(:bench) { Benches::Routine.new("test_string", 'insert', 50000, 1, 'a') } it 'assigns instance correctly' do expect(bench.instance_variable_get('@instance')).to eql 'test_string' end it 'assigns method correctly' do expect(bench.instance_variable_get('@method')).to eql 'insert' end it 'assigns repetitions correctly' do expect(bench.instance_variable_get('@repetitions')).to eql 50000 end it' assigns args correctly' do expect(bench.instance_variable_get('@args')).to eql [1, 'a'] end end end describe 'call' do context 'no method arguments' do let(:bench) { Benches::Routine.new("test_string", 'split', 20) } it 'performs benchmark' do expect(bench.call).to be_a Benchmark::Tms end end context 'method has arguments' do let(:bench) { Benches::Routine.new("test_string", 'insert', 20, 1, 'a') } it 'performs benchmark' do expect(bench.call).to be_a Benchmark::Tms end end end end