microscope 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/microscope/instance_method.rb +5 -0
- data/lib/microscope/instance_method/date_instance_method.rb +8 -0
- data/lib/microscope/instance_method/datetime_instance_method.rb +8 -0
- data/lib/microscope/version.rb +1 -1
- data/spec/microscope/instance_method/date_instance_method_spec.rb +18 -0
- data/spec/microscope/instance_method/datetime_instance_method_spec.rb +18 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7602cb25b5b12f243c0380bb3f66a8d126bc0d53
|
4
|
+
data.tar.gz: 592d56ccc94f58eccfbae50646beb09f7b06547e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da0941107f2b282149fbb7321d7cf402aa354b4407657b3cf57d3f2dbebb88f6f255bbb6a21f9d5692fbc3fdc3659a5ad75e7b7c611871f8306cc188d7a30933
|
7
|
+
data.tar.gz: 0b78e8dfb69a15ebf94759b503d1c8ff1f00b7d7c1de145efd227ebf3694ed6778930ef4158e19bdac81e0e1672ed987fe4a1e11fe87ffc5ec54f6a2987ccdff
|
@@ -11,6 +11,14 @@ module Microscope
|
|
11
11
|
!value.nil? && value <= Date.today
|
12
12
|
end
|
13
13
|
|
14
|
+
define_method "#{cropped_field}=" do |value|
|
15
|
+
if Microscope::InstanceMethod.value_to_boolean(value)
|
16
|
+
self.#{field.name} = Date.today
|
17
|
+
else
|
18
|
+
self.#{field.name} = nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
14
22
|
define_method "not_#{cropped_field}?" do
|
15
23
|
!#{cropped_field}?
|
16
24
|
end
|
@@ -11,6 +11,14 @@ module Microscope
|
|
11
11
|
!value.nil? && value <= Time.now
|
12
12
|
end
|
13
13
|
|
14
|
+
define_method "#{cropped_field}=" do |value|
|
15
|
+
if Microscope::InstanceMethod.value_to_boolean(value)
|
16
|
+
self.#{field.name} = Time.now
|
17
|
+
else
|
18
|
+
self.#{field.name} = nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
14
22
|
define_method "not_#{cropped_field}?" do
|
15
23
|
!#{cropped_field}?
|
16
24
|
end
|
data/lib/microscope/version.rb
CHANGED
@@ -25,6 +25,24 @@ describe Microscope::InstanceMethod::DateInstanceMethod do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
describe '#started=' do
|
29
|
+
before { subject.started = value }
|
30
|
+
|
31
|
+
context 'with present argument' do
|
32
|
+
subject { Event.create(started_on: 2.months.ago) }
|
33
|
+
let(:value) { '0' }
|
34
|
+
|
35
|
+
it { should_not be_started }
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'with blank argument' do
|
39
|
+
subject { Event.create }
|
40
|
+
let(:value) { '1' }
|
41
|
+
|
42
|
+
it { should be_started }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
28
46
|
describe '#not_started?' do
|
29
47
|
context 'with negative result' do
|
30
48
|
subject { Event.create(started_on: 2.months.ago) }
|
@@ -5,7 +5,6 @@ describe Microscope::InstanceMethod::DatetimeInstanceMethod do
|
|
5
5
|
run_migration do
|
6
6
|
create_table(:events, force: true) do |t|
|
7
7
|
t.datetime :started_at, default: nil
|
8
|
-
t.datetime :featured_at, default: nil
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
@@ -24,6 +23,24 @@ describe Microscope::InstanceMethod::DatetimeInstanceMethod do
|
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
26
|
+
describe '#started=' do
|
27
|
+
before { subject.started = value }
|
28
|
+
|
29
|
+
context 'with present argument' do
|
30
|
+
subject { Event.create(started_at: 2.months.ago) }
|
31
|
+
let(:value) { '0' }
|
32
|
+
|
33
|
+
it { should_not be_started }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'with blank argument' do
|
37
|
+
subject { Event.create }
|
38
|
+
let(:value) { '1' }
|
39
|
+
|
40
|
+
it { should be_started }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
27
44
|
describe '#not_started?' do
|
28
45
|
context 'with negative result' do
|
29
46
|
subject { Event.create(started_at: 2.months.ago) }
|
@@ -43,6 +60,5 @@ describe Microscope::InstanceMethod::DatetimeInstanceMethod do
|
|
43
60
|
let(:event) { Event.create(started_at: nil) }
|
44
61
|
it { expect { event.start! }.to change { event.reload.started_at }.from(nil).to(stubbed_date) }
|
45
62
|
it { expect(event).to respond_to(:start!) }
|
46
|
-
it { expect(event).to respond_to(:feature!) }
|
47
63
|
end
|
48
64
|
end
|