Permalink
Browse files

Clean up scoping

  • Loading branch information...
1 parent 0ac2645 commit 39caed08c7ca290729f06f7da0380ebd3993b91e @joshuaclayton joshuaclayton committed Oct 7, 2011
Showing with 4 additions and 19 deletions.
  1. +4 −4 lib/factory_girl/attribute_list.rb
  2. +0 −15 spec/factory_girl/attribute_list_spec.rb
@@ -31,10 +31,6 @@ def each(&block)
flattened_attributes.each(&block)
end
- def attribute_defined?(attribute_name)
- !!find_attribute(attribute_name)
- end
-
def apply_attributes(attributes_to_apply)
attributes_to_apply.callbacks.reverse.each { |callback| prepend_callback(callback) }
new_attributes = []
@@ -93,6 +89,10 @@ def flattened_attributes
end.flatten
end
+ def attribute_defined?(attribute_name)
+ !!find_attribute(attribute_name)
+ end
+
def find_attribute(attribute_name)
@attributes.values.flatten.detect do |attribute|
attribute.name == attribute_name
@@ -45,21 +45,6 @@
end
end
-describe FactoryGirl::AttributeList, "#attribute_defined?" do
- let(:static_attribute) { FactoryGirl::Attribute::Static.new(:full_name, "value") }
- let(:callback_attribute) { FactoryGirl::Callback.new(:after_create, lambda { }) }
- let(:static_attribute_named_after_create) { FactoryGirl::Attribute::Static.new(:after_create, "funky!") }
-
- it "knows if an attribute has been defined" do
- subject.attribute_defined?(static_attribute.name).should == false
-
- subject.define_attribute(static_attribute)
-
- subject.attribute_defined?(static_attribute.name).should == true
- subject.attribute_defined?(:undefined_attribute).should == false
- end
-end
-
describe FactoryGirl::AttributeList, "#add_callback" do
let(:proxy_class) { mock("klass") }
let(:proxy) { FactoryGirl::Proxy.new(proxy_class) }

0 comments on commit 39caed0

Please sign in to comment.