Class: Transpec::Syntax::OnelinerShould::OnelinerShouldHaveRecord
Instance Attribute Summary collapse
#have
Instance Method Summary
collapse
#build_converted_subject, #build_expectation, #converted_owner_of_collection, #original_items, #original_subject, #positive?, #source_builder
Methods inherited from Record
#==, #hash, #to_s
Constructor Details
#initialize(should, have, negative_form_of_to = nil) ⇒ OnelinerShouldHaveRecord
Returns a new instance of OnelinerShouldHaveRecord.
166
167
168
169
170
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 166
def initialize(should, have, negative_form_of_to = nil)
super(have)
@should = should
@negative_form_of_to = negative_form_of_to
end
|
Instance Attribute Details
Returns the value of attribute negative_form_of_to.
164
165
166
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 164
def negative_form_of_to
@negative_form_of_to
end
|
#should ⇒ Object
Returns the value of attribute should.
164
165
166
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 164
def should
@should
end
|
Instance Method Details
#converted_description ⇒ Object
191
192
193
194
195
196
197
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 191
def converted_description
if should.example_has_description?
"it '...' do"
else
"it '#{should.build_description('n')}' do"
end
end
|
#converted_expectation ⇒ Object
199
200
201
202
203
204
205
206
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 199
def converted_expectation
case should.current_syntax_type
when :should
"#{converted_subject}.#{should.method_name}"
when :expect
"expect(#{converted_subject})." + (should.positive? ? 'to' : negative_form_of_to)
end
end
|
#converted_subject ⇒ Object
208
209
210
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 208
def converted_subject
build_converted_subject('subject')
end
|
#converted_syntax ⇒ Object
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 180
def converted_syntax
@converted_syntax ||= begin
syntax = converted_description
syntax << ' '
syntax << converted_expectation
syntax << ' '
syntax << source_builder.replacement_matcher_source
syntax << ' end'
end
end
|
#original_syntax ⇒ Object
172
173
174
175
176
177
178
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 172
def original_syntax
@original_syntax ||= begin
syntax = should.example_has_description? ? "it '...' do" : 'it {'
syntax << " #{should.method_name} #{have.method_name}(n).#{original_items} "
syntax << (should.example_has_description? ? 'end' : '}')
end
end
|