Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class StringTester
- def self.is_hello?(s)
- s == 'hello'
- end
- end
- RSpec.describe StringTester do
- # Tests are fairly readable in English...
- describe '::is_hello?' do
- it { expect(StringTester.is_hello?('hello')).to be_truthy }
- it { expect(StringTester.is_hello?('something else')).to be_falsey }
- end
- end
- # ...but the output is ambiguous without going back to look at the tests.
- # Output:
- # StringTester
- # ::is_hello?
- # should be truthy
- # should be falsey
- RSpec.describe StringTester do
- # Tests are redundant when read in English...
- describe '::is_hello?' do
- it 'is true for "hello"' do
- expect(StringTester.is_hello?('hello')).to be_truthy
- end
- it 'is false for "something else"' do
- expect(StringTester.is_hello?('something else')).to be_falsey
- end
- end
- end
- # ...but the output is very straightfoward.
- # Output:
- # StringTester
- # ::is_hello?
- # is true for "hello"
- # is false for "something else"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement