Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

. Adding a README and a gem builder

  • Loading branch information...
commit cba3bff6c8bbbde9ea1bc03066b985acf5664d6a 1 parent ecba924
Kaspar Schiess authored June 18, 2010

Showing 2 changed files with 119 additions and 3 deletions. Show diff stats Hide diff stats

  1. 46  README
  2. 76  Rakefile
46  README
... ...
@@ -0,0 +1,46 @@
  1
+
  2
+FLOOR MANAGER - when your job is handling the girls
  3
+
  4
+The floor manager manages a whole graph of objects and lets you create them 
  5
+in memory or the database for the duration of a test. 
  6
+
  7
+You need two posts that are linked up to the same author? [1] Easy: 
  8
+
  9
+  FloorManager.define :first do
  10
+    one :author do  
  11
+      name 'John Smith'
  12
+    end
  13
+  
  14
+    any :post do
  15
+      title 'The posts title'
  16
+      author.set :author
  17
+    end
  18
+  end
  19
+
  20
+And in your tests: 
  21
+  
  22
+  before(:each) do
  23
+    FloorManager.reset
  24
+    
  25
+    floor = FloorManager.get(:floor)
  26
+    posts = [floor.create(:post), floor.create(:post)]
  27
+  end
  28
+  
  29
+This gives you two posts to test against. Both posts will have the same
  30
+author, right down to the database id. 
  31
+
  32
+COMPATIBILITY
  33
+
  34
+This has only been tested with rails 2. Both Ruby 1.8 and Ruby 1.9 should
  35
+work.
  36
+
  37
+STATUS
  38
+
  39
+Useful in daily life. 
  40
+  
  41
+AUTHOR
  42
+
  43
+Kaspar Schiess (kaspar.schiess@absurd.li)
  44
+
  45
+[1] http://robots.thoughtbot.com/post/159807023/waiting-for-a-factory-girl
  46
+
76  Rakefile
... ...
@@ -1,5 +1,75 @@
1  
-task :default => :spec
2 1
 
3  
-require 'spec'
4  
-require 'spec/rake/spectask'
  2
+
  3
+require "rubygems"
  4
+require "rake/gempackagetask"
  5
+require "rake/rdoctask"
  6
+
  7
+require "spec"
  8
+require "spec/rake/spectask"
5 9
 Spec::Rake::SpecTask.new
  10
+
  11
+
  12
+task :default => ["spec"]
  13
+
  14
+# This builds the actual gem. For details of what all these options
  15
+# mean, and other ones you can add, check the documentation here:
  16
+#
  17
+#   http://rubygems.org/read/chapter/20
  18
+#
  19
+spec = Gem::Specification.new do |s|
  20
+
  21
+  # Change these as appropriate
  22
+  s.name              = "floor_manager"
  23
+  s.version           = "0.1.0"
  24
+  s.summary           = "Allows creation of a whole graph of objects on the fly during testing"
  25
+  s.author            = "Kaspar Schiess"
  26
+  s.email             = "kaspar.schiess@absurd.li"
  27
+  s.homepage          = "http://github.com/kschiess/floor_manager"
  28
+
  29
+  s.has_rdoc          = true
  30
+  s.extra_rdoc_files  = %w(README)
  31
+  s.rdoc_options      = %w(--main README)
  32
+
  33
+  # Add any extra files to include in the gem
  34
+  s.files             = %w(LICENSE Rakefile README) + Dir.glob("{spec,lib/**/*}")
  35
+  s.require_paths     = ["lib"]
  36
+
  37
+  # If you want to depend on other gems, add them here, along with any
  38
+  # relevant versions
  39
+  s.add_dependency("activesupport", "~> 2.3.5")
  40
+
  41
+  # If your tests use any gems, include them here
  42
+  s.add_development_dependency("rspec")
  43
+  s.add_development_dependency("flexmock")
  44
+end
  45
+
  46
+# This task actually builds the gem. We also regenerate a static
  47
+# .gemspec file, which is useful if something (i.e. GitHub) will
  48
+# be automatically building a gem for this project. If you're not
  49
+# using GitHub, edit as appropriate.
  50
+#
  51
+# To publish your gem online, install the 'gemcutter' gem; Read more 
  52
+# about that here: http://gemcutter.org/pages/gem_docs
  53
+Rake::GemPackageTask.new(spec) do |pkg|
  54
+  pkg.gem_spec = spec
  55
+end
  56
+
  57
+desc "Build the gemspec file #{spec.name}.gemspec"
  58
+task :gemspec do
  59
+  file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
  60
+  File.open(file, "w") {|f| f << spec.to_ruby }
  61
+end
  62
+
  63
+task :package => :gemspec
  64
+
  65
+# Generate documentation
  66
+Rake::RDocTask.new do |rd|
  67
+  rd.main = "README"
  68
+  rd.rdoc_files.include("README", "lib/**/*.rb")
  69
+  rd.rdoc_dir = "rdoc"
  70
+end
  71
+
  72
+desc 'Clear out RDoc and generated packages'
  73
+task :clean => [:clobber_rdoc, :clobber_package] do
  74
+  rm "#{spec.name}.gemspec"
  75
+end

0 notes on commit cba3bff

Please sign in to comment.
Something went wrong with that request. Please try again.