Class: Transpec::Syntax::Have::HaveRecord
- Defined in:
- lib/transpec/syntax/have.rb
Instance Method Summary collapse
- #converted_subject ⇒ Object
- #converted_syntax ⇒ Object
-
#initialize(have) ⇒ HaveRecord
constructor
A new instance of HaveRecord.
- #original_items ⇒ Object
- #original_subject ⇒ Object
- #original_syntax ⇒ Object
Methods inherited from Record
Constructor Details
#initialize(have) ⇒ HaveRecord
Returns a new instance of HaveRecord.
173 174 175 |
# File 'lib/transpec/syntax/have.rb', line 173 def initialize(have) @have = have end |
Instance Method Details
#converted_subject ⇒ Object
219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/transpec/syntax/have.rb', line 219 def converted_subject if @have.subject_is_owner_of_collection? if @have.collection_accessor_is_private? "obj.send(#{@have.items_name.inspect}).#{@have.query_method}" else "obj.#{@have.items_name}.#{@have.query_method}" end else "collection.#{@have.default_query_method}" end end |
#converted_syntax ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/transpec/syntax/have.rb', line 190 def converted_syntax @converted_syntax ||= begin syntax = case @have.expectation.current_syntax_type when :should "#{converted_subject}.should" when :expect "expect(#{converted_subject}).to" end syntax << " #{@have.replacement_matcher_source('n')}" end end |
#original_items ⇒ Object
211 212 213 214 215 216 217 |
# File 'lib/transpec/syntax/have.rb', line 211 def original_items if @have.subject_is_owner_of_collection? @have.items_name else 'items' end end |
#original_subject ⇒ Object
203 204 205 206 207 208 209 |
# File 'lib/transpec/syntax/have.rb', line 203 def original_subject if @have.subject_is_owner_of_collection? 'obj' else 'collection' end end |
#original_syntax ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/transpec/syntax/have.rb', line 177 def original_syntax @original_syntax ||= begin syntax = case @have.expectation when Should "#{original_subject}.should" when Expect "expect(#{original_subject}).to" end syntax << " #{@have.have_method_name}(n).#{original_items}" end end |