rails_static_record 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/static_record/base.rb +9 -0
- data/lib/static_record/errors.rb +2 -0
- data/lib/static_record/gateway_model.rb +47 -1
- data/lib/static_record/loader_file.rb +4 -0
- data/lib/static_record/version.rb +1 -1
- data/spec/dummy/app/models/category.rb +1 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +2 -0
- data/spec/dummy/log/test.log +1243 -0
- data/spec/dummy/spec/models/test_spec.rb +0 -4
- data/spec/spec_helper.rb +47 -49
- data/spec/static_record_spec.rb +36 -7
- metadata +5 -1
data/spec/spec_helper.rb
CHANGED
@@ -47,53 +47,51 @@ RSpec.configure do |config|
|
|
47
47
|
# triggering implicit auto-inclusion in groups with matching metadata.
|
48
48
|
config.shared_context_metadata_behavior = :apply_to_host_groups
|
49
49
|
|
50
|
-
# The settings below are suggested to provide a good initial experience
|
51
|
-
# with RSpec, but feel free to customize to your heart's content.
|
52
|
-
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
|
59
|
-
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
|
64
|
-
|
65
|
-
#
|
66
|
-
#
|
67
|
-
# - http://
|
68
|
-
# - http://
|
69
|
-
#
|
70
|
-
|
71
|
-
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
|
86
|
-
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
|
92
|
-
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
Kernel.srand config.seed
|
98
|
-
=end
|
50
|
+
# The settings below are suggested to provide a good initial experience
|
51
|
+
# with RSpec, but feel free to customize to your heart's content.
|
52
|
+
# # This allows you to limit a spec run to individual examples or groups
|
53
|
+
# # you care about by tagging them with `:focus` metadata. When nothing
|
54
|
+
# # is tagged with `:focus`, all examples get run. RSpec also provides
|
55
|
+
# # aliases for `it`, `describe`, and `context` that include `:focus`
|
56
|
+
# # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
57
|
+
# config.filter_run_when_matching :focus
|
58
|
+
#
|
59
|
+
# # Allows RSpec to persist some state between runs in order to support
|
60
|
+
# # the `--only-failures` and `--next-failure` CLI options. We recommend
|
61
|
+
# # you configure your source control system to ignore this file.
|
62
|
+
# config.example_status_persistence_file_path = "spec/examples.txt"
|
63
|
+
#
|
64
|
+
# # Limits the available syntax to the non-monkey patched syntax that is
|
65
|
+
# # recommended. For more details, see:
|
66
|
+
# # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
67
|
+
# # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
68
|
+
# # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
69
|
+
# config.disable_monkey_patching!
|
70
|
+
#
|
71
|
+
# # Many RSpec users commonly either run the entire suite or an individual
|
72
|
+
# # file, and it's useful to allow more verbose output when running an
|
73
|
+
# # individual spec file.
|
74
|
+
# if config.files_to_run.one?
|
75
|
+
# # Use the documentation formatter for detailed output,
|
76
|
+
# # unless a formatter has already been configured
|
77
|
+
# # (e.g. via a command-line flag).
|
78
|
+
# config.default_formatter = 'doc'
|
79
|
+
# end
|
80
|
+
#
|
81
|
+
# # Print the 10 slowest examples and example groups at the
|
82
|
+
# # end of the spec run, to help surface which specs are running
|
83
|
+
# # particularly slow.
|
84
|
+
# config.profile_examples = 10
|
85
|
+
#
|
86
|
+
# # Run specs in random order to surface order dependencies. If you find an
|
87
|
+
# # order dependency and want to debug it, you can fix the order by providing
|
88
|
+
# # the seed, which is printed after each run.
|
89
|
+
# # --seed 1234
|
90
|
+
# config.order = :random
|
91
|
+
#
|
92
|
+
# # Seed global randomization in this process using the `--seed` CLI option.
|
93
|
+
# # Setting this allows you to use `--seed` to deterministically reproduce
|
94
|
+
# # test failures related to randomization by passing the same `--seed` value
|
95
|
+
# # as the one that triggered the failure.
|
96
|
+
# Kernel.srand config.seed
|
99
97
|
end
|
data/spec/static_record_spec.rb
CHANGED
@@ -1,21 +1,50 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
describe StaticRecord do
|
4
|
-
subject(:base) { StaticRecord::Base.new }
|
5
|
-
|
6
4
|
describe 'configuration and first instance' do
|
7
5
|
it 'should get the default path for static db' do
|
8
|
-
expect(StaticRecord::Base.file_path).to
|
6
|
+
expect(StaticRecord::Base.file_path).to match(/\/db\/static$/)
|
9
7
|
end
|
10
8
|
|
11
9
|
it 'should do set a custom path for static db' do
|
12
|
-
StaticRecord::Base.file_path =
|
10
|
+
StaticRecord::Base.file_path = File.join(Rails.root, 'db', 'test')
|
11
|
+
|
12
|
+
expect(StaticRecord::Base.file_path).to match(/\/db\/test$/)
|
13
|
+
|
14
|
+
# Reset it to default valule for the test.
|
15
|
+
StaticRecord::Base.file_path = File.join(Rails.root, 'db', 'static')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should initialize category model with 3 attributes' do
|
19
|
+
category = Category.new id: 909, title: 'Test Category', uuid: 99.0
|
20
|
+
|
21
|
+
expect(category.attributes).to include(id: 909,
|
22
|
+
title: 'Test Category',
|
23
|
+
uuid: 99.0)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'class methods for categories test model' do
|
28
|
+
it 'should has 26 elements' do
|
29
|
+
expect(Category.count).to eq(26)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should get 3 categories' do
|
33
|
+
categories = Category.find 1, 5, 16
|
34
|
+
|
35
|
+
expect(categories.count).to eq(3)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'raise error when find_by arguments are not a hash' do
|
39
|
+
expect { Category.find_by(1) }.to raise_error(StaticRecord::InvalidParameterError)
|
40
|
+
end
|
13
41
|
|
14
|
-
|
42
|
+
it 'should return the first item in the data when is called first method' do
|
43
|
+
expect(Category.first.id).to eq(1)
|
15
44
|
end
|
16
45
|
|
17
|
-
it 'should
|
18
|
-
expect(
|
46
|
+
it 'should get the second item in the data when is called second method' do
|
47
|
+
expect(Category.second.id).to eq(2)
|
19
48
|
end
|
20
49
|
end
|
21
50
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_static_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateo Olaya Bernal
|
@@ -130,7 +130,9 @@ files:
|
|
130
130
|
- spec/dummy/db/migrate/20161016220221_create_tests.rb
|
131
131
|
- spec/dummy/db/schema.rb
|
132
132
|
- spec/dummy/db/static/categories.yml
|
133
|
+
- spec/dummy/db/test.sqlite3
|
133
134
|
- spec/dummy/log/development.log
|
135
|
+
- spec/dummy/log/test.log
|
134
136
|
- spec/dummy/public/404.html
|
135
137
|
- spec/dummy/public/422.html
|
136
138
|
- spec/dummy/public/500.html
|
@@ -217,7 +219,9 @@ test_files:
|
|
217
219
|
- spec/dummy/db/migrate/20161016220221_create_tests.rb
|
218
220
|
- spec/dummy/db/schema.rb
|
219
221
|
- spec/dummy/db/static/categories.yml
|
222
|
+
- spec/dummy/db/test.sqlite3
|
220
223
|
- spec/dummy/log/development.log
|
224
|
+
- spec/dummy/log/test.log
|
221
225
|
- spec/dummy/public/404.html
|
222
226
|
- spec/dummy/public/422.html
|
223
227
|
- spec/dummy/public/500.html
|