Commit 03997e00 authored by intrigeri's avatar intrigeri Committed by Tails developers
Browse files

Name newly introduced functions (that have no side effect) depending on what...

Name newly introduced functions (that have no side effect) depending on what they return, instead of what they do.
parent 94412752
......@@ -126,7 +126,7 @@ When /^I join some empty multi-user chat$/ do
!account["chat_room"].empty?
chat_room = account["chat_room"]
else
chat_room = generate_random_alnum_string(10,15)
chat_room = random_alnum_string(10,15)
end
@screen.type(chat_room)
......
......@@ -115,16 +115,16 @@ end
ALPHA_SET = ('A'..'Z').to_a + ('a'..'z').to_a
ALNUM_SET = ALPHA_SET + (0..9).to_a.map { |n| n.to_s }
def generate_random_string_from_set(set, min_len, max_len)
def random_string_from_set(set, min_len, max_len)
len = (min_len..max_len).to_a.sample
len ||= min_len
(0..len-1).map { |n| set.sample }.join
end
def generate_random_alpha_string(min_len, max_len = 0)
generate_random_string_from_set(ALPHA_SET, min_len, max_len)
def random_alpha_string(min_len, max_len = 0)
random_string_from_set(ALPHA_SET, min_len, max_len)
end
def generate_random_alnum_string(min_len, max_len = 0)
generate_random_string_from_set(ALNUM_SET, min_len, max_len)
def random_alnum_string(min_len, max_len = 0)
random_string_from_set(ALNUM_SET, min_len, max_len)
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment