Skip to content
This repository was archived by the owner on Sep 17, 2018. It is now read-only.

Commit d3b051b

Browse files
author
James Couball
committed
Tighten up expected exceptions to avoid false positives
1 parent 5300031 commit d3b051b

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

lib/mysql_expectations/key_field.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ def validate_length(length)
4545
begin
4646
length = Integer(length)
4747
rescue ArgumentError
48-
raise 'length must be an integer or convertable to an integer'
48+
raise ArgumentError.new('length must be an integer or convertable to an integer')
4949
end
5050
length
5151
end
5252

5353
def validate_order(order)
5454
return nil if order.nil?
5555
return order if VALID_ORDERINGS.include? order
56-
fail 'Order must be either KeyField::ORDER_ASC or KeyField::ORDER_DESC'
56+
fail ArgumentError.new('Order must be either KeyField::ORDER_ASC or KeyField::ORDER_DESC')
5757
end
5858
end
5959
end

spec/database_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
expect(subject.item).to be_an_instance_of(Table)
3030
end
3131
it 'should raise an exception when called with args' do
32-
expect { subject.item(1) }.to raise_error
32+
expect { subject.item(1) }.to raise_error NoMethodError
3333
end
3434
it 'should raise an exception when called with a block' do
35-
expect { subject.item {} }.to raise_error
35+
expect { subject.item {} }.to raise_error NoMethodError
3636
end
3737
end
3838

spec/key_field_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
it 'should throw an exception during initialization' do
8585
expect do
8686
KeyField.new('id', :asdf)
87-
end.to raise_error
87+
end.to raise_error ArgumentError
8888
end
8989
end
9090

@@ -100,7 +100,7 @@
100100
it 'should not throw an error during initialization' do
101101
expect do
102102
KeyField.new('id', KeyField::ORDER_ASC, 'forty')
103-
end.to raise_error
103+
end.to raise_error ArgumentError
104104
end
105105
end
106106
end

spec/mysql_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
)
2727
end
2828
it 'should raise an exception when called with args' do
29-
expect { subject.order_tracking(1) }.to raise_error
29+
expect { subject.order_tracking(1) }.to raise_error NoMethodError
3030
end
3131
it 'should raise an exception when called with a block' do
32-
expect { subject.order_tracking {} }.to raise_error
32+
expect { subject.order_tracking {} }.to raise_error NoMethodError
3333
end
3434
end
3535

spec/table_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
expect(subject.id).to be_an_instance_of(Field)
4646
end
4747
it 'should raise an exception when called with args' do
48-
expect { subject.id(1) }.to raise_error
48+
expect { subject.id(1) }.to raise_error NoMethodError
4949
end
5050
it 'should raise an exception when called with a block' do
51-
expect { subject.id {} }.to raise_error
51+
expect { subject.id {} }.to raise_error NoMethodError
5252
end
5353
end
5454

0 commit comments

Comments
 (0)