Skip to content

Commit

Permalink
Clean up scoping
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaclayton committed Oct 7, 2011
1 parent 0ac2645 commit 39caed0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
8 changes: 4 additions & 4 deletions lib/factory_girl/attribute_list.rb
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions spec/factory_girl/attribute_list_spec.rb
Expand Up @@ -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) }
Expand Down

0 comments on commit 39caed0

Please sign in to comment.