File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ describe Injectable ::ClassMethods do
2+ describe '#simple_class_attribute' do
3+ subject ( :klass ) do
4+ Class . new do
5+ include Injectable
6+
7+ def self . singleton_class?
8+ true
9+ end
10+
11+ class_eval do
12+ simple_class_attribute :flag
13+ end
14+
15+ def call
16+ 'jarl'
17+ end
18+ end
19+ end
20+
21+ it 'defines instance reader delegating to singleton reader when singleton_class?' do
22+ klass . flag = 'on'
23+ expect ( klass . flag ) . to eq ( 'on' )
24+ end
25+
26+ it 'passes the singleton class attribute value to the instances' do
27+ klass . flag = 'on'
28+ instance = klass . new
29+ expect ( instance . flag ) . to eq ( 'on' )
30+ end
31+
32+ it 'allows to modify attribute value on the instance' , skip : 'Failing, need to investigate' do
33+ instance = klass . new
34+ instance . instance_variable_set ( '@flag' , 'local' )
35+ expect ( instance . flag ) . to eq ( 'local' )
36+ end
37+
38+ it 'does not pass instance values up to the singleton class value' do
39+ klass . flag = 'on'
40+ instance = klass . new
41+ instance . instance_variable_set ( '@flag' , 'local' )
42+ expect ( klass . flag ) . to eq 'on'
43+ end
44+ end
45+ end
You can’t perform that action at this time.
0 commit comments