Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixing syntax errors

git-svn-id: https://svn.thoughtbot.com/plugins/when/trunk@314 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information...
commit b9547f1245a5dfa5a8232cd93cc2874b8c6a063d 1 parent ee264f7
dcroak authored
Showing with 10 additions and 8 deletions.
  1. +10 −8 test/callbacks_test.rb
View
18 test/callbacks_test.rb
@@ -15,19 +15,21 @@ def setup
destroy_callbacks = ['before_destroy', 'after_destroy']
unique_callbacks = ['after_find', 'after_initialize']
- conditions = [ lambda {|company| company.callback_flag == true}, :flag? ]
+ conditions = [ 'lambda {|company| company.callback_flag == true}' ]
src = ''
conditions.each do |condition|
basic_callbacks.each do |callback|
- define_method "test_#{callback}_with_if_condition_which_returns_true_should_change_company_name" do
- Company.send(callback.to_sym, :change_name, { :if => condition })
- company = Company.new :name => 'thoughtbot', :callback_flag => true
- assert company.save
- assert_equal 'new name', company.name
- end
-
src << <<-END;
+ def test_#{callback}_with_if_condition_which_returns_true_should_change_company_name
+ Company.class_eval do
+ #{callback} :change_name, :if => #{condition}
+ end
+ company = Company.new :name => 'thoughtbot', :callback_flag => true
+ assert company.save
+ assert_equal 'new name', company.name
+ end
+
def test_#{callback}_with_if_condition_which_returns_false_should_not_change_company_name
Company.class_eval do
#{callback} :change_name, :if => #{condition}
Please sign in to comment.
Something went wrong with that request. Please try again.