File: shared_examples.rb

package info (click to toggle)
ruby-hashie 5.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 884 kB
  • sloc: ruby: 7,049; sh: 8; makefile: 6
file content (26 lines) | stat: -rw-r--r-- 753 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
RSpec.shared_examples 'Dash default handling' do |property, name = property|
  it 'uses the default when initializing' do
    expect(test.new(name => nil).public_send(property)).to eq ''
  end

  it 'allows you to set the value to nil with the hash writer' do
    trash = test.new(name => 'foo')
    trash[name] = nil

    expect(trash.public_send(property)).to be_nil
  end

  it 'allows you to set the value to nil with the method writer' do
    trash = test.new(name => 'foo')
    trash[name] = nil

    expect(trash.public_send(property)).to be_nil
  end

  it 'uses the default when updating with defaults' do
    trash = test.new(name => 'foo')
    trash.update_attributes!(name => nil)

    expect(trash.public_send(property)).to eq ''
  end
end