Skip to content

Instantly share code, notes, and snippets.

Created July 13, 2015 20:07
Show Gist options
  • Save anonymous/d4abda87a8af366b5953 to your computer and use it in GitHub Desktop.
Save anonymous/d4abda87a8af366b5953 to your computer and use it in GitHub Desktop.
class String
def do_certain_parts_contain_a_number?
self.match /regex/ do |match|
'its a number!' if match.contains_a_number? # HOW TO I MOCK contains_a_number? HERE?!
end
end
end
RSpec.decribe String do
describe '#do_certain_parts_contain_a_number?'
it 'returns ' do
expect{ match }.to_receive(:contains_a_number?).and_return true # OR SOMETHING?!
expect{ 'acertainstring43'.do_certain_parts_contain_a_number? }.to eq 'its a number!'
end
end
end
NoMethodError:
undefined method `contains_a_number?' for "acertainstring43":String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment