I have the following ruby calabash step:
When(/^I enter (phone number|email)$/) do |method|
login_type = case method
when 'phone number'
true
when 'email'
false
else
raise("#{method} is not supported")
end
verify_login_page(type: login_type)
aggregator = case method
when 'phone number'
Aggregator::PHONE
when 'email'
Aggregator::EMAIL
else
Aggregator::ALL
end
get_and_enter_code(aggregator)
end
Even though it seems clear, I'm pretty sure I can make it better from design perspective. Especially what I don't like is login_type case method with true/false assignment. How it's better to do it? Thanks
You can use ternary operator assignment:
Since you raise exception
Aggregator::ALLcase should never occur.