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 collaboratorPlaying a role
- Background
-
- Given
-
a file named "spec/spec_helper.rb" with:
require 'rspec/role-mocks' $LOAD_PATH.unshift('lib')
- And
-
a file named "spec/roles/logger.rb" with:
RSpec.define_role 'Logger' do def log(message, opts = {}, &block); end end
- And
-
a file named "spec/console_logger_spec.rb" with:
require 'spec_helper' require 'console_logger' require 'roles/logger' describe ConsoleLogger do it_plays_role 'Logger' end
- Scenarios
-
- Object plays the role
- Object does not play the role
- Object has other method arity
- Object has other method argument type
- Object plays the role
-
- Given
-
a file named "lib/console_logger.rb" with:
class ConsoleLogger def log(message, opts = {}, &block); end end
- When
-
I run
rspec spec/console_logger_spec.rb
- Then
- the example should pass
- Object does not play the role
-
- Given
-
a file named "lib/console_logger.rb" with:
class ConsoleLogger def not_log(message); end end
- When
-
I run
rspec spec/console_logger_spec.rb
- Then
- the example should fail
- And
-
the output should contain:
ConsoleLogger does not play role "Logger" as expected
- Object has other method arity
-
- Given
-
a file named "lib/console_logger.rb" with:
class ConsoleLogger def log(message); end end
- When
-
I run
rspec spec/console_logger_spec.rb
- Then
- the example should fail
- And
-
the output should contain:
ConsoleLogger does not play role "Logger" as expected
- Object has other method argument type
-
- Given
-
a file named "lib/console_logger.rb" with:
class ConsoleLogger def log(message, opts = {}, no_block); end end
- When
-
I run
rspec spec/console_logger_spec.rb
- Then
- the example should fail
- And
-
the output should contain:
ConsoleLogger does not play role "Logger" as expected
Last published over 7 years ago by treppo.