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 +4 -4
- data/.travis.yml +2 -1
- data/Gemfile.lock +1 -1
- data/lib/active_record_samplooper.rb +2 -2
- data/lib/active_record_samplooper/version.rb +1 -1
- data/spec/models/sample_model_spec.rb +4 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edebddabcb8d0f99e3b1023410db3374a7df84a3
|
4
|
+
data.tar.gz: 00460ad5ffeda8801cdc44742b9a14e99e0a4fa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
@@ -47,7 +47,7 @@ module ActiveRecordSamplooper
|
|
47
47
|
|
48
48
|
def init!
|
49
49
|
self.id_store = klass.pluck(:id).shuffle!
|
50
|
-
|
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
|
|
@@ -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.
|
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-
|
11
|
+
date: 2015-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|