soulless 0.6.0 → 1.0.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.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -18
  3. data/.rspec +1 -1
  4. data/.travis.yml +7 -12
  5. data/CODE_OF_CONDUCT.md +49 -0
  6. data/Gemfile +17 -13
  7. data/LICENSE.txt +17 -18
  8. data/README.md +8 -181
  9. data/Rakefile +4 -8
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/docker-compose.yml +11 -0
  13. data/lib/soulless/attributes.rb +33 -0
  14. data/lib/soulless/callbacks.rb +13 -0
  15. data/lib/soulless/dirty.rb +10 -8
  16. data/lib/soulless/inheritance.rb +120 -124
  17. data/lib/soulless/model.rb +24 -63
  18. data/lib/soulless/validations/uniqueness_validator.rb +7 -8
  19. data/lib/soulless/validations.rb +1 -2
  20. data/lib/soulless/version.rb +1 -1
  21. data/lib/soulless.rb +5 -23
  22. data/soulless.gemspec +12 -13
  23. metadata +30 -173
  24. data/lib/soulless/accessors.rb +0 -51
  25. data/lib/soulless/associations.rb +0 -35
  26. data/lib/soulless/locale/en.yml +0 -30
  27. data/lib/soulless/railtie.rb +0 -7
  28. data/lib/soulless/validations/associated_validator.rb +0 -17
  29. data/spec/associated_validator_spec.rb +0 -31
  30. data/spec/associations_spec.rb +0 -65
  31. data/spec/dirty_spec.rb +0 -54
  32. data/spec/dummy/.gitignore +0 -17
  33. data/spec/dummy/README.rdoc +0 -28
  34. data/spec/dummy/Rakefile +0 -6
  35. data/spec/dummy/app/assets/images/.keep +0 -0
  36. data/spec/dummy/app/assets/javascripts/application.js +0 -16
  37. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  38. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  39. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  40. data/spec/dummy/app/forms/dummy_form.rb +0 -7
  41. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  42. data/spec/dummy/app/mailers/.keep +0 -0
  43. data/spec/dummy/app/models/.keep +0 -0
  44. data/spec/dummy/app/models/concerns/.keep +0 -0
  45. data/spec/dummy/app/models/dummy_model.rb +0 -6
  46. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  47. data/spec/dummy/bin/bundle +0 -3
  48. data/spec/dummy/bin/rails +0 -4
  49. data/spec/dummy/bin/rake +0 -4
  50. data/spec/dummy/config/application.rb +0 -28
  51. data/spec/dummy/config/boot.rb +0 -6
  52. data/spec/dummy/config/database.yml +0 -25
  53. data/spec/dummy/config/environment.rb +0 -5
  54. data/spec/dummy/config/environments/development.rb +0 -29
  55. data/spec/dummy/config/environments/production.rb +0 -80
  56. data/spec/dummy/config/environments/test.rb +0 -36
  57. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  58. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  59. data/spec/dummy/config/initializers/inflections.rb +0 -16
  60. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  61. data/spec/dummy/config/initializers/secret_token.rb +0 -12
  62. data/spec/dummy/config/initializers/session_store.rb +0 -3
  63. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  64. data/spec/dummy/config/locales/en.yml +0 -23
  65. data/spec/dummy/config/routes.rb +0 -56
  66. data/spec/dummy/config.ru +0 -4
  67. data/spec/dummy/db/migrate/20131106221200_create_dummy_models.rb +0 -11
  68. data/spec/dummy/db/schema.rb +0 -24
  69. data/spec/dummy/db/seeds.rb +0 -7
  70. data/spec/dummy/db/test.sqlite3 +0 -0
  71. data/spec/dummy/lib/assets/.keep +0 -0
  72. data/spec/dummy/lib/tasks/.keep +0 -0
  73. data/spec/dummy/log/.keep +0 -0
  74. data/spec/dummy/public/404.html +0 -58
  75. data/spec/dummy/public/422.html +0 -58
  76. data/spec/dummy/public/500.html +0 -57
  77. data/spec/dummy/public/favicon.ico +0 -0
  78. data/spec/dummy/public/robots.txt +0 -5
  79. data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
  80. data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
  81. data/spec/inheritance_spec.rb +0 -51
  82. data/spec/soulless_spec.rb +0 -61
  83. data/spec/spec_helper.rb +0 -38
  84. data/spec/support/dummy_association.rb +0 -30
  85. data/spec/support/dummy_class.rb +0 -20
  86. data/spec/support/dummy_model_inheritance.rb +0 -10
  87. data/spec/support/dummy_soulless_inheritance.rb +0 -10
  88. data/spec/support/en.yml +0 -8
  89. data/spec/uniqueness_validator_spec.rb +0 -17
metadata CHANGED
@@ -1,57 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soulless
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Smith
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2014-10-26 00:00:00.000000000 Z
11
+ date: 2016-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '3.2'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '3.2'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: activemodel
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: '3.2'
19
+ version: 4.2.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.1'
34
23
  type: :runtime
35
24
  prerelease: false
36
25
  version_requirements: !ruby/object:Gem::Requirement
37
26
  requirements:
38
27
  - - ">="
39
28
  - !ruby/object:Gem::Version
40
- version: '3.2'
29
+ version: 4.2.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.1'
41
33
  - !ruby/object:Gem::Dependency
42
34
  name: virtus
43
35
  requirement: !ruby/object:Gem::Requirement
44
36
  requirements:
45
- - - ">="
37
+ - - "~>"
46
38
  - !ruby/object:Gem::Version
47
- version: '1.0'
39
+ version: 1.0.0
48
40
  type: :runtime
49
41
  prerelease: false
50
42
  version_requirements: !ruby/object:Gem::Requirement
51
43
  requirements:
52
- - - ">="
44
+ - - "~>"
53
45
  - !ruby/object:Gem::Version
54
- version: '1.0'
46
+ version: 1.0.0
55
47
  - !ruby/object:Gem::Dependency
56
48
  name: bundler
57
49
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +58,6 @@ dependencies:
66
58
  - - ">="
67
59
  - !ruby/object:Gem::Version
68
60
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: database_cleaner
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
61
  - !ruby/object:Gem::Dependency
84
62
  name: rake
85
63
  requirement: !ruby/object:Gem::Requirement
@@ -98,17 +76,17 @@ dependencies:
98
76
  name: rspec
99
77
  requirement: !ruby/object:Gem::Requirement
100
78
  requirements:
101
- - - ">="
79
+ - - "~>"
102
80
  - !ruby/object:Gem::Version
103
- version: '0'
81
+ version: '3.0'
104
82
  type: :development
105
83
  prerelease: false
106
84
  version_requirements: !ruby/object:Gem::Requirement
107
85
  requirements:
108
- - - ">="
86
+ - - "~>"
109
87
  - !ruby/object:Gem::Version
110
- version: '0'
111
- description: Rails models without a database (and Rails).
88
+ version: '3.0'
89
+ description: Create Rails style models without the database (and Rails).
112
90
  email:
113
91
  - anthony@sticksnleaves.com
114
92
  executables: []
@@ -118,85 +96,25 @@ files:
118
96
  - ".gitignore"
119
97
  - ".rspec"
120
98
  - ".travis.yml"
99
+ - CODE_OF_CONDUCT.md
121
100
  - Gemfile
122
101
  - LICENSE.txt
123
102
  - README.md
124
103
  - Rakefile
104
+ - bin/console
105
+ - bin/setup
106
+ - docker-compose.yml
125
107
  - lib/soulless.rb
126
- - lib/soulless/accessors.rb
127
- - lib/soulless/associations.rb
108
+ - lib/soulless/attributes.rb
109
+ - lib/soulless/callbacks.rb
128
110
  - lib/soulless/dirty.rb
129
111
  - lib/soulless/inheritance.rb
130
- - lib/soulless/locale/en.yml
131
112
  - lib/soulless/model.rb
132
- - lib/soulless/railtie.rb
133
113
  - lib/soulless/validations.rb
134
- - lib/soulless/validations/associated_validator.rb
135
114
  - lib/soulless/validations/uniqueness_validator.rb
136
115
  - lib/soulless/version.rb
137
116
  - soulless.gemspec
138
- - spec/associated_validator_spec.rb
139
- - spec/associations_spec.rb
140
- - spec/dirty_spec.rb
141
- - spec/dummy/.gitignore
142
- - spec/dummy/README.rdoc
143
- - spec/dummy/Rakefile
144
- - spec/dummy/app/assets/images/.keep
145
- - spec/dummy/app/assets/javascripts/application.js
146
- - spec/dummy/app/assets/stylesheets/application.css
147
- - spec/dummy/app/controllers/application_controller.rb
148
- - spec/dummy/app/controllers/concerns/.keep
149
- - spec/dummy/app/forms/dummy_form.rb
150
- - spec/dummy/app/helpers/application_helper.rb
151
- - spec/dummy/app/mailers/.keep
152
- - spec/dummy/app/models/.keep
153
- - spec/dummy/app/models/concerns/.keep
154
- - spec/dummy/app/models/dummy_model.rb
155
- - spec/dummy/app/views/layouts/application.html.erb
156
- - spec/dummy/bin/bundle
157
- - spec/dummy/bin/rails
158
- - spec/dummy/bin/rake
159
- - spec/dummy/config.ru
160
- - spec/dummy/config/application.rb
161
- - spec/dummy/config/boot.rb
162
- - spec/dummy/config/database.yml
163
- - spec/dummy/config/environment.rb
164
- - spec/dummy/config/environments/development.rb
165
- - spec/dummy/config/environments/production.rb
166
- - spec/dummy/config/environments/test.rb
167
- - spec/dummy/config/initializers/backtrace_silencers.rb
168
- - spec/dummy/config/initializers/filter_parameter_logging.rb
169
- - spec/dummy/config/initializers/inflections.rb
170
- - spec/dummy/config/initializers/mime_types.rb
171
- - spec/dummy/config/initializers/secret_token.rb
172
- - spec/dummy/config/initializers/session_store.rb
173
- - spec/dummy/config/initializers/wrap_parameters.rb
174
- - spec/dummy/config/locales/en.yml
175
- - spec/dummy/config/routes.rb
176
- - spec/dummy/db/migrate/20131106221200_create_dummy_models.rb
177
- - spec/dummy/db/schema.rb
178
- - spec/dummy/db/seeds.rb
179
- - spec/dummy/db/test.sqlite3
180
- - spec/dummy/lib/assets/.keep
181
- - spec/dummy/lib/tasks/.keep
182
- - spec/dummy/log/.keep
183
- - spec/dummy/public/404.html
184
- - spec/dummy/public/422.html
185
- - spec/dummy/public/500.html
186
- - spec/dummy/public/favicon.ico
187
- - spec/dummy/public/robots.txt
188
- - spec/dummy/vendor/assets/javascripts/.keep
189
- - spec/dummy/vendor/assets/stylesheets/.keep
190
- - spec/inheritance_spec.rb
191
- - spec/soulless_spec.rb
192
- - spec/spec_helper.rb
193
- - spec/support/dummy_association.rb
194
- - spec/support/dummy_class.rb
195
- - spec/support/dummy_model_inheritance.rb
196
- - spec/support/dummy_soulless_inheritance.rb
197
- - spec/support/en.yml
198
- - spec/uniqueness_validator_spec.rb
199
- homepage: ''
117
+ homepage: https://github.com/anthonator/soulless
200
118
  licenses:
201
119
  - MIT
202
120
  metadata: {}
@@ -216,69 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
134
  version: '0'
217
135
  requirements: []
218
136
  rubyforge_project:
219
- rubygems_version: 2.2.2
137
+ rubygems_version: 2.6.7
220
138
  signing_key:
221
139
  specification_version: 4
222
- summary: Create Rails style models without the database.
223
- test_files:
224
- - spec/associated_validator_spec.rb
225
- - spec/associations_spec.rb
226
- - spec/dirty_spec.rb
227
- - spec/dummy/.gitignore
228
- - spec/dummy/README.rdoc
229
- - spec/dummy/Rakefile
230
- - spec/dummy/app/assets/images/.keep
231
- - spec/dummy/app/assets/javascripts/application.js
232
- - spec/dummy/app/assets/stylesheets/application.css
233
- - spec/dummy/app/controllers/application_controller.rb
234
- - spec/dummy/app/controllers/concerns/.keep
235
- - spec/dummy/app/forms/dummy_form.rb
236
- - spec/dummy/app/helpers/application_helper.rb
237
- - spec/dummy/app/mailers/.keep
238
- - spec/dummy/app/models/.keep
239
- - spec/dummy/app/models/concerns/.keep
240
- - spec/dummy/app/models/dummy_model.rb
241
- - spec/dummy/app/views/layouts/application.html.erb
242
- - spec/dummy/bin/bundle
243
- - spec/dummy/bin/rails
244
- - spec/dummy/bin/rake
245
- - spec/dummy/config.ru
246
- - spec/dummy/config/application.rb
247
- - spec/dummy/config/boot.rb
248
- - spec/dummy/config/database.yml
249
- - spec/dummy/config/environment.rb
250
- - spec/dummy/config/environments/development.rb
251
- - spec/dummy/config/environments/production.rb
252
- - spec/dummy/config/environments/test.rb
253
- - spec/dummy/config/initializers/backtrace_silencers.rb
254
- - spec/dummy/config/initializers/filter_parameter_logging.rb
255
- - spec/dummy/config/initializers/inflections.rb
256
- - spec/dummy/config/initializers/mime_types.rb
257
- - spec/dummy/config/initializers/secret_token.rb
258
- - spec/dummy/config/initializers/session_store.rb
259
- - spec/dummy/config/initializers/wrap_parameters.rb
260
- - spec/dummy/config/locales/en.yml
261
- - spec/dummy/config/routes.rb
262
- - spec/dummy/db/migrate/20131106221200_create_dummy_models.rb
263
- - spec/dummy/db/schema.rb
264
- - spec/dummy/db/seeds.rb
265
- - spec/dummy/db/test.sqlite3
266
- - spec/dummy/lib/assets/.keep
267
- - spec/dummy/lib/tasks/.keep
268
- - spec/dummy/log/.keep
269
- - spec/dummy/public/404.html
270
- - spec/dummy/public/422.html
271
- - spec/dummy/public/500.html
272
- - spec/dummy/public/favicon.ico
273
- - spec/dummy/public/robots.txt
274
- - spec/dummy/vendor/assets/javascripts/.keep
275
- - spec/dummy/vendor/assets/stylesheets/.keep
276
- - spec/inheritance_spec.rb
277
- - spec/soulless_spec.rb
278
- - spec/spec_helper.rb
279
- - spec/support/dummy_association.rb
280
- - spec/support/dummy_class.rb
281
- - spec/support/dummy_model_inheritance.rb
282
- - spec/support/dummy_soulless_inheritance.rb
283
- - spec/support/en.yml
284
- - spec/uniqueness_validator_spec.rb
140
+ summary: Rails models without the database (and Rails)
141
+ test_files: []
@@ -1,51 +0,0 @@
1
- module Soulless
2
- module Accessors
3
- private
4
- def init_accessors(attributes)
5
- setup_attribute_methods(attributes)
6
- define_attribute_accessors(attributes)
7
- end
8
-
9
- def setup_attribute_methods(attributes)
10
- self.class.define_attribute_methods(attributes)
11
- end
12
-
13
- def define_attribute_accessors(attributes)
14
- attributes.each do |attribute|
15
- define_reader(attribute)
16
- define_writer(attribute)
17
- end
18
- end
19
-
20
- def define_reader(attribute)
21
- self.class.send(:define_method, "#{attribute}".to_sym) do
22
- instance_variable_get("@#{attribute}")
23
- end
24
- end
25
-
26
- def define_writer(attribute)
27
- self.class.send(:define_method, "#{attribute}=".to_sym) do |value|
28
- define_dirty_writer(attribute, value)
29
- super(value)
30
- define_association_writer(attribute)
31
- end
32
- end
33
-
34
- def define_dirty_writer(attribute, value)
35
- send("#{attribute}_will_change!") unless instance_variable_get("@#{attribute}") == value
36
- end
37
-
38
- def define_association_writer(attribute)
39
- association_attributes = self.class.association_attributes
40
- if association_attributes && association_attributes.include?(attribute)
41
- association = send(attribute)
42
- return if association.nil?
43
- if association.kind_of?(Array)
44
- association.each { |child| child.parent = self }
45
- else
46
- association.parent = self
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,35 +0,0 @@
1
- module Soulless
2
- module Associations
3
- def self.included(base)
4
- base.instance_eval do
5
- @association_attributes = []
6
-
7
- class << self
8
- attr_reader :association_attributes
9
- end
10
-
11
- def has_one(name, superclass = Object, &block)
12
- klass = define_virtus_class(name, superclass, &block)
13
- send(:attribute, name, klass)
14
- end
15
-
16
- def has_many(name, superclass = Object, &block)
17
- klass = define_virtus_class(name, superclass, &block)
18
- send(:attribute, name, Array[klass])
19
- end
20
-
21
- private
22
- def define_virtus_class(name, superclass, &block)
23
- @association_attributes << name
24
- klass_name = name.to_s.singularize.classify + '_' + SecureRandom.hex
25
- klass = const_set(klass_name, Class.new(superclass))
26
- klass.send(:include, Soulless.model) unless klass.included_modules.include?(Model)
27
- klass.send(:attr_accessor, :parent)
28
- klass.instance_eval(&block) if block_given?
29
- klass.model_name.instance_variable_set(:@i18n_key, klass.model_name.i18n_key.to_s.gsub(/_[^_]+$/, '').underscore.to_sym)
30
- klass
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,30 +0,0 @@
1
- en:
2
- errors:
3
- # The default format to use in full error messages.
4
- format: "%{attribute} %{message}"
5
-
6
- # The values :model, :attribute and :value are always available for interpolation
7
- # The value :count is available when applicable. Can be used for pluralization.
8
- messages:
9
- inclusion: "is not included in the list"
10
- exclusion: "is reserved"
11
- invalid: "is invalid"
12
- confirmation: "doesn't match %{attribute}"
13
- accepted: "must be accepted"
14
- empty: "can't be empty"
15
- blank: "can't be blank"
16
- present: "must be blank"
17
- too_long: "is too long (maximum is %{count} characters)"
18
- too_short: "is too short (minimum is %{count} characters)"
19
- wrong_length: "is the wrong length (should be %{count} characters)"
20
- not_a_number: "is not a number"
21
- not_an_integer: "must be an integer"
22
- greater_than: "must be greater than %{count}"
23
- greater_than_or_equal_to: "must be greater than or equal to %{count}"
24
- equal_to: "must be equal to %{count}"
25
- less_than: "must be less than %{count}"
26
- less_than_or_equal_to: "must be less than or equal to %{count}"
27
- other_than: "must be other than %{count}"
28
- odd: "must be odd"
29
- even: "must be even"
30
- taken: "has already been taken"
@@ -1,7 +0,0 @@
1
- module Soulless
2
- class Railtie < Rails::Railtie
3
- config.after_initialize do |app|
4
- app.config.paths.add('app/forms', eager_load: true)
5
- end
6
- end
7
- end
@@ -1,17 +0,0 @@
1
- module Soulless
2
- module Validations
3
- class AssociatedValidator < ActiveModel::EachValidator
4
- def validate_each(record, attribute, value)
5
- if Array.wrap(value).reject { |r| r.valid? }.any?
6
- record.errors.add(attribute, :invalid, options.merge(value: value))
7
- end
8
- end
9
- end
10
-
11
- module ClassMethods
12
- def validates_associated(*attr_names)
13
- validates_with(AssociatedValidator, _merge_attributes(attr_names))
14
- end
15
- end
16
- end
17
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Soulless::Validations::AssociatedValidator do
4
- it 'should not be valid if has_one associations are invalid' do
5
- dummy_association = DummyAssociation.new
6
- dummy_association.spouse = { name: nil }
7
- expect(dummy_association.valid?).to eq(false)
8
- dummy_association.errors[:spouse].should include('is invalid')
9
- dummy_association.spouse.errors[:name].should include("can't be blank")
10
- end
11
-
12
- it 'should be valid if has_one associations are valid' do
13
- dummy_association = DummyAssociation.new
14
- dummy_association.spouse = { name: 'Megan' }
15
- expect(dummy_association.valid?).to eq(true)
16
- end
17
-
18
- it 'should not be valid if has_many associations are invalid' do
19
- dummy_association = DummyAssociation.new
20
- dummy_association.friends = [{ name: nil }, { name: nil }]
21
- expect(dummy_association.valid?).to eq(false)
22
- dummy_association.errors[:friends].should include('is invalid')
23
- dummy_association.friends[0].errors[:name].should include("can't be blank")
24
- end
25
-
26
- it 'should be valid if has_many associations are valid' do
27
- dummy_association = DummyAssociation.new
28
- dummy_association.friends = [{ name: 'Yaw' }, { name: 'Biff' }]
29
- expect(dummy_association.valid?).to eq(true)
30
- end
31
- end
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Soulless::Associations do
4
- before(:each) do
5
- @dummy_class = DummyAssociation.new
6
- end
7
-
8
- describe 'has_one' do
9
- it 'should allow hash values' do
10
- @dummy_class.spouse = { name: 'Megan' }
11
- @dummy_class.spouse.name.should == 'Megan'
12
- end
13
-
14
- it 'should allow a class type to be defined' do
15
- @dummy_class.dummy_clone = { name: 'Megan' }
16
- @dummy_class.dummy_clone.class.name.should match(/\ADummyAssociation::DummyClone/)
17
- end
18
-
19
- it 'should properly pull down error translations' do
20
- @dummy_class.dummy_clone = { name: nil }
21
- @dummy_class.dummy_clone.save
22
- @dummy_class.dummy_clone.errors[:name][0].should == "can't be blank"
23
- end
24
-
25
- it 'should properly pull down custom error translations' do
26
- I18n.load_path += Dir.glob(File.dirname(__FILE__) + '/support/en.yml')
27
- I18n.backend.load_translations
28
- @dummy_class.dummy_clone = { name: nil }
29
- @dummy_class.dummy_clone.save
30
- @dummy_class.dummy_clone.errors[:name][0].should == 'this is a test'
31
- end
32
-
33
- it 'should have a parent assigned during initialization' do
34
- @dummy_class = DummyAssociation.new(spouse: { name: 'Megan' })
35
- @dummy_class.spouse.parent.should == @dummy_class
36
- end
37
-
38
- it 'should have a parent assigned when set after initialization' do
39
- @dummy_class.spouse = { name: 'Megan' }
40
- @dummy_class.spouse.parent.should == @dummy_class
41
- end
42
- end
43
-
44
- describe 'has_many' do
45
- it 'should allow array values' do
46
- @dummy_class.friends = [{ name: 'Biff' }]
47
- @dummy_class.friends[0].name.should == 'Biff'
48
- end
49
-
50
- it 'should allow a class type to be defined' do
51
- @dummy_class.dummy_clones = [{ name: 'Biff' }]
52
- @dummy_class.dummy_clones[0].class.name.should match(/\ADummyAssociation::DummyClone/)
53
- end
54
-
55
- it 'should have a parent assigned during initialization' do
56
- @dummy_class = DummyAssociation.new(friends: [{ name: 'Yaw' }])
57
- @dummy_class.friends[0].parent.should == @dummy_class
58
- end
59
-
60
- it 'should have a parent assigned when set after initialization' do
61
- @dummy_class.friends = [{ name: 'Yaw' }]
62
- @dummy_class.friends[0].parent.should == @dummy_class
63
- end
64
- end
65
- end
data/spec/dirty_spec.rb DELETED
@@ -1,54 +0,0 @@
1
- describe Soulless::Dirty do
2
- before(:each) do
3
- @dummy_class = DummyClass.new
4
- end
5
-
6
- it 'should support dirty attributes' do
7
- expect(@dummy_class.respond_to?(:changed?)).to eq(true)
8
- end
9
-
10
- it 'should record attribute changes' do
11
- expect(@dummy_class.name_changed?).to eq(false)
12
- @dummy_class.name = 'Yaw'
13
- expect(@dummy_class.name_changed?).to eq(true)
14
- end
15
-
16
- it 'should correctly record changes to objects with initialized values' do
17
- @dummy_class = DummyClass.new(name: 'Biff')
18
- expect(@dummy_class.name_changed?).to eq(false)
19
- @dummy_class.name = 'Anthony'
20
- expect(@dummy_class.name_changed?).to eq(true)
21
- end
22
-
23
- it 'should record changes in a has_one association' do
24
- @dummy_association = DummyAssociation.new(spouse: { name: 'Megan' })
25
- expect(@dummy_association.spouse.name_changed?).to eq(false)
26
- @dummy_association.spouse.name = 'Megan Jr'
27
- expect(@dummy_association.spouse.name_changed?).to eq(true)
28
- end
29
-
30
- it 'should record changes in a has_many association' do
31
- @dummy_association = DummyAssociation.new(friends: [{ name: 'Yaw' }])
32
- expect(@dummy_association.friends[0].name_changed?).to eq(false)
33
- @dummy_association.friends[0].name = 'Biff'
34
- expect(@dummy_association.friends[0].name_changed?).to eq(true)
35
- end
36
-
37
- it 'should reset its dirty state when saved' do
38
- @dummy_class.name = 'Biff'
39
- @dummy_class.save
40
- expect(@dummy_class.changed?).to eq(false)
41
- end
42
-
43
- it 'should not reset its dirty state if validations fail' do
44
- @dummy_class.name = nil
45
- @dummy_class.save
46
- expect(@dummy_class.changed?).to eq(true)
47
- end
48
-
49
- it 'should record changed made before #save was called in previous_changes' do
50
- @dummy_class.name = 'Biff'
51
- @dummy_class.save
52
- expect(@dummy_class.previous_changes).to_not be_empty
53
- end
54
- end
@@ -1,17 +0,0 @@
1
- # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
- #
3
- # If you find yourself ignoring temporary files generated by your text editor
4
- # or operating system, you probably want to add a global ignore instead:
5
- # git config --global core.excludesfile '~/.gitignore_global'
6
-
7
- # Ignore bundler config.
8
- /.bundle
9
-
10
- # Ignore the default SQLite database.
11
- /db/development.sqlite3
12
- /db/production.sqlite3
13
- /db/*.sqlite3-journal
14
-
15
- # Ignore all logfiles and tempfiles.
16
- /log/*.log
17
- /tmp
@@ -1,28 +0,0 @@
1
- == README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
data/spec/dummy/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
-
6
- Dummy::Application.load_tasks
File without changes
@@ -1,16 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require jquery
14
- //= require jquery_ujs
15
- //= require turbolinks
16
- //= require_tree .
@@ -1,13 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
10
- *
11
- *= require_self
12
- *= require_tree .
13
- */
@@ -1,5 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
- protect_from_forgery with: :exception
5
- end
File without changes