Skip to content

Commit b59b89b

Browse files
committed
Test attribute instead of attr_accessor
1 parent 1de276a commit b59b89b

10 files changed

Lines changed: 29 additions & 9 deletions

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ Available callbacks are (listed in execution order):
254254

255255
```ruby
256256
class RegistrationForm < YAAF::Form
257+
attribute :email, :string
258+
attribute :name, :string
259+
257260
normalizes :email, with: ->(email) { email.strip.downcase }
258261
normalizes :name, with: ->(name) { name.strip.titleize }
259262

spec/support/forms/multiple_errors_form.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class MultipleErrorsForm < YAAF::Form
2-
attr_accessor :email, :name
2+
attribute :email, :string
3+
attribute :name, :string
34

45
validates :name, format: { with: /[a-zA-Z]+/ }
56
validates :email, format: { with: /\S+@\S+\.\S+/ }

spec/support/forms/registration_form.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class RegistrationForm < YAAF::Form
2-
attr_accessor :email, :name
2+
attribute :email, :string
3+
attribute :name, :string
34

45
validates :name, format: { with: /[a-zA-Z]+/ }, allow_blank: true
56

spec/support/forms/user_destroy_form.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class UserDestroyForm < YAAF::Form
2-
attr_accessor :email, :name
2+
attribute :email, :string
3+
attribute :name, :string
34

45
before_save :mark_user_for_destruction
56

spec/support/forms/with_commit_callbacks_form.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
class WithCommitCallbacksForm < YAAF::Form
2-
attr_accessor :email, :name, :after_counter
2+
attribute :email, :string
3+
attribute :name, :string
4+
5+
attr_accessor :after_counter
36

47
validates :name, format: { with: /[a-zA-Z]+/ }, allow_blank: true
58
after_commit { @after_counter += 1 }

spec/support/forms/with_multiple_callbacks_form.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
class WithMultipleCallbacksForm < YAAF::Form
2-
attr_accessor :email, :name, :result
2+
attribute :email, :string
3+
attribute :name, :string
4+
5+
attr_accessor :result
36

47
validates :name, format: { with: /[a-zA-Z]+/ }, allow_blank: true
58
after_validation :add_to_after_validation_counter, :add_again_to_after_validation_counter

spec/support/forms/with_rollback_callbacks_form.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
class WithRollbackCallbacksForm < YAAF::Form
2-
attr_accessor :email, :name, :after_counter
2+
attribute :email, :string
3+
attribute :name, :string
4+
5+
attr_accessor :after_counter
36

47
validates :name, format: { with: /[a-zA-Z]+/ }, allow_blank: true
58
after_rollback { @after_counter += 1 }

spec/support/forms/with_save_callbacks_form.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
class WithSaveCallbacksForm < YAAF::Form
2-
attr_accessor :email, :name, :before_counter, :after_counter
2+
attribute :email, :string
3+
attribute :name, :string
4+
5+
attr_accessor :before_counter, :after_counter
36

47
validates :name, format: { with: /[a-zA-Z]+/ }, allow_blank: true
58
before_save :add_to_before_counter

spec/support/forms/with_validation_callbacks_form.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
class WithValidationCallbacksForm < YAAF::Form
2-
attr_accessor :email, :name, :before_counter, :after_counter
2+
attribute :email, :string
3+
attribute :name, :string
4+
5+
attr_accessor :before_counter, :after_counter
36

47
validates :name, format: { with: /[a-zA-Z]+/ }, allow_blank: true
58
before_validation :add_to_before_counter

0 commit comments

Comments
 (0)