Skip to content

Commit

Permalink
Preparing for 0.3.0 release, see changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Ginty committed Oct 16, 2011
1 parent 17f31c1 commit 37fe0c9
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 15 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*.swp
*.swo
.*
*.gem
coverage/*
1 change: 1 addition & 0 deletions .rbenv-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.9.2-p290
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--colour -f doc
1 change: 1 addition & 0 deletions .rvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rvm use 1.9.2@cranky --create
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Overview of Changes

## 0.3.0

* Factory.debug was broken on ActiveModel based classes, now works with them

* Attributes can be skipped by setting the value to :skip. e.g. crank(:user, :name => :skip) will
generate a User instance without calling or assigning anything to the name attribute

* Updated dev environment for latest rspec compatibility (2.6.0)

## 0.2.0

Changes between version prior to this were not tracked here
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
source "http://gemcutter.org"

group :development do
gem "rake"
gem "gemcutter"
end

group :test do
gem "rspec", "1.3.0"
gem "rspec"
gem "rcov"
end

18 changes: 14 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
GEM
remote: http://gemcutter.org/
specs:
gemcutter (0.6.1)
rcov (0.9.8)
rspec (1.3.0)
diff-lcs (1.1.2)
gemcutter (0.7.0)
rake (0.9.2)
rcov (0.9.9)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)

PLATFORMS
ruby

DEPENDENCIES
gemcutter
rake
rcov
rspec (= 1.3.0)
rspec
7 changes: 6 additions & 1 deletion lib/cranky/factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ def attributes_for(what, attrs={})
def debug(*args)
item = build(*args)
if !item.valid?
raise "Oops, the #{item.class} created by the Factory has the following errors: #{item.errors}"
if item.errors.respond_to?("messages")
errors = item.errors.messages
else
errors = item.errors
end
raise "Oops, the #{item.class} created by the Factory has the following errors: #{errors}"
end
item
end
Expand Down
4 changes: 3 additions & 1 deletion lib/cranky/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def execute
item = get_constant(attributes[:class] ? attributes[:class] : @target).new
# Assign all explicit attributes first
attributes.each do |attribute, value|
item.send("#{attribute}=", value) if item.respond_to?("#{attribute}=") && !value.respond_to?("call")
unless value == :skip
item.send("#{attribute}=", value) if item.respond_to?("#{attribute}=") && !value.respond_to?("call")
end
end
# Then call any blocks
attributes.each do |attribute, value|
Expand Down
8 changes: 4 additions & 4 deletions rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ $:.unshift File.expand_path("../lib", __FILE__)

require 'cranky'
require 'rubygems'
require 'spec/rake/spectask'
require 'rspec/core'
require 'rspec/core/rake_task'

desc "Run specs"
Spec::Rake::SpecTask.new(:spec) do |t|
t.spec_files = Dir.glob("spec/**/*_spec.rb")
t.spec_opts = ["-c"]
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = ("spec/**/*_spec.rb")
t.rcov = true
end

Expand Down
4 changes: 2 additions & 2 deletions spec/cranky_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@

it "should allow blocks to be passed into the define method" do
Factory.build(:user, :name => "jenny", :email => lambda{ |u| "#{u.name}@home.com" }).email.should == "[email protected]"
Factory.build(:user, :name => lambda{"jimmy" + " cranky"}).name.should == "jimmy cranky"
Factory.build(:user, :name => lambda { |u| "jimmy" + " cranky" }).name.should == "jimmy cranky"
Factory.build(:user, :name => "jenny", :email => Proc.new{ |u| "#{u.name}@home.com" }).email.should == "[email protected]"
Factory.build(:user, :name => Proc.new{"jimmy" + " cranky"}).name.should == "jimmy cranky"
Factory.build(:user, :name => Proc.new{ |u| "jimmy" + " cranky" }).name.should == "jimmy cranky"
end

it "allows factories to call other factories" do
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rubygems'
require 'spec'
require 'rspec'
require 'cranky'


Expand Down

0 comments on commit 37fe0c9

Please sign in to comment.