state_machines-activemodel 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +14 -10
  4. data/Appraisals +4 -15
  5. data/Gemfile +3 -0
  6. data/LICENSE.txt +1 -1
  7. data/README.md +9 -6
  8. data/Rakefile +5 -6
  9. data/gemfiles/active_model_4.1.gemfile +5 -1
  10. data/gemfiles/active_model_4.2.gemfile +11 -0
  11. data/lib/state_machines/integrations/active_model.rb +105 -108
  12. data/lib/state_machines/integrations/active_model/locale.rb +8 -8
  13. data/lib/state_machines/integrations/{version.rb → active_model/version.rb} +1 -1
  14. data/state_machines-activemodel.gemspec +10 -9
  15. data/{spec/support → test/files}/en.yml +1 -1
  16. data/test/integration_test.rb +23 -0
  17. data/test/machine_by_default_test.rb +24 -0
  18. data/test/machine_errors_test.rb +19 -0
  19. data/test/machine_multiple_test.rb +18 -0
  20. data/test/machine_with_callbacks_test.rb +130 -0
  21. data/test/machine_with_dirty_attribute_and_custom_attributes_during_loopback_test.rb +26 -0
  22. data/test/machine_with_dirty_attribute_and_state_events_test.rb +23 -0
  23. data/test/machine_with_dirty_attributes_and_custom_attribute_test.rb +34 -0
  24. data/test/machine_with_dirty_attributes_during_loopback_test.rb +49 -0
  25. data/test/machine_with_dirty_attributes_test.rb +33 -0
  26. data/test/machine_with_dynamic_initial_state_test.rb +14 -0
  27. data/test/machine_with_events_test.rb +13 -0
  28. data/test/machine_with_failed_after_callbacks_test.rb +31 -0
  29. data/test/machine_with_failed_before_callbacks_test.rb +32 -0
  30. data/test/machine_with_initialized_state_test.rb +35 -0
  31. data/test/machine_with_internationalization_test.rb +190 -0
  32. data/test/machine_with_model_state_attribute_test.rb +31 -0
  33. data/test/machine_with_non_model_state_attribute_undefined_test.rb +26 -0
  34. data/test/machine_with_state_driven_validations_test.rb +31 -0
  35. data/test/machine_with_states_test.rb +13 -0
  36. data/test/machine_with_static_initial_state_test.rb +13 -0
  37. data/test/machine_with_validations_and_custom_attribute_test.rb +22 -0
  38. data/test/machine_with_validations_test.rb +46 -0
  39. data/test/test_helper.rb +58 -0
  40. metadata +83 -36
  41. data/gemfiles/active_model_3.2.gemfile +0 -7
  42. data/gemfiles/active_model_3.2.gemfile.lock +0 -50
  43. data/gemfiles/active_model_4.0.gemfile +0 -7
  44. data/gemfiles/active_model_4.0.gemfile.lock +0 -56
  45. data/gemfiles/active_model_4.1.gemfile.lock +0 -57
  46. data/gemfiles/active_model_edge.gemfile +0 -7
  47. data/gemfiles/active_model_edge.gemfile.lock +0 -62
  48. data/spec/active_model_spec.rb +0 -801
  49. data/spec/integration_spec.rb +0 -26
  50. data/spec/spec_helper.rb +0 -8
  51. data/spec/support/helpers.rb +0 -48
  52. data/spec/support/migration_helpers.rb +0 -43
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe StateMachines::Integrations::ActiveModel do
4
- it { expect(StateMachines::Integrations::ActiveModel.integration_name).to eq(:active_model) }
5
-
6
- it 'should_match_if_class_includes_validations_feature' do
7
- expect(StateMachines::Integrations::ActiveModel.matches?(new_model { include ActiveModel::Validations })).to be_truthy
8
- end
9
-
10
- it 'should_not_match_if_class_does_not_include_active_model_features' do
11
- expect(StateMachines::Integrations::ActiveModel.matches?(new_model)).to be_falsy
12
- end
13
-
14
- it 'should_have_no_defaults' do
15
- expect(StateMachines::Integrations::ActiveModel.defaults).to eq({})
16
- end
17
-
18
- describe '.matching_ancestors' do
19
- it do
20
- expect(StateMachines::Integrations::ActiveModel.matching_ancestors).to include('ActiveModel')
21
- end
22
- it do
23
- expect(StateMachines::Integrations::ActiveModel.matching_ancestors).to include('ActiveModel::Validations')
24
- end
25
- end
26
- end
@@ -1,8 +0,0 @@
1
-
2
- require 'state_machines/integrations/active_model'
3
- Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
4
- I18n.enforce_available_locales = true
5
- RSpec.configure do |config|
6
- config.raise_errors_for_deprecations!
7
- end
8
-
@@ -1,48 +0,0 @@
1
- # Creates a new ActiveModel model (and the associated table)
2
-
3
- class Bar
4
-
5
- end
6
-
7
- def new_model(&block)
8
- # Simple ActiveModel superclass
9
- parent = Class.new do
10
- def self.model_attribute(name)
11
- define_method(name) { instance_variable_defined?("@#{name}") ? instance_variable_get("@#{name}") : nil }
12
- define_method("#{name}=") do |value|
13
- send("#{name}_will_change!") if self.class <= ActiveModel::Dirty && value != send(name)
14
- instance_variable_set("@#{name}", value)
15
- end
16
- end
17
-
18
- def self.create
19
- object = new
20
- object.save
21
- object
22
- end
23
-
24
- def initialize(attrs = {})
25
- attrs.each {|attr, value| send("#{attr}=", value)}
26
- @changed_attributes = {}
27
- end
28
-
29
- def attributes
30
- @attributes ||= {}
31
- end
32
-
33
- def save
34
- @changed_attributes = {}
35
- true
36
- end
37
- end
38
-
39
- model = Class.new(parent) do
40
- def self.name
41
- 'Bar::Foo'
42
- end
43
-
44
- model_attribute :state
45
- end
46
- model.class_eval(&block) if block_given?
47
- model
48
- end
@@ -1,43 +0,0 @@
1
- def assert(obj)
2
- expect(obj).to be_truthy
3
- end
4
-
5
- def assert_equal(value, obj)
6
- expect(obj).to eq(value)
7
- end
8
-
9
- def assert_not_equal(value, obj)
10
- expect(obj).to_not eq(value)
11
- end
12
-
13
-
14
- def assert_not_nil(obj)
15
- expect(obj).to_not be_nil
16
- end
17
-
18
- def assert_nil(obj)
19
- expect(obj).to be_nil
20
- end
21
-
22
- def assert_raise(exception, &block)
23
- expect(block).to raise_error(exception)
24
- end
25
-
26
- def assert_nothing_raised(&block)
27
- expect(block).to_not raise_error
28
- end
29
-
30
-
31
- def assert_same(value, obj)
32
- expect(obj).to eq(value)
33
- end
34
-
35
- def assert_not_same(value, obj)
36
- expect(obj).to_not eq(value)
37
- end
38
-
39
- def assert_instance_of(klass, obj)
40
- expect(obj).to be_a klass
41
- end
42
-
43
-