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.31 spec/support/field_matcher.rb
netsuite-0.0.30 spec/support/field_matcher.rb
netsuite-0.0.29 spec/support/field_matcher.rb
netsuite-0.0.28 spec/support/field_matcher.rb
netsuite-0.0.27 spec/support/field_matcher.rb
netsuite-0.0.26 spec/support/field_matcher.rb
netsuite-0.0.25 spec/support/field_matcher.rb
netsuite-0.0.23 spec/support/field_matcher.rb
netsuite-0.0.22 spec/support/field_matcher.rb
netsuite-0.0.21 spec/support/field_matcher.rb
netsuite-0.0.20 spec/support/field_matcher.rb
netsuite-0.0.19 spec/support/field_matcher.rb
netsuite-0.0.18 spec/support/field_matcher.rb
netsuite-0.0.17 spec/support/field_matcher.rb
netsuite-0.0.16 spec/support/field_matcher.rb
netsuite-0.0.15 spec/support/field_matcher.rb
netsuite-0.0.14 spec/support/field_matcher.rb
netsuite-0.0.13 spec/support/field_matcher.rb
netsuite-0.0.12 spec/support/field_matcher.rb
netsuite-0.0.11 spec/support/field_matcher.rb