describe BikePOA::Helpers::ForceField do class DummySubject < Hashie::Dash include BikePOA::Helpers::ForceField property :number force_integer :number end let(:dummy) { DummySubject.new } describe 'force integer' do it "accepts any value that is castable to integer" do expect { dummy.number = '42' }.to_not raise_error(ArgumentError) expect { dummy.number = 42 }.to_not raise_error(ArgumentError) expect { dummy.number = 42.0 }.to_not raise_error(ArgumentError) end it "raises when the value is not castable to integer" do expect { dummy.number = "abc" }.to raise_error(ArgumentError) expect { dummy.number = "a12" }.to raise_error(ArgumentError) end end end