yannlugrin-rspec-factory-girl 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,12 @@
1
1
  = RSpec - Factory Girl
2
2
 
3
- RSpec matcher collection for testing your model builded with factory girl.
3
+ RSpec matcher collection for testing your model built with factory girl.
4
4
 
5
5
  describe Post do
6
- it { should be_builded_by_factory } # Factory named ':post' is used
6
+ it { should be_built_by_factory } # Factory named ':post' is used
7
7
  it { should be_created_by_factory } # Factory named ':post' is used
8
8
 
9
- it { should be_builded_by_factory(:my_factory) }
9
+ it { should be_built_by_factory(:my_factory) }
10
10
  it { should be_created_by_factory(:my_factory) }
11
11
  end
12
12
 
@@ -42,9 +42,22 @@ Or using git submodules:
42
42
 
43
43
  == Requirements
44
44
 
45
+ * activerecord >= 2.3.2
45
46
  * factory_girl >= 1.2.0
46
47
  * rspec >= 1.2.0
47
- * rspec-rails >= 1.2.0 (only for rails projects)
48
+ * rspec-rails >= 1.2.0
49
+
50
+ == RubyGems
51
+
52
+ RubyGems is not required by this library, if you have a LoadError when you run rake tasks, use
53
+ follwing command:
54
+
55
+ RUBYOPT="rubygems" rake
56
+
57
+ or export RUBYOPTS before launch rake tasks:
58
+
59
+ RUBYOPT="rubygems"
60
+ export RUBYOPT
48
61
 
49
62
  == More information
50
63
 
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 1
2
+ :patch: 0
3
3
  :major: 0
4
- :minor: 1
4
+ :minor: 2
@@ -1,3 +1,3 @@
1
1
  require 'spec/factory_girl/matchers/base'
2
- require 'spec/factory_girl/matchers/be_builded_by_factory'
3
- require 'spec/factory_girl/matchers/be_created_by_factory'
2
+ require 'spec/factory_girl/matchers/be_built_by_factory'
3
+ require 'spec/factory_girl/matchers/be_created_by_factory'
@@ -38,7 +38,7 @@ module Spec
38
38
  begin
39
39
  Factory.create(@factory)
40
40
  rescue ActiveRecord::RecordInvalid => e
41
- @errors << "model have uniqu validation, use sequence in factory (#{e.to_s})"
41
+ @errors << "model has uniqueness validation, use sequence in factory (#{e.to_s})"
42
42
  return false
43
43
  end
44
44
 
@@ -1,7 +1,7 @@
1
1
  module Spec
2
2
  module FactoryGirl
3
3
  module Matchers
4
- class BeBuildedByFactory < Spec::FactoryGirl::Matchers::Base
4
+ class BeBuiltByFactory < Spec::FactoryGirl::Matchers::Base
5
5
  def description
6
6
  "build instance of '#{@target}' by factory '#{@factory}'"
7
7
  end
@@ -14,18 +14,18 @@ module Spec
14
14
  super
15
15
  end
16
16
 
17
- def failure_message
17
+ def failure_message_for_should
18
18
  "expected #{@target.inspect} to be build by factory '#{@factory}'\n" + @errors.join("\n")
19
19
  end
20
20
 
21
- def negative_failure_message
21
+ def failure_message_for_should_not
22
22
  "expected #{@target.inspect} not to be build by factory '#{@factory}'"
23
23
  end
24
24
  end
25
25
 
26
- def be_builded_by_factory(factory = nil)
27
- BeBuildedByFactory.new(factory)
26
+ def be_built_by_factory(factory = nil)
27
+ BeBuiltByFactory.new(factory)
28
28
  end
29
29
  end
30
30
  end
31
- end
31
+ end
@@ -19,11 +19,11 @@ module Spec
19
19
  super
20
20
  end
21
21
 
22
- def failure_message
22
+ def failure_message_for_should
23
23
  "expected #{@target.inspect} to be created by factory '#{@factory}'\n" + @errors.join("\n")
24
24
  end
25
25
 
26
- def negative_failure_message
26
+ def failure_message_for_should_not
27
27
  "expected #{@target.inspect} not to be created by factory '#{@factory}'"
28
28
  end
29
29
  end
@@ -13,7 +13,7 @@ describe 'Factory' do
13
13
  end
14
14
  subject { SimpleModel }
15
15
 
16
- it { should be_builded_by_factory }
16
+ it { should be_built_by_factory }
17
17
  it { should be_created_by_factory }
18
18
  end
19
19
 
@@ -26,7 +26,7 @@ describe 'Factory' do
26
26
  end
27
27
  subject { SimpleModel.new }
28
28
 
29
- it { should be_builded_by_factory }
29
+ it { should be_built_by_factory }
30
30
  it { should be_created_by_factory }
31
31
  end
32
32
 
@@ -39,7 +39,7 @@ describe 'Factory' do
39
39
  end
40
40
  subject { SimpleModel }
41
41
 
42
- it { should be_builded_by_factory(:another_model) }
42
+ it { should be_built_by_factory(:another_model) }
43
43
  it { should be_created_by_factory(:another_model) }
44
44
  end
45
45
 
@@ -53,7 +53,7 @@ describe 'Factory' do
53
53
  end
54
54
  subject { SimpleModel }
55
55
 
56
- it { should_not be_builded_by_factory(:simple_model) }
56
+ it { should_not be_built_by_factory(:simple_model) }
57
57
  it { should_not be_created_by_factory(:simple_model) }
58
58
  end
59
59
 
@@ -66,7 +66,7 @@ describe 'Factory' do
66
66
  end
67
67
  subject { SimpleModel }
68
68
 
69
- it { should be_builded_by_factory(:simple_model) }
69
+ it { should be_built_by_factory(:simple_model) }
70
70
  it { should be_created_by_factory(:simple_model) }
71
71
  end
72
72
 
@@ -79,7 +79,7 @@ describe 'Factory' do
79
79
  end
80
80
  subject { SimpleModel }
81
81
 
82
- it { should be_builded_by_factory(:simple_model) }
82
+ it { should be_built_by_factory(:simple_model) }
83
83
  it { should be_created_by_factory(:simple_model) }
84
84
  end
85
85
 
@@ -94,7 +94,7 @@ describe 'Factory' do
94
94
  end
95
95
  subject { SimpleModel }
96
96
 
97
- it { should_not be_builded_by_factory(:simple_model) }
97
+ it { should_not be_built_by_factory(:simple_model) }
98
98
  it { should_not be_created_by_factory(:simple_model) }
99
99
  end
100
100
 
@@ -110,11 +110,11 @@ describe 'Factory' do
110
110
  end
111
111
  subject { SimpleModel }
112
112
 
113
- it { should be_builded_by_factory(:simple_model) }
113
+ it { should be_built_by_factory(:simple_model) }
114
114
  it { should be_created_by_factory(:simple_model) }
115
115
  end
116
116
 
117
- context 'without sequence for uniqu attribute' do
117
+ context 'without sequence for unique attribute' do
118
118
  before(:each) do
119
119
  define_model(:simple_model, :name => :string) do
120
120
  validates_uniqueness_of :name
@@ -125,23 +125,27 @@ describe 'Factory' do
125
125
  end
126
126
  subject { SimpleModel }
127
127
 
128
- it { should_not be_builded_by_factory(:simple_model) }
128
+ it { should_not be_built_by_factory(:simple_model) }
129
129
  it { should_not be_created_by_factory(:simple_model) }
130
130
  end
131
131
 
132
- context 'with sequence for uniqu attribute' do
132
+ context 'with sequence for unique attribute' do
133
133
  before(:each) do
134
134
  define_model(:simple_model, :name => :string) do
135
135
  validates_uniqueness_of :name
136
136
  end
137
137
 
138
+ Factory.sequence :name do |n|
139
+ "name #{n}"
140
+ end
141
+
138
142
  Factory.define :simple_model do |model|
139
- model.sequence(:name) {|n| "name #{n}" }
143
+ model.name { Factory.next(:name) }
140
144
  end
141
145
  end
142
146
  subject { SimpleModel }
143
147
 
144
- it { should be_builded_by_factory(:simple_model) }
148
+ it { should be_built_by_factory(:simple_model) }
145
149
  it { should be_created_by_factory(:simple_model) }
146
150
  end
147
151
  end
@@ -1,9 +1,7 @@
1
- require 'spec'
2
-
3
- $LOAD_PATH.unshift(File.dirname(__FILE__))
4
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
1
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
2
+ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
5
3
 
6
- require 'rubygems'
4
+ require 'spec'
7
5
  require 'activerecord'
8
6
  require 'factory_girl'
9
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yannlugrin-rspec-factory-girl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yann Lugrin
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-18 00:00:00 -07:00
12
+ date: 2009-04-09 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -29,8 +29,8 @@ files:
29
29
  - lib/spec/factory_girl
30
30
  - lib/spec/factory_girl/matchers.rb
31
31
  - lib/spec/factory_girl/matchers
32
- - lib/spec/factory_girl/matchers/be_builded_by_factory.rb
33
32
  - lib/spec/factory_girl/matchers/base.rb
33
+ - lib/spec/factory_girl/matchers/be_built_by_factory.rb
34
34
  - lib/spec/factory_girl/matchers/be_created_by_factory.rb
35
35
  - lib/spec/factory_girl.rb
36
36
  - spec/factory_girl_spec.rb
@@ -64,6 +64,6 @@ rubyforge_project:
64
64
  rubygems_version: 1.2.0
65
65
  signing_key:
66
66
  specification_version: 2
67
- summary: Rspec matcher collection for testing your model builded with factory girl
67
+ summary: Rspec matcher collection for testing your model built with factory girl
68
68
  test_files: []
69
69