diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index <HASH>..<HASH> 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -22,11 +22,14 @@ RSpec.configure do |config|
   end
 end
 
-def an_illegal_claim_code
+def generate_code(number)
   legal_map = [*'A'..'Z'] + [*'a'..'z'] + [*0..9]
-  first_length = rand(6)
-  short_code = (0..first_length).map{legal_map.sample}.join
-  second_length = [*8..25].sample
-  long_code = [*8..25].sample.times.inject([]){|arr| arr << legal_map.sample}.join
+  Array.new(number) { legal_map.sample }.join
+end
+
+  
+def an_illegal_claim_code
+  short_code = generate_code(rand(6))
+  long_code  = generate_code(rand(8..25))
   [nil, short_code, long_code].sample
 end
Refactor claim code generation

This refactor makes the code much easier to understand and takes advantage of **rand(Range)** and **Array.new** with a block.