state_machines-activemodel 0.0.2 → 0.0.3
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/.gitignore +1 -0
- data/.travis.yml +14 -10
- data/Appraisals +4 -15
- data/Gemfile +3 -0
- data/LICENSE.txt +1 -1
- data/README.md +9 -6
- data/Rakefile +5 -6
- data/gemfiles/active_model_4.1.gemfile +5 -1
- data/gemfiles/active_model_4.2.gemfile +11 -0
- data/lib/state_machines/integrations/active_model.rb +105 -108
- data/lib/state_machines/integrations/active_model/locale.rb +8 -8
- data/lib/state_machines/integrations/{version.rb → active_model/version.rb} +1 -1
- data/state_machines-activemodel.gemspec +10 -9
- data/{spec/support → test/files}/en.yml +1 -1
- data/test/integration_test.rb +23 -0
- data/test/machine_by_default_test.rb +24 -0
- data/test/machine_errors_test.rb +19 -0
- data/test/machine_multiple_test.rb +18 -0
- data/test/machine_with_callbacks_test.rb +130 -0
- data/test/machine_with_dirty_attribute_and_custom_attributes_during_loopback_test.rb +26 -0
- data/test/machine_with_dirty_attribute_and_state_events_test.rb +23 -0
- data/test/machine_with_dirty_attributes_and_custom_attribute_test.rb +34 -0
- data/test/machine_with_dirty_attributes_during_loopback_test.rb +49 -0
- data/test/machine_with_dirty_attributes_test.rb +33 -0
- data/test/machine_with_dynamic_initial_state_test.rb +14 -0
- data/test/machine_with_events_test.rb +13 -0
- data/test/machine_with_failed_after_callbacks_test.rb +31 -0
- data/test/machine_with_failed_before_callbacks_test.rb +32 -0
- data/test/machine_with_initialized_state_test.rb +35 -0
- data/test/machine_with_internationalization_test.rb +190 -0
- data/test/machine_with_model_state_attribute_test.rb +31 -0
- data/test/machine_with_non_model_state_attribute_undefined_test.rb +26 -0
- data/test/machine_with_state_driven_validations_test.rb +31 -0
- data/test/machine_with_states_test.rb +13 -0
- data/test/machine_with_static_initial_state_test.rb +13 -0
- data/test/machine_with_validations_and_custom_attribute_test.rb +22 -0
- data/test/machine_with_validations_test.rb +46 -0
- data/test/test_helper.rb +58 -0
- metadata +83 -36
- data/gemfiles/active_model_3.2.gemfile +0 -7
- data/gemfiles/active_model_3.2.gemfile.lock +0 -50
- data/gemfiles/active_model_4.0.gemfile +0 -7
- data/gemfiles/active_model_4.0.gemfile.lock +0 -56
- data/gemfiles/active_model_4.1.gemfile.lock +0 -57
- data/gemfiles/active_model_edge.gemfile +0 -7
- data/gemfiles/active_model_edge.gemfile.lock +0 -62
- data/spec/active_model_spec.rb +0 -801
- data/spec/integration_spec.rb +0 -26
- data/spec/spec_helper.rb +0 -8
- data/spec/support/helpers.rb +0 -48
- data/spec/support/migration_helpers.rb +0 -43
data/spec/integration_spec.rb
DELETED
@@ -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
|
data/spec/spec_helper.rb
DELETED
data/spec/support/helpers.rb
DELETED
@@ -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
|
-
|