Class: ArgumentSpecification::Argument
- Inherits:
-
Object
- Object
- ArgumentSpecification::Argument
- Defined in:
- lib/argspec/argument.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
Instance Method Summary collapse
-
#initialize(object) ⇒ Argument
constructor
Create a new argument.
-
#should(matcher, *args) ⇒ Object
Should.
-
#should_not(matcher, *args) ⇒ Object
Should not.
Constructor Details
#initialize(object) ⇒ Argument
Create a new argument
Arguments:
object: (?)
Example:
>> test = :test
>> ArgumentSpecification::Argument.new(test)
=> #<Argument:0x00000000000000 @object=:test>
15 16 17 |
# File 'lib/argspec/argument.rb', line 15 def initialize(object) @object = object end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
3 4 5 |
# File 'lib/argspec/argument.rb', line 3 def object @object end |
Instance Method Details
#should(matcher, *args) ⇒ Object
Should
Arguments:
matcher: (Symbol) A method name as a symbol (see the matchers.rb file)
args: (Splat)
Example:
>> argument.should(:be, true)
=> nil
Raises:
ArgumentError: If the matcher determines the object does not match
32 33 34 35 36 37 38 |
# File 'lib/argspec/argument.rb', line 32 def should(matcher, *args) ensure_matcher(matcher) return if Matchers.send(matcher, self, *args) raise ArgumentError, "'#{prettify_object}' should #{prettify_matcher(matcher)} '#{prettify_args(args)}'" end |
#should_not(matcher, *args) ⇒ Object
Should not
Arguments:
matcher: (Symbol) A method name as a symbol (see the matchers.rb file)
args: (Splat)
Example:
>> argument.should_not(:be, true)
=> nil
Raises:
ArgumentError: If the matcher determines the object does match
53 54 55 56 57 58 59 |
# File 'lib/argspec/argument.rb', line 53 def should_not(matcher, *args) ensure_matcher(matcher) return if Matchers.send(matcher, self, *args) == false raise ArgumentError, "'#{prettify_object}' should not #{prettify_matcher(matcher)} '#{prettify_args(args)}'" end |