This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

fixture refactoring

git-svn-id: https://svn.thoughtbot.com/plugins/when/trunk@329 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information...
1 parent c44041d commit ac8f84c4bed35bdf6b4bc383d4f94f5842c5393c jcarroll committed Feb 14, 2008
Showing with 43 additions and 43 deletions.
  1. +24 −24 test/callbacks_test.rb
  2. +4 −4 test/filters_test.rb
  3. +3 −3 test/fixtures/companies_controller.rb
  4. +4 −4 test/fixtures/company.rb
  5. +8 −8 test/validations_test.rb
View
@@ -21,31 +21,31 @@ def setup
define_method "test_#{callback}_with_if_condition_#{condition.class}_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
+ company = Company.new :name => 'thoughtbot', :flag => true
assert company.save
assert_equal 'new name', company.name
end
define_method "test_#{callback}_with_if_condition_#{condition.class}_which_returns_false_should_not_change_company_name" do
Company.send callback.to_sym, :change_name, :if => condition
- company = Company.new :name => 'thoughtbot', :callback_flag => false
+ company = Company.new :name => 'thoughtbot', :flag => false
assert company.save
assert_equal 'thoughtbot', company.name
end
define_method "test_#{callback}_with_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_name" do
Company.send callback.to_sym, :change_name, :unless => condition
- company = Company.new :name => 'thoughtbot', :callback_flag => true
+ company = Company.new :name => 'thoughtbot', :flag => true
assert company.save
assert_equal 'thoughtbot', company.name
end
define_method "test_#{callback}_with_unless_condition_#{condition.class}_which_returns_false_should_change_company_name" do
Company.send callback.to_sym, :change_name, :unless => condition
- company = Company.new :name => 'thoughtbot', :callback_flag => false
+ company = Company.new :name => 'thoughtbot', :flag => false
assert company.save
assert_equal 'new name', company.name
end
@@ -55,71 +55,71 @@ def setup
define_method "test_#{callback}_with_if_condition_#{condition.class}_which_returns_true_should_change_company_name" do
Company.send callback.to_sym, :change_name, :if => condition
- company = Company.create :name => 'thoughtbot', :callback_flag => true
+ company = Company.create :name => 'thoughtbot', :flag => true
assert company.save
assert_equal 'new name', company.name
end
define_method "test_#{callback}_with_if_condition_#{condition.class}_which_returns_false_should_not_change_company_name" do
Company.send callback.to_sym, :change_name, :if => condition
- company = Company.create :name => 'thoughtbot', :callback_flag => false
+ company = Company.create :name => 'thoughtbot', :flag => false
assert company.save
assert_equal 'thoughtbot', company.name
end
define_method "test_#{callback}_with_unless_condition_#{condition.class}_which_returns_true_should_not_change_company_name" do
Company.send callback.to_sym, :change_name, :unless => condition
- company = Company.create :name => 'thoughtbot', :callback_flag => true
+ company = Company.create :name => 'thoughtbot', :flag => true
assert company.save
assert_equal 'thoughtbot', company.name
end
define_method "test_#{callback}_with_unless_condition_#{condition.class}_which_returns_false_should_change_company_name" do
Company.send callback.to_sym, :change_name, :unless => condition
- company = Company.create :name => 'thoughtbot', :callback_flag => false
+ company = Company.create :name => 'thoughtbot', :flag => false
assert company.save
assert_equal 'new name', company.name
end
end
destroy_callbacks.each do |callback|
- define_method "test_#{callback}_with_if_condition_#{condition.class}_which_returns_true_should_toggle_callback_flag" do
- Company.send callback.to_sym, :toggle_callback_flag, :if => condition
+ define_method "test_#{callback}_with_if_condition_#{condition.class}_which_returns_true_should_toggle_flag" do
+ Company.send callback.to_sym, :toggle_flag, :if => condition
- company = Company.new :name => 'thoughtbot', :callback_flag => true
+ company = Company.new :name => 'thoughtbot', :flag => true
assert company.save
assert company.destroy
- assert ! company.callback_flag
+ assert ! company.flag
end
- define_method "test_#{callback}_with_if_condition_#{condition.class}_which_returns_false_should_not_toggle_callback_flag" do
- Company.send callback.to_sym, :toggle_callback_flag, :if => condition
+ define_method "test_#{callback}_with_if_condition_#{condition.class}_which_returns_false_should_not_toggle_flag" do
+ Company.send callback.to_sym, :toggle_flag, :if => condition
- company = Company.new :name => 'thoughtbot', :callback_flag => false
+ company = Company.new :name => 'thoughtbot', :flag => false
assert company.save
assert company.destroy
- assert ! company.callback_flag
+ assert ! company.flag
end
- define_method "test_#{callback}_with_unless_condition_#{condition.class}_which_returns_true_should_not_toggle_callback_flag" do
- Company.send callback.to_sym, :toggle_callback_flag, :unless => condition
+ define_method "test_#{callback}_with_unless_condition_#{condition.class}_which_returns_true_should_not_toggle_flag" do
+ Company.send callback.to_sym, :toggle_flag, :unless => condition
- company = Company.new :name => 'thoughtbot', :callback_flag => true
+ company = Company.new :name => 'thoughtbot', :flag => true
assert company.save
assert company.destroy
- assert company.callback_flag
+ assert company.flag
end
- define_method "test_#{callback}_with_unless_condition_#{condition.class}_which_returns_false_should_toggle_callback_flag" do
- Company.send callback.to_sym, :toggle_callback_flag, :unless => condition
+ define_method "test_#{callback}_with_unless_condition_#{condition.class}_which_returns_false_should_toggle_flag" do
+ Company.send callback.to_sym, :toggle_flag, :unless => condition
- company = Company.new :name => 'thoughtbot', :callback_flag => false
+ company = Company.new :name => 'thoughtbot', :flag => false
assert company.save
assert company.destroy
- assert company.callback_flag
+ assert company.flag
end
end
end
View
@@ -23,7 +23,7 @@ def setup
CompaniesController.send filter.to_sym, :change_name, :if => condition
@controller.name = 'thoughtbot'
- @controller.filter_flag = true
+ @controller.flag = true
get :index
assert_equal 'new name', @controller.name
@@ -33,7 +33,7 @@ def setup
CompaniesController.send filter.to_sym, :change_name, :if => condition
@controller.name = 'thoughtbot'
- @controller.filter_flag = false
+ @controller.flag = false
get :index
assert_equal 'thoughtbot', @controller.name
@@ -43,7 +43,7 @@ def setup
CompaniesController.send filter.to_sym, :change_name, :unless => condition
@controller.name = 'thoughtbot'
- @controller.filter_flag = true
+ @controller.flag = true
get :index
assert_equal 'thoughtbot', @controller.name
@@ -53,7 +53,7 @@ def setup
CompaniesController.send filter.to_sym, :change_name, :unless => condition
@controller.name = 'thoughtbot'
- @controller.filter_flag = false
+ @controller.flag = false
get :index
assert_equal 'new name', @controller.name
@@ -1,14 +1,14 @@
class CompaniesController < ActionController::Base
- attr_accessor :name,
- :filter_flag
+ attr_accessor :flag,
+ :name
def change_name
self.name = 'new name'
end
def flag?
- filter_flag == true
+ flag
end
def index
View
@@ -1,17 +1,17 @@
class Company < ActiveRecord::Base
- attr_accessor :callback_flag
+ attr_accessor :flag
def change_name
self.name = 'new name'
end
def flag?
- callback_flag == true
+ flag
end
- def toggle_callback_flag
- self.callback_flag = ! callback_flag
+ def toggle_flag
+ self.flag = ! flag
return true
end
View
@@ -16,31 +16,31 @@ def setup
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', :callback_flag => true
+ 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', :callback_flag => false
+ 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', :callback_flag => true
+ 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', :callback_flag => false
+ company = Company.new :name => 'thoughtbot', :flag => false
assert company.save
assert_equal 'new name', company.name
end
@@ -50,31 +50,31 @@ def setup
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', :callback_flag => true
+ 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', :callback_flag => false
+ 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', :callback_flag => true
+ 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', :callback_flag => false
+ company = Company.create :name => 'thoughtbot', :flag => false
assert company.save
assert_equal 'new name', company.name
end

0 comments on commit ac8f84c

Please sign in to comment.