Sha256: 38642623fe8f7951e517ae6a01d56c34fe8c962e5eb225f89617c9b49b91be52

Contents?: true

Size: 526 Bytes

Versions: 107

Compression:

Stored size: 526 Bytes

Contents

RSpec::Matchers.define :have_field do |attribute|

  match do |model|
    field_can_be_set_and_retrieved?(model, attribute) && field_can_be_set_on_instantiation?(model, attribute)
  end

  def field_can_be_set_and_retrieved?(model, attribute)
    obj = Object.new
    model.send("#{attribute}=".to_sym, obj)
    model.send(attribute) == obj
  end

  def field_can_be_set_on_instantiation?(model, attribute)
    obj = Object.new
    new_model = model.class.new(attribute => obj)
    new_model.send(attribute) == obj
  end

end

Version data entries

107 entries across 107 versions & 1 rubygems

Version Path
netsuite-0.2.0 spec/support/field_matcher.rb
netsuite-0.1.0 spec/support/field_matcher.rb
netsuite-0.0.50 spec/support/field_matcher.rb
netsuite-0.0.49 spec/support/field_matcher.rb
netsuite-0.0.48 spec/support/field_matcher.rb
netsuite-0.0.47 spec/support/field_matcher.rb
netsuite-0.0.45 spec/support/field_matcher.rb
netsuite-0.0.44 spec/support/field_matcher.rb
netsuite-0.0.43 spec/support/field_matcher.rb
netsuite-0.0.42 spec/support/field_matcher.rb
netsuite-0.0.41 spec/support/field_matcher.rb
netsuite-0.0.40 spec/support/field_matcher.rb
netsuite-0.0.39 spec/support/field_matcher.rb
netsuite-0.0.38 spec/support/field_matcher.rb
netsuite-0.0.37 spec/support/field_matcher.rb
netsuite-0.0.36 spec/support/field_matcher.rb
netsuite-0.0.35 spec/support/field_matcher.rb
netsuite-0.0.34 spec/support/field_matcher.rb
netsuite-0.0.33 spec/support/field_matcher.rb
netsuite-0.0.32 spec/support/field_matcher.rb