Class: Transpec::Syntax::Should::RecordBuilder

Inherits:
RecordBuilder show all
Defined in:
lib/transpec/syntax/should.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from RecordBuilder

build, #build

Constructor Details

#initialize(should, negative_form_of_to) ⇒ RecordBuilder

Returns a new instance of RecordBuilder.



74
75
76
77
# File 'lib/transpec/syntax/should.rb', line 74

def initialize(should, negative_form_of_to)
  @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.



72
73
74
# File 'lib/transpec/syntax/should.rb', line 72

def negative_form_of_to
  @negative_form_of_to
end

#should ⇒ Object (readonly)

Returns the value of attribute should.



72
73
74
# File 'lib/transpec/syntax/should.rb', line 72

def should
  @should
end

Instance Method Details

#new_syntax ⇒ Object



90
91
92
93
94
95
96
97
98
# File 'lib/transpec/syntax/should.rb', line 90

def new_syntax
  syntax = if should.proc_subject?
             'expect { }.'
           else
             'expect(obj).'
           end

  syntax << (should.positive? ? 'to' : negative_form_of_to)
end

#old_syntax ⇒ Object



79
80
81
82
83
84
85
86
87
88
# File 'lib/transpec/syntax/should.rb', line 79

def old_syntax
  syntax = if should.proc_subject?
             "#{should.name_of_subject_method_taking_block} { }.should"
           else
             'obj.should'
           end

  syntax << '_not' unless should.positive?
  syntax
end