Permalink
Browse files

style changes

git-svn-id: https://svn.thoughtbot.com/plugins/when/trunk@334 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information...
1 parent 75e11f5 commit f2c7cc46bf8545aeebb23180cead62d19ce330de dcroak committed Feb 14, 2008
Showing with 9 additions and 1 deletion.
  1. +1 −1 README
  2. +8 −0 test/validations_test.rb
View
2 README
@@ -30,7 +30,7 @@ and 1 filter:
before_filter
-It works when :if or :unless is passed a Symbol, a lambdas or a String.
+It works when :if or :unless is passed a Symbol, a Proc or a String.
They return or evaluate to a true or false value.
Example
View
@@ -15,27 +15,31 @@ def setup
basic_validations.each do |validation|
define_method "test_#{validation}_with_if_condition_#{condition.class}_which_returns_true_should_change_company_name" do
Company.send validation.to_sym, :change_name, :if => condition
+
company = Company.new :name => 'thoughtbot', :flag => true
assert company.save
assert_equal 'new name', company.name
end
define_method "test_#{validation}_with_if_condition_#{condition.class}_which_returns_false_should_not_change_company_name" do
Company.send validation.to_sym, :change_name, :if => condition
+
company = Company.new :name => 'thoughtbot', :flag => false
assert company.save
assert_equal 'thoughtbot', company.name
end
define_method "test_#{validation}_with_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_name" do
Company.send validation.to_sym, :change_name, :unless => condition
+
company = Company.new :name => 'thoughtbot', :flag => true
assert company.save
assert_equal 'thoughtbot', company.name
end
define_method "test_#{validation}_with_unless_condition_#{condition.class}_which_returns_false_should_change_company_name" do
Company.send validation.to_sym, :change_name, :unless => condition
+
company = Company.new :name => 'thoughtbot', :flag => false
assert company.save
assert_equal 'new name', company.name
@@ -63,27 +67,31 @@ def setup
update_validations.each do |validation|
define_method "test_#{validation}_with_if_condition_#{condition.class}_which_returns_true_should_change_company_name" do
Company.send validation.to_sym, :change_name, :if => condition
+
company = Company.create :name => 'thoughtbot', :flag => true
assert company.save
assert_equal 'new name', company.name
end
define_method "test_#{validation}_with_if_condition_#{condition.class}_which_returns_false_should_not_change_company_name" do
Company.send validation.to_sym, :change_name, :if => condition
+
company = Company.create :name => 'thoughtbot', :flag => false
assert company.save
assert_equal 'thoughtbot', company.name
end
define_method "test_#{validation}_with_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_name" do
Company.send validation.to_sym, :change_name, :unless => condition
+
company = Company.create :name => 'thoughtbot', :flag => true
assert company.save
assert_equal 'thoughtbot', company.name
end
define_method "test_#{validation}_with_unless_condition_#{condition.class}_which_returns_false_should_change_company_name" do
Company.send validation.to_sym, :change_name, :unless => condition
+
company = Company.create :name => 'thoughtbot', :flag => false
assert company.save
assert_equal 'new name', company.name

0 comments on commit f2c7cc4

Please sign in to comment.