Class: Inspec::Expect
- Inherits:
-
Object
- Object
- Inspec::Expect
- Defined in:
- lib/inspec/expect.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #example_group ⇒ Object
-
#initialize(value, &block) ⇒ Expect
constructor
A new instance of Expect.
- #not_to(*args, &block) ⇒ Object
- #to(*args, &block) ⇒ Object
Constructor Details
#initialize(value, &block) ⇒ Expect
Returns a new instance of Expect.
11 12 13 14 15 |
# File 'lib/inspec/expect.rb', line 11 def initialize(value, &block) @value = value @block = block @calls = [] end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
10 11 12 |
# File 'lib/inspec/expect.rb', line 10 def block @block end |
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
10 11 12 |
# File 'lib/inspec/expect.rb', line 10 def calls @calls end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/inspec/expect.rb', line 10 def value @value end |
Instance Method Details
#example_group ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/inspec/expect.rb', line 25 def example_group that = self opts = { 'caller' => calls[0][3] } if !calls[0][3].nil? && !calls[0][3].empty? && (m = calls[0][3][0].match(/^([^:]*):(\d+):/)) opts['file_path'] = m[0] opts['line_number'] = m[1] end RSpec::Core::ExampleGroup.describe(that.value, opts) do that.calls.each do |method, args, block, clr| it(nil, caller: clr) do x = expect(that.value, &that.block).method(method) x.call(*args, &block) end end end end |
#not_to(*args, &block) ⇒ Object
21 22 23 |
# File 'lib/inspec/expect.rb', line 21 def not_to(*args, &block) @calls.push([:not_to, args, block, caller]) end |
#to(*args, &block) ⇒ Object
17 18 19 |
# File 'lib/inspec/expect.rb', line 17 def to(*args, &block) @calls.push([:to, args, block, caller]) end |