fabrication 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,14 +27,14 @@ describe "Fabricate.sequence" do
27
27
  context 'with a name and starting number' do
28
28
 
29
29
  it 'starts with the number provided' do
30
- Fabricate.sequence(:incr, 69).should == 69
30
+ Fabricate.sequence(:higher, 69).should == 69
31
31
  end
32
32
 
33
33
  it 'increments by one with each call' do
34
- Fabricate.sequence(:incr).should == 70
35
- Fabricate.sequence(:incr, 69).should == 71
36
- Fabricate.sequence(:incr).should == 72
37
- Fabricate.sequence(:incr).should == 73
34
+ Fabricate.sequence(:higher).should == 70
35
+ Fabricate.sequence(:higher, 69).should == 71
36
+ Fabricate.sequence(:higher).should == 72
37
+ Fabricate.sequence(:higher).should == 73
38
38
  end
39
39
 
40
40
  end
data/spec/spec_helper.rb CHANGED
@@ -6,9 +6,3 @@ require 'spec'
6
6
  require 'spec/autorun'
7
7
  require 'fabrication'
8
8
  require 'ffaker'
9
-
10
- Spec::Runner.configure do |config|
11
- config.before(:all) do
12
- Fabrication.clear_definitions
13
- end
14
- end
@@ -35,3 +35,7 @@ end
35
35
  class Division < ActiveRecord::Base
36
36
  belongs_to :company
37
37
  end
38
+
39
+ Fabricator(:division) do
40
+ name "Division Name"
41
+ end
@@ -1,3 +1,18 @@
1
1
  class Person
2
2
  attr_accessor :age, :first_name, :last_name, :shoes
3
3
  end
4
+
5
+ class Dog
6
+ attr_accessor :name, :breed
7
+ end
8
+
9
+ Fabricator(:person) do
10
+ first_name "John"
11
+ last_name { Faker::Name.last_name }
12
+ age { rand(100) }
13
+ shoes(:count => 10) { |person, i| "shoe #{i}" }
14
+ end
15
+
16
+ Fabricator(:greyhound, :from => :dog) do
17
+ breed "greyhound"
18
+ end
@@ -31,3 +31,18 @@ class Book
31
31
 
32
32
  embedded_in :author, :inverse_of => :books
33
33
  end
34
+
35
+ Fabricator(:author) do
36
+ name 'George Orwell'
37
+ books(:count => 4) do |author, i|
38
+ Fabricate(:book, :title => "book title #{i}", :author => author)
39
+ end
40
+ end
41
+
42
+ Fabricator(:hemingway, :from => :author) do
43
+ name 'Ernest Hemingway'
44
+ end
45
+
46
+ Fabricator(:book) do
47
+ title "book title"
48
+ end
@@ -0,0 +1,61 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fabrication::Support do
4
+
5
+ describe ".class_for" do
6
+
7
+ context "with a class that exists" do
8
+
9
+ it "returns the class for a class" do
10
+ Fabrication::Support.class_for(Object).should == Object
11
+ end
12
+
13
+ it "returns the class for a class name string" do
14
+ Fabrication::Support.class_for('object').should == Object
15
+ end
16
+
17
+ it "returns the class for a class name symbol" do
18
+ Fabrication::Support.class_for(:object).should == Object
19
+ end
20
+
21
+ end
22
+
23
+ context "with a class that doesn't exist" do
24
+
25
+ it "returns nil for a class name string" do
26
+ Fabrication::Support.class_for('your_mom').should be_nil
27
+ end
28
+
29
+ it "returns nil for a class name symbol" do
30
+ Fabrication::Support.class_for(:your_mom).should be_nil
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+
37
+ describe ".find_definitions" do
38
+
39
+ before(:all) do
40
+ File.open("spec/fabricators.rb", "w") do |f|
41
+ f.write("Fabricator(:awesome_object, :from => :object)")
42
+ end
43
+ File.open("spec/fabricators/cool_object.rb", "w") do |f|
44
+ f.write("Fabricator(:cool_object, :from => :object)")
45
+ end
46
+ Fabrication::Support.find_definitions
47
+ File.delete("spec/fabricators.rb")
48
+ File.delete("spec/fabricators/cool_object.rb")
49
+ end
50
+
51
+ it "has an awesome object" do
52
+ Fabrication::Fabricator.schematics[:awesome_object].should be
53
+ end
54
+
55
+ it "has a cool object" do
56
+ Fabrication::Fabricator.schematics[:cool_object].should be
57
+ end
58
+
59
+ end
60
+
61
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fabrication
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 0
10
- version: 0.6.0
9
+ - 2
10
+ version: 0.6.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul Elliott
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-31 00:00:00 -04:00
18
+ date: 2010-08-16 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -130,10 +130,10 @@ files:
130
130
  - lib/fabrication/generator/base.rb
131
131
  - lib/fabrication/generator/mongoid.rb
132
132
  - lib/fabrication/schematic.rb
133
+ - lib/fabrication/sequencer.rb
133
134
  - lib/fabrication/support.rb
134
135
  - lib/fabrication/version.rb
135
136
  - lib/fabrication.rb
136
- - spec/benchmark_spec.rb
137
137
  - spec/fabrication_spec.rb
138
138
  - spec/fabricator_spec.rb
139
139
  - spec/generator/active_record_spec.rb
@@ -146,6 +146,7 @@ files:
146
146
  - spec/support/active_record.rb
147
147
  - spec/support/helper_objects.rb
148
148
  - spec/support/mongoid.rb
149
+ - spec/support_spec.rb
149
150
  - README.markdown
150
151
  has_rdoc: true
151
152
  homepage: http://github.com/paulelliott/fabrication
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'processing speed' do
4
-
5
- context 'with activerecord objects' do
6
-
7
- before do
8
- # Fabricator(
9
- end
10
- end
11
- end