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.0.10 spec/support/field_matcher.rb
netsuite-0.0.9 spec/support/field_matcher.rb
netsuite-0.0.8 spec/support/field_matcher.rb
netsuite-0.0.7 spec/support/field_matcher.rb
netsuite-0.0.6 spec/support/field_matcher.rb
netsuite-0.0.5 spec/support/field_matcher.rb
netsuite-0.0.4 spec/support/field_matcher.rb