active_record_samplooper 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: 1f6520d84d931e0a006a6f52cb97f6891c098396
4
- data.tar.gz: 78970ac41e0551eb96cb6837ab614c009f51b691
3
+ metadata.gz: edebddabcb8d0f99e3b1023410db3374a7df84a3
4
+ data.tar.gz: 00460ad5ffeda8801cdc44742b9a14e99e0a4fa1
5
5
  SHA512:
6
- metadata.gz: c5522057491651ba49888a06e112af13b16006761e9fad23ef885a6ecef71efbbb324c5576ef204e430c81ca63730ee9cf72115439b0f41b94df0bfcf12b0f4e
7
- data.tar.gz: a37ea8835a03a14ba6926f5cc3962ecff77354a58a654a0c8a7cd7196eea5eb8c77a113769e8a89ca61d7b9c7c661e6b64fefcb905b6add294836205ce1c7cbe
6
+ metadata.gz: 77d0d17c3d8bee4bae8395d6501a66ce2232de391dfd6d828b4cf276d0313d628df371ed2fd183a03a74380b50fbef0909a84ed98deb912fcd65394cc32480e8
7
+ data.tar.gz: 5b15e0a17a67a22363b90c1876e2e773492996477a2c7ed2595c11da39006b185144762c1bf40aeeb889bcea7289d1d74e0bc03a58334ca5f38254dd01655688
data/.travis.yml CHANGED
@@ -8,7 +8,7 @@ env:
8
8
  before_install:
9
9
  - gem install bundler -v 1.10.3
10
10
  install:
11
- - bundle install --without production --deployment
11
+ - bundle install
12
12
  cache:
13
13
  directories:
14
14
  - vendor/bundle
@@ -16,6 +16,7 @@ before_script:
16
16
  - cp spec/dummy/config/database.def.yml spec/dummy/config/database.yml
17
17
  script:
18
18
  - cd spec/dummy
19
+ - bundle install
19
20
  - bundle exec rake db:create RAILS_ENV=test
20
21
  - bundle exec rake db:migrate RAILS_ENV=test
21
22
  - bundle exec rake db:test:prepare
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_record_samplooper (0.0.1)
4
+ active_record_samplooper (0.0.2)
5
5
  rails (~> 4.2.1)
6
6
 
7
7
  GEM
@@ -47,7 +47,7 @@ module ActiveRecordSamplooper
47
47
 
48
48
  def init!
49
49
  self.id_store = klass.pluck(:id).shuffle!
50
- self.rest = id_store.dup
50
+ reset!
51
51
  end
52
52
 
53
53
 
@@ -69,7 +69,7 @@ end
69
69
  class ::ActiveRecord::Base
70
70
  class << self
71
71
  def sample
72
- offset(rand(count)).first
72
+ offset(rand(count(:all))).first
73
73
  end
74
74
 
75
75
 
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordSamplooper
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -18,6 +18,10 @@ RSpec.describe SampleModel, type: :model do
18
18
  it 'any times, get SampleModel instance' do
19
19
  36.times { expect(SampleModel.sample).to be_a(SampleModel) }
20
20
  end
21
+
22
+ it 'get SampleModel instance from relation' do
23
+ expect(SampleModel.select(:id, :name).sample).to be_a(SampleModel)
24
+ end
21
25
  end
22
26
 
23
27
 
@@ -65,7 +69,6 @@ RSpec.describe SampleModel, type: :model do
65
69
  sampler
66
70
  new_id = create(:sample_model).id
67
71
  1000.times { expect(sampler.sample.id).not_to eq(new_id) }
68
- SampleModel.destroy(new_id)
69
72
  end
70
73
  end
71
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_samplooper
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
  - mmmpa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-24 00:00:00.000000000 Z
11
+ date: 2015-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails