Skip to content

Instantly share code, notes, and snippets.

@csexton
Created June 6, 2014 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csexton/ada371ab6f2f356e50aa to your computer and use it in GitHub Desktop.
Save csexton/ada371ab6f2f356e50aa to your computer and use it in GitHub Desktop.
require 'rspec'
require 'rspec/autorun'
def pack_size(desc)
if (desc.match(/([\d]+)[\s]pack/i))
$1.to_i
else
1
end
end
describe 'pack_size' do
it "lowercase 'pack'" do
expect(pack_size("10 pack")).to eq 10
end
it "leading characters" do
expect(pack_size("oh hai there 3 pack")).to eq 3
end
it "trailing characters" do
expect(pack_size("10 Pack late to the show")).to eq 10
end
it "defaults to 1" do
expect(pack_size("Nothing to see here")).to eq 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment