Class: MinitestToRspec::Model::Iter
- Inherits:
-
Base
- Object
- Base
- MinitestToRspec::Model::Iter
show all
- Defined in:
- lib/minitest_to_rspec/model/iter.rb
Overview
Data object. Represents an ‘:iter` s-expression.
Instance Method Summary
collapse
#assert_sexp_type, #assert_sexp_type_array, #sexp_type?
Constructor Details
#initialize(exp) ⇒ Iter
Returns a new instance of Iter.
9
10
11
12
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 9
def initialize(exp)
assert_sexp_type(:iter, exp)
@exp = exp.dup
end
|
Instance Method Details
#[](*args) ⇒ Object
14
15
16
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 14
def [](*args)
@exp[*args]
end
|
#assert_difference? ⇒ Boolean
18
19
20
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 18
def assert_difference?
!empty? && Model::Call.assert_difference?(@exp[1])
end
|
#assert_no_difference? ⇒ Boolean
#assert_nothing_raised? ⇒ Boolean
#assert_raise? ⇒ Boolean
30
31
32
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 30
def assert_raise?
!empty? && Model::Call.assert_raise?(@exp[1])
end
|
#assert_raises? ⇒ Boolean
34
35
36
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 34
def assert_raises?
!empty? && Model::Call.assert_raises?(@exp[1])
end
|
#block ⇒ Object
38
39
40
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 38
def block
@exp[3]
end
|
#call ⇒ Object
42
43
44
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 42
def call
@exp[1]
end
|
#call_arguments ⇒ Object
Not to be confused with block arguments.
47
48
49
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 47
def call_arguments
call_obj.arguments
end
|
#call_obj ⇒ Object
51
52
53
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 51
def call_obj
Model::Call.new(call)
end
|
#each ⇒ Object
Enumerates children, skipping the base ‘call` and starting with the block arguments, then each `:call` in the block.
58
59
60
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 58
def each
@exp[2..-1].each do |e| yield(e) end
end
|
#empty? ⇒ Boolean
62
63
64
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 62
def empty?
@exp.length == 1 end
|
#setup? ⇒ Boolean
66
67
68
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 66
def setup?
!empty? && Model::Call.method_name?(@exp[1], :setup)
end
|
#sexp ⇒ Object
74
75
76
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 74
def sexp
@exp
end
|
#teardown? ⇒ Boolean
70
71
72
|
# File 'lib/minitest_to_rspec/model/iter.rb', line 70
def teardown?
!empty? && Model::Call.method_name?(@exp[1], :teardown)
end
|