Class: Transpec::Syntax::OnelinerShould::HaveRecordBuilder
Instance Method Summary
collapse
#annotation, #build_expectation, #build_new_subject, #new_owner_of_collection, #old_items, #old_subject, #positive?, #source_builder
build, #build, param_names
Instance Method Details
#new_description ⇒ Object
161
162
163
164
165
166
167
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 161
def new_description
if should.example.description?
"it '...' do"
else
"it '#{should.build_description('n')}' do"
end
end
|
#new_expectation ⇒ Object
169
170
171
172
173
174
175
176
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 169
def new_expectation
case should.current_syntax_type
when :should
"#{new_subject}.#{should.method_name}"
when :expect
"expect(#{new_subject})." + (should.positive? ? 'to' : negative_form_of_to)
end
end
|
#new_subject ⇒ Object
178
179
180
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 178
def new_subject
build_new_subject('subject')
end
|
#new_syntax ⇒ Object
152
153
154
155
156
157
158
159
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 152
def new_syntax
syntax = new_description
syntax << ' '
syntax << new_expectation
syntax << ' '
syntax << source_builder.replacement_matcher_source
syntax << ' end'
end
|
#old_syntax ⇒ Object
146
147
148
149
150
|
# File 'lib/transpec/syntax/oneliner_should.rb', line 146
def old_syntax
syntax = should.example.description? ? "it '...' do" : 'it {'
syntax << " #{should.method_name} #{have.method_name}(n).#{old_items} "
syntax << (should.example.description? ? 'end' : '}')
end
|