Permalink
Browse files

Fixed bug with alias functionality.

  • Loading branch information...
hoverlover committed Dec 29, 2010
1 parent dde290a commit 89fe1d906b2e0f6822818bd59bb8771c2ad25d7a
Showing with 5 additions and 4 deletions.
  1. +2 −2 miniskirt.rb
  2. +3 −2 miniskirt_test.rb
View
@@ -21,8 +21,8 @@ def define(name, attrs = {})
end
def build(name, attrs = {})
- (name, n = (@@factories[name.to_s][:class] || name).to_s) and (m = name.classify.constantize).new do |rec|
- attrs.symbolize_keys!.reverse_update(@@factories[name]).each do |k, v|
+ (klass, n = (@@factories[name.to_s][:class] || name).to_s) and (m = klass.classify.constantize).new do |rec|
+ attrs.symbolize_keys!.reverse_update(@@factories[name.to_s]).each do |k, v|
rec.send "#{k}=", case v when String # Sequence and interpolate.
v.sub(/%\d*d/) {|d| d % n ||= m.maximum(:id).to_i + 1} % attrs % n
when Proc then v.call(rec) else v
View
@@ -69,9 +69,9 @@ def test_should_interpolate
end
def test_should_allow_aliases_in_define
- user = Factory.build :another_name_for_user, :login => (login = 'itsme')
+ user = Factory.build :another_name_for_user
assert_instance_of User, user
- assert_equal login, user.login
+ assert_equal 'test', user.login
end
end
@@ -114,6 +114,7 @@ class Post < Mock
end
Miniskirt.define :user, :as => :another_name_for_user do |f|
+ f.login 'test'
end
Miniskirt.define :post do |f|

0 comments on commit 89fe1d9

Please sign in to comment.