time_for_a_boolean 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b911b8e5eb898861b4bd685d9cca9077c24d2ac3
4
- data.tar.gz: 4b608bfe50aad84b8db5de8420acb6652eb2dd56
3
+ metadata.gz: 26332da2835fdd1d1ccdd0d65721aea37327a29f
4
+ data.tar.gz: 0f8f8f69c3dd56a234a1ad1420e4e3c0a0f83982
5
5
  SHA512:
6
- metadata.gz: 3de77ccb1b78cf796faee950ef48f9593e7890480ba6407a0332ac6e13e5e64c48426f7be82f47fa6c2e7bf9828081e420f01300464a5098e0e5a4b82eefbc62
7
- data.tar.gz: 28e4d3a903284312c50a1f4c69c474b39eb6114ae1f905a96d74ccbb580f73aa2f70f9468e46d894161c074a4caac29725ccec1af5bc809aaa0129e4d0f9f416
6
+ metadata.gz: 1490cd3fc6b4b3dc779df13307203929a899fb0f0b0d761a0b91aa810ffe22d0c777199984425364dd2e3d7fe3784bfd2196dae3455007dcd0a70a6316b23ab5
7
+ data.tar.gz: bfa8129fedc1befc242375792de263b43e477f551bc178c82c174e14bfbdcc749068d65cb500440489a381108262e223f733b1038bb86523545b3432f0deee65
@@ -1,3 +1,3 @@
1
1
  module TimeForABoolean
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -6,12 +6,12 @@ module TimeForABoolean
6
6
  def time_for_a_boolean(attribute)
7
7
  define_method(attribute) do
8
8
  !send("#{attribute}_at").nil? &&
9
- send("#{attribute}_at") <= -> { DateTime.now }.()
9
+ send("#{attribute}_at") <= -> { DateTime.current }.()
10
10
  end
11
11
  alias_method "#{attribute}?", attribute
12
12
  define_method("#{attribute}=") do |value|
13
13
  if value
14
- send("#{attribute}_at=", -> { DateTime.now }.())
14
+ send("#{attribute}_at=", -> { DateTime.current }.())
15
15
  else
16
16
  send("#{attribute}_at=", nil)
17
17
  end
@@ -26,7 +26,7 @@ describe TimeForABoolean do
26
26
  it 'calls nil? on the backing timestamp' do
27
27
  klass.time_for_a_boolean :attribute
28
28
  timestamp = double(nil?: true)
29
- object.stub(attribute_at: timestamp)
29
+ allow(object).to receive(:attribute_at).and_return(timestamp)
30
30
 
31
31
  object.attribute
32
32
 
@@ -35,23 +35,23 @@ describe TimeForABoolean do
35
35
 
36
36
  it 'is true if the attribute is not nil' do
37
37
  klass.time_for_a_boolean :attribute
38
- object.stub(attribute_at: DateTime.now - 10)
38
+ allow(object).to receive(:attribute_at).and_return(DateTime.now - 10)
39
39
 
40
- expect(object.attribute).to be_true
40
+ expect(object.attribute).to be_truthy
41
41
  end
42
42
 
43
43
  it 'is false if the attribute is nil' do
44
44
  klass.time_for_a_boolean :attribute
45
- object.stub(attribute_at: nil)
45
+ allow(object).to receive(:attribute_at)
46
46
 
47
- expect(object.attribute).to be_false
47
+ expect(object.attribute).to be_falsey
48
48
  end
49
49
 
50
50
  it 'is false if the attribute time is in the future' do
51
51
  klass.time_for_a_boolean :attribute
52
- object.stub(attribute_at: Time.now + 86400) # one day in the future
52
+ allow(object).to receive(:attribute_at).and_return(Time.now + 86400) # one day in the future
53
53
 
54
- expect(object.attribute).to be_false
54
+ expect(object.attribute).to be_falsey
55
55
  end
56
56
  end
57
57
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_for_a_boolean
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Thompson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-28 00:00:00.000000000 Z
11
+ date: 2014-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails