Class: Transpec::Syntax::OnelinerShould::OnelinerShouldHaveRecord
- Inherits:
-
Have::HaveRecord
- Object
- Record
- Have::HaveRecord
- Transpec::Syntax::OnelinerShould::OnelinerShouldHaveRecord
- Defined in:
- lib/transpec/syntax/oneliner_should.rb
Instance Attribute Summary collapse
-
#negative_form_of_to ⇒ Object
readonly
Returns the value of attribute negative_form_of_to.
-
#should ⇒ Object
readonly
Returns the value of attribute should.
Attributes inherited from Have::HaveRecord
Attributes inherited from Record
Instance Method Summary collapse
- #converted_description ⇒ Object
- #converted_expectation ⇒ Object
- #converted_subject ⇒ Object
- #converted_syntax ⇒ Object
-
#initialize(should, have, negative_form_of_to = nil) ⇒ OnelinerShouldHaveRecord
constructor
A new instance of OnelinerShouldHaveRecord.
- #original_syntax ⇒ Object
Methods inherited from Have::HaveRecord
Methods inherited from Record
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
#negative_form_of_to ⇒ Object (readonly)
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 (readonly)
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 |