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.6.9 spec/support/field_matcher.rb
netsuite-0.6.8 spec/support/field_matcher.rb
netsuite-0.6.7 spec/support/field_matcher.rb
netsuite-0.6.6 spec/support/field_matcher.rb
netsuite-0.6.5 spec/support/field_matcher.rb
netsuite-0.6.4 spec/support/field_matcher.rb
netsuite-0.6.3 spec/support/field_matcher.rb
netsuite-0.6.2 spec/support/field_matcher.rb
netsuite-0.6.1 spec/support/field_matcher.rb
netsuite-0.6.0 spec/support/field_matcher.rb
netsuite-0.5.9 spec/support/field_matcher.rb
netsuite-0.5.8 spec/support/field_matcher.rb
netsuite-0.5.7 spec/support/field_matcher.rb
netsuite-0.5.6 spec/support/field_matcher.rb
netsuite-0.5.5 spec/support/field_matcher.rb
netsuite-0.5.4 spec/support/field_matcher.rb
netsuite-0.5.3 spec/support/field_matcher.rb
netsuite-0.5.2 spec/support/field_matcher.rb
netsuite-0.5.1 spec/support/field_matcher.rb
netsuite-0.5.0 spec/support/field_matcher.rb