To add a collaborator to this project you will need to use the Relish gem to add the collaborator via a terminal command. Soon you'll be able to also add collaborators here!
More about adding a collaboratorReturning a value
- Background
-
- Given
-
a file named "spec/roles/notifier.rb" with:
RSpec.define_role 'Notifier' do def notify; end end
- And
-
a file named "spec/spec_helper.rb" with:
require 'rspec/role-mocks' $LOAD_PATH.unshift("lib")
- Scenarios
-
- Return nil by default
-
- Given
-
a file named "spec/user_spec.rb" with:
require 'spec_helper' require 'roles/notifier' RSpec.describe 'Default return value' do it 'notifies the console' do notifier = role_double("Notifier") expect(notifier).to receive(:notify) expect(notifier.notify).to be_nil end end
- When
-
I run
rspec spec/user_spec.rb
- Then
- the examples should all pass
- Specify a return value
-
- Given
-
a file named "spec/user_spec.rb" with:
require 'spec_helper' require 'roles/notifier' RSpec.describe 'Specified return value' do it 'notifies the console' do notifier = role_double("Notifier") expect(notifier).to receive(:notify).and_return(1) expect(notifier.notify).to eq(1) end end
- When
-
I run
rspec spec/user_spec.rb
- Then
- the examples should all pass
Last published over 7 years ago by treppo.