diff --git a/CHANGELOG.md b/CHANGELOG.md index 12ca877..8acd808 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Overview of Changes +## 0.3.1 + +* Bugfix, generating a hash of attributes via _attrs did not work with factory methods + that used the inherit method + ## 0.3.0 * Updated README to present the crank syntax as the default diff --git a/lib/cranky/factory.rb b/lib/cranky/factory.rb index 56cb345..23f2830 100644 --- a/lib/cranky/factory.rb +++ b/lib/cranky/factory.rb @@ -62,10 +62,6 @@ def n @n += 1 end - def inherit(what, overrides={}) - build(what, overrides.merge(options)) - end - # Execute the requested factory method, crank out the target object! def crank_it(what, overrides) if what.to_s =~ /(.*)_attrs$/ @@ -86,6 +82,12 @@ def define(defaults={}) current_job.execute end + def inherit(what, overrides={}) + overrides = overrides.merge(options) + overrides = overrides.merge(:_return_attributes => true) if current_job.return_attributes + build(what, overrides) + end + def current_job @pipeline.last end diff --git a/lib/cranky/job.rb b/lib/cranky/job.rb index 2194e94..faf00bd 100644 --- a/lib/cranky/job.rb +++ b/lib/cranky/job.rb @@ -2,7 +2,7 @@ module Cranky class Job attr_writer :defaults - attr_reader :overrides + attr_reader :overrides, :return_attributes def initialize(target, overrides={}) @defaults = {} diff --git a/lib/cranky/version.rb b/lib/cranky/version.rb index 7accbd9..49473dc 100644 --- a/lib/cranky/version.rb +++ b/lib/cranky/version.rb @@ -1,3 +1,3 @@ module Cranky - VERSION = "0.3.0" + VERSION = "0.3.1" end diff --git a/rakefile b/rakefile index 023015e..bed03a8 100644 --- a/rakefile +++ b/rakefile @@ -18,13 +18,19 @@ task :release_tag do system "git tag -a v#{Cranky::VERSION} -m 'version #{Cranky::VERSION}'" end +# Push to github +desc "Push to Github" +task :push do + system "git push --tags origin master" +end + desc "Build the gem" task :build do system "bundle exec gem build cranky.gemspec" end desc "Release version #{Cranky::VERSION}" -task :release => [:build, :release_tag] do +task :release => [:build, :release_tag, :push] do system "bundle exec gem push cranky-#{Cranky::VERSION}.gem" end diff --git a/spec/cranky_spec.rb b/spec/cranky_spec.rb index 46bee30..711efb0 100644 --- a/spec/cranky_spec.rb +++ b/spec/cranky_spec.rb @@ -140,5 +140,9 @@ crank(:user_attrs).size.should == 6 end + specify "attributes for works with factory methods using inherit" do + crank(:admin_by_define_attrs).class.should == Hash + end + end