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.8.9 spec/support/field_matcher.rb
netsuite-0.8.8 spec/support/field_matcher.rb
netsuite-0.8.7 spec/support/field_matcher.rb
netsuite-0.8.6 spec/support/field_matcher.rb
netsuite-0.8.5 spec/support/field_matcher.rb
netsuite-0.8.4 spec/support/field_matcher.rb
netsuite-0.8.3 spec/support/field_matcher.rb
netsuite-0.8.2 spec/support/field_matcher.rb
netsuite-0.8.1 spec/support/field_matcher.rb
netsuite-0.8.0 spec/support/field_matcher.rb
netsuite-0.7.9 spec/support/field_matcher.rb
netsuite-0.7.8 spec/support/field_matcher.rb
netsuite-0.7.7 spec/support/field_matcher.rb
netsuite-0.7.6 spec/support/field_matcher.rb
netsuite-0.7.5 spec/support/field_matcher.rb
netsuite-0.7.4 spec/support/field_matcher.rb
netsuite-0.7.3 spec/support/field_matcher.rb
netsuite-0.7.2 spec/support/field_matcher.rb
netsuite-0.7.1 spec/support/field_matcher.rb
netsuite-0.7.0 spec/support/field_matcher.rb