hydra_attribute 0.2.0 → 0.3.0.beta1

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 (63) hide show
  1. data/README.md +74 -68
  2. data/cucumber.yml +1 -0
  3. data/features/attributes/create.feature +22 -0
  4. data/features/attributes/destroy.feature +18 -0
  5. data/features/attributes/update.feature +19 -0
  6. data/features/create.feature +47 -0
  7. data/features/define.feature +33 -0
  8. data/features/query_methods/group.feature +13 -14
  9. data/features/query_methods/order.feature +63 -52
  10. data/features/query_methods/select.feature +36 -37
  11. data/features/query_methods/where.feature +36 -38
  12. data/features/step_definitions/model_steps.rb +23 -19
  13. data/features/step_definitions/query_methods.rb +6 -2
  14. data/features/step_definitions/record_steps.rb +28 -10
  15. data/features/support/env.rb +12 -6
  16. data/features/support/schema.rb +62 -35
  17. data/features/support/world.rb +14 -5
  18. data/features/update.feature +114 -0
  19. data/gemfiles/3.1.gemfile.lock +10 -10
  20. data/gemfiles/3.2.gemfile.lock +10 -10
  21. data/lib/hydra_attribute/active_record/association.rb +77 -0
  22. data/lib/hydra_attribute/active_record/association_preloader.rb +82 -0
  23. data/lib/hydra_attribute/active_record/attribute_methods.rb +145 -37
  24. data/lib/hydra_attribute/active_record/migration.rb +21 -0
  25. data/lib/hydra_attribute/active_record/reflection.rb +16 -0
  26. data/lib/hydra_attribute/active_record/relation/query_methods.rb +73 -71
  27. data/lib/hydra_attribute/active_record/relation.rb +1 -24
  28. data/lib/hydra_attribute/active_record.rb +16 -2
  29. data/lib/hydra_attribute/association_builder.rb +44 -20
  30. data/lib/hydra_attribute/builder.rb +15 -13
  31. data/lib/hydra_attribute/configuration.rb +9 -30
  32. data/lib/hydra_attribute/entity_callbacks.rb +46 -0
  33. data/lib/hydra_attribute/hydra_attribute.rb +27 -0
  34. data/lib/hydra_attribute/migrator.rb +106 -0
  35. data/lib/hydra_attribute/railtie.rb +2 -0
  36. data/lib/hydra_attribute/version.rb +2 -2
  37. data/lib/hydra_attribute.rb +8 -6
  38. data/lib/rails/generators/hydra_attribute/install/templates/hydra_attribute.txt +4 -0
  39. data/spec/spec_helper.rb +1 -2
  40. metadata +42 -60
  41. data/features/attribute_methods.feature +0 -146
  42. data/features/define_attributes.feature +0 -56
  43. data/features/load_associations.feature +0 -40
  44. data/features/step_definitions/class_steps.rb +0 -32
  45. data/features/typecast_attributes.feature +0 -24
  46. data/lib/generators/hydra_attribute/install/templates/hydra_attribute.txt +0 -11
  47. data/lib/hydra_attribute/active_record/attribute_methods/before_type_cast.rb +0 -16
  48. data/lib/hydra_attribute/active_record/attribute_methods/read.rb +0 -13
  49. data/lib/hydra_attribute/attribute_builder.rb +0 -57
  50. data/lib/hydra_attribute/attribute_proxy.rb +0 -16
  51. data/lib/hydra_attribute/migration.rb +0 -27
  52. data/spec/hydra_attribute/active_record/relation/query_methods_spec.rb +0 -334
  53. data/spec/hydra_attribute/active_record/relation_spec.rb +0 -67
  54. data/spec/hydra_attribute/active_record/scoping_spec.rb +0 -23
  55. data/spec/hydra_attribute/active_record_spec.rb +0 -18
  56. data/spec/hydra_attribute/association_builder_spec.rb +0 -95
  57. data/spec/hydra_attribute/attribute_builder_spec.rb +0 -70
  58. data/spec/hydra_attribute/attribute_helpers_spec.rb +0 -70
  59. data/spec/hydra_attribute/builder_spec.rb +0 -39
  60. data/spec/hydra_attribute/configuration_spec.rb +0 -65
  61. data/spec/hydra_attribute_spec.rb +0 -20
  62. /data/lib/{generators → rails/generators}/hydra_attribute/install/USAGE +0 -0
  63. /data/lib/{generators → rails/generators}/hydra_attribute/install/install_generator.rb +0 -0
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe HydraAttribute::Builder do
4
-
5
- let(:klass) { Class.new }
6
- let!(:builder) { HydraAttribute::Builder.new(klass) }
7
-
8
- describe '#initialzie' do
9
- it 'should include HydraAttribute::ActiveRecord::Scoping to class' do
10
- klass.should include(HydraAttribute::ActiveRecord::Scoping)
11
- end
12
-
13
- it 'should include HydraAttribute::ActiveRecord::AttributeMethods to class' do
14
- klass.should include(HydraAttribute::ActiveRecord::AttributeMethods)
15
- end
16
-
17
- it 'should respond to all supported types' do
18
- HydraAttribute::SUPPORT_TYPES.each do |type|
19
- builder.should respond_to(type)
20
- end
21
- end
22
- end
23
-
24
- describe '#string' do
25
- let(:association_instance) { mock(:association_instance) }
26
- let(:attribute_instance) { mock(:attribute_instance) }
27
-
28
- before do
29
- HydraAttribute::AssociationBuilder.should_receive(:new).with(klass, :string).and_return(association_instance)
30
- HydraAttribute::AttributeBuilder.should_receive(:new).with(klass, :name, :string).and_return(attribute_instance)
31
-
32
- [association_instance, attribute_instance].each { |instance| instance.should_receive(:build) }
33
- end
34
-
35
- it 'should build association' do
36
- builder.string :name
37
- end
38
- end
39
- end
@@ -1,65 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe HydraAttribute::Configuration do
4
- let(:config) { HydraAttribute::Configuration.new }
5
-
6
- describe '#table_name' do
7
- describe 'with table prefix' do
8
- before { config.table_prefix = 'table_' }
9
-
10
- it 'should return table name' do
11
- config.table_name(:string).should == :table_string_attributes
12
- end
13
- end
14
-
15
- describe 'without table prefix' do
16
- before { config.table_prefix = '' }
17
-
18
- it 'should return table name' do
19
- config.table_name(:string).should == :string_attributes
20
- end
21
- end
22
- end
23
-
24
- describe '#association' do
25
- describe 'with association prefix' do
26
- before { config.association_prefix = 'assoc_' }
27
-
28
- it 'should return association name' do
29
- config.association(:string).should == :assoc_string_attributes
30
- end
31
- end
32
-
33
- describe 'without association prefix' do
34
- before { config.association_prefix = '' }
35
-
36
- it 'should return association name' do
37
- config.association(:string).should == :string_attributes
38
- end
39
- end
40
- end
41
-
42
- describe '#associated_model_name' do
43
- describe 'use module wrapper' do
44
- before { config.use_module_for_associated_models = true }
45
-
46
- it 'should return associated model name' do
47
- config.associated_model_name(:string).should == 'HydraAttribute::StringAttribute'
48
- end
49
- end
50
-
51
- describe 'don not use module wrapper' do
52
- before { config.use_module_for_associated_models = false }
53
-
54
- it 'should return associated model name' do
55
- config.associated_model_name(:string).should == 'StringAttribute'
56
- end
57
- end
58
- end
59
-
60
- describe '#associated_const_name' do
61
- it 'should return constant name for new model' do
62
- config.associated_const_name(:string).should == :StringAttribute
63
- end
64
- end
65
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe HydraAttribute do
4
- describe '.config' do
5
- it 'should return and instance of HydraAttribute::Configuration' do
6
- HydraAttribute.config.should be_a_kind_of(HydraAttribute::Configuration)
7
- end
8
-
9
- it 'should cache config object' do
10
- HydraAttribute.config.should be_equal(HydraAttribute.config)
11
- end
12
- end
13
-
14
- describe '.setup' do
15
- it 'should allow to change default configuration' do
16
- HydraAttribute.setup { |config| config.table_prefix = 'custom_table_prefix' }
17
- HydraAttribute.config.table_prefix.should == 'custom_table_prefix'
18
- end
19
- end
20
- end