Skip to content

Commit

Permalink
fixjour!
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Adkisson committed Aug 8, 2010
1 parent 28541c8 commit 4ac71f6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'

def spec_require(fpath)
require File.expalnd_path(File.join(File.dirname(__FILE__), *fpath.split('/')))
end

# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
Expand All @@ -24,4 +28,6 @@
# examples within a transaction, comment the following line or assign false
# instead of true.
config.use_transactional_fixtures = true

config.include Fixjour
end
40 changes: 40 additions & 0 deletions spec/support/builders/basic_builders.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Fixjour do
define_builder LineItem do |klass, overrides|
klass.new(
:description => Faker::Lorem.sentence,
:receipt => new_receipt,
:amount => Random.rand * 1000
)
end

define_builder Pool do |klass, overrides|
klass.new(
:slug => Faker::Lorem.sentence.split(' ').first.downcase,
:name => Faker::Lorem.sentence.split(' ').first.capitalize
)
end

define_builder PoolMembership do |klass, overrides|
klass.new(
:pool => new_pool,
:member => new_user,
:stake => 1 + rand(30)
)
end

define_builder Receipt do |klass, overrides|
klass.new(
:spent_at => 3.days.ago.to_date,
:pool => new_pool,
:spender => new_user
)
end

define_builder User do |klass, overrides|
klass.new(
:name => Faker::Name.name,
:email => Faker::Internet.email,
:fbuid => 10**5 + rand(10**6)
)
end
end

0 comments on commit 4ac71f6

Please sign in to comment.