Module: RSpec::Matchers::Pretty

Defined in:
opal/opal/rspec/fixes.rb

Instance Method Summary collapse

Instance Method Details

#underscore(camel_cased_word) ⇒ Object



12
13
14
15
16
17
18
19
# File 'opal/opal/rspec/fixes.rb', line 12

def underscore(camel_cased_word)
  word = camel_cased_word.to_s
  word = word.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
  word = word.gsub(/([a-z\d])([A-Z])/,'\1_\2')
  word = word.tr("-", "_")
  word = word.downcase
  word
end