rails4でrspecでテストを書こうと思って、factory_girlを使ってみたら
エラー出たのでそのときの対応
まずはバージョンを確認
gem list抜粋
factory_girl (4.4.0)
factory_girl_rails (4.4.1)
rails (4.1.4)
rspec (3.0.0)
rspec-core (3.0.4)
rspec-expectations (3.0.4)
rspec-mocks (3.0.4)
rspec-rails (3.0.2)
rspec-support (3.0.4)
テスト対象のテーブル
mysql> desc seq_sometest4s;
+--------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+------------+------+-----+---------+-------+
| id | int(10) | NO | PRI | 0 | |
| seq_id | bigint(10) | YES | | NULL | |
+--------+------------+------+-----+---------+-------+
2 rows in set (0.01 sec)
spec_helper.rbにfactory_girlの設定を追加
require 'factory_girl_rails'
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.use_transactional_fixtures = true
config.order = "random"
config.include FactoryGirl::Syntax::Methods
config.before do
FactoryGirl.reload
end
end
config/application.rbにもfactory_girlの設定を追加
config.generators do |g|
g.test_framework :rspec, :fixture => true, :fixture_replacement => :factory_girl
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
end
テストコード
$ cat spec/models/concerns/seq_table_spec.rb
require 'spec_helper'
describe "SeqTable" do
describe "seq_incrment" do
FactoryGirl.build(:seq_sometest4)
end
end
テストを実行するとエラーになりました。
$ bundle exec rspec spec/models/concerns/seq_table_spec.rb
seq_sometest4
/Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/registry.rb:33:in `find': Factory not registered: seq_sometest4 (ArgumentError)
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/decorator.rb:10:in `method_missing'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl.rb:91:in `factory_by_name'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/factory_runner.rb:12:in `run'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
from /Users/xxx/Documents/github/test20140812/test-api/spec/models/concerns/seq_table_spec.rb:6:in `block (2 levels) in '
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:331:in `module_exec'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:331:in `subclass'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:227:in `block in define_example_group_method'
from /Users/xxx/Documents/github/test20140812/test-api/spec/models/concerns/seq_table_spec.rb:4:in `block in '
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:331:in `module_exec'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:331:in `subclass'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:227:in `block in define_example_group_method'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/dsl.rb:41:in `block in expose_example_group_alias'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/dsl.rb:79:in `block (2 levels) in expose_example_group_alias_globally'
from /Users/xxx/Documents/github/test20140812/test-api/spec/models/concerns/seq_table_spec.rb:3:in `'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `block in load_spec_files'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `each'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load_spec_files'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:97:in `setup'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in `run'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/exe/rspec:4:in `'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/bin/rspec:23:in `load'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/bin/rspec:23:in `'
ちょっとググってみたところ、spec_helper.rbに以下を追加するとよいとあったので入れてみました。
requireの下に
FactoryGirl.find_definitions
そして再度テストを実行してみたところ、またエラーが出ました。
$ bundle exec rspec spec/models/concerns/seq_table_spec.rb
/Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:16: warning: File.exists? is a deprecated name, use File.exist? instead
/Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:16: warning: File.exists? is a deprecated name, use File.exist? instead
/Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:16: warning: File.exists? is a deprecated name, use File.exist? instead
/Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/inflector/methods.rb:238:in `const_get': uninitialized constant SeqSometest4 (NameError)
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/inflector/methods.rb:238:in `block in constantize'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/inflector/methods.rb:236:in `each'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/inflector/methods.rb:236:in `inject'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/inflector/methods.rb:236:in `constantize'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/factory.rb:26:in `build_class'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/factory.rb:37:in `run'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/factory_runner.rb:23:in `block in run'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/notifications.rb:161:in `instrument'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/factory_runner.rb:22:in `run'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
from /Users/xxx/Documents/github/test20140812/test-api/spec/models/concerns/seq_table_spec.rb:6:in `block (2 levels) in '
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:331:in `module_exec'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:331:in `subclass'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:227:in `block in define_example_group_method'
from /Users/xxx/Documents/github/test20140812/test-api/spec/models/concerns/seq_table_spec.rb:4:in `block in '
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:331:in `module_exec'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:331:in `subclass'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/example_group.rb:227:in `block in define_example_group_method'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/dsl.rb:41:in `block in expose_example_group_alias'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/dsl.rb:79:in `block (2 levels) in expose_example_group_alias_globally'
from /Users/xxx/Documents/github/test20140812/test-api/spec/models/concerns/seq_table_spec.rb:3:in `'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `block in load_spec_files'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `each'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load_spec_files'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:97:in `setup'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in `run'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/exe/rspec:4:in `'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/bin/rspec:23:in `load'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/bin/rspec:23:in `'
ちょっと原因がわからなかったので、railsコマンドでもう一度modelを作ってみました。
specファイルの中身を見ると、requireの記述が違います。
$ bundle exec rails g model seq_sometest4 id:integer seq_id:integer
invoke active_record
create db/migrate/20140827015707_create_seq_sometest4s.rb
identical app/models/seq_sometest4.rb
invoke rspec
create spec/models/seq_sometest4_spec.rb
invoke factory_girl
identical spec/factories/seq_sometest4s.rb
$ cat spec/models/seq_sometest4_spec.rb
require 'rails_helper'
RSpec.describe SeqSometest4, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'rails_helper'に変更して再度テストを実行してみましたが、またエラーになりました。。
$ bundle exec rspec spec/models/concerns/seq_table_spec.rb
/Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/decorator.rb:10:in `method_missing': Factory already registered: seq_sometest4 (FactoryGirl::DuplicateDefinitionError)
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/decorator/disallows_duplicates_registry.rb:6:in `register'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl.rb:85:in `block in register_factory'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl.rb:84:in `each'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl.rb:84:in `register_factory'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:20:in `factory'
from /Users/xxx/Documents/github/test20140812/test-api/spec/factories/seq_sometest4s.rb:4:in `block in '
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:49:in `instance_eval'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:49:in `run'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/syntax/default.rb:7:in `define'
from /Users/xxx/Documents/github/test20140812/test-api/spec/factories/seq_sometest4s.rb:3:in `'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `block in load'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:20:in `block (2 levels) in find_definitions'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:19:in `each'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:19:in `block in find_definitions'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:15:in `each'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl-4.4.0/lib/factory_girl/find_definitions.rb:15:in `find_definitions'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/factory_girl_rails-4.4.1/lib/factory_girl_rails/railtie.rb:21:in `block in '
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/lazy_load_hooks.rb:36:in `call'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/lazy_load_hooks.rb:44:in `each'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.4/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/application/finisher.rb:64:in `block in '
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `run'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/xxx/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /Users/xxx/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /Users/xxx/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /Users/xxx/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /Users/xxx/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /Users/xxx/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /Users/xxx/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /Users/xxx/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /Users/xxx/.rbenv/versions/2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/railties-4.1.4/lib/rails/application.rb:300:in `initialize!'
from /Users/xxx/Documents/github/test20140812/test-api/config/environment.rb:5:in `'
from /Users/xxx/Documents/github/test20140812/test-api/spec/rails_helper.rb:4:in `require'
from /Users/xxx/Documents/github/test20140812/test-api/spec/rails_helper.rb:4:in `'
from /Users/xxx/Documents/github/test20140812/test-api/spec/models/concerns/seq_table_spec.rb:1:in `require'
from /Users/xxx/Documents/github/test20140812/test-api/spec/models/concerns/seq_table_spec.rb:1:in `'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `block in load_spec_files'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `each'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load_spec_files'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:97:in `setup'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in `run'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/gems/rspec-core-3.0.4/exe/rspec:4:in `'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/bin/rspec:23:in `load'
from /Users/xxx/Documents/github/test20140812/test-api/vendor/bundle/ruby/2.1.0/bin/rspec:23:in `'
先ほど付け足したspec_helper.rbのFactoryGirl.find_definitionsを削除して再度実行したら、
今度はエラーにならずに動きました。
テスト自体は書いてないので0件です。
$ bundle exec rspec spec/models/concerns/seq_table_spec.rb
No examples found.
Finished in 0.00033 seconds (files took 3.61 seconds to load)
0 examples, 0 failures
require 'rails_helper'が肝だった訳ですが、ちゃんとrailsコマンドで最初から作っていれば
エラーにはまらずに済んでたと思うので、あるものはちゃんと使わないといけないですね。
参考URL
http://dev.classmethod.jp/server-side/ruby-on-rails/ruby-on-rails_factorygirl/
https://github.com/thoughtbot/factory_girl/blob/master/GETTING_STARTED.md
http://thinkit.co.jp/story/2014/07/08/5092/page/0/2
http://stackoverflow.com/questions/9300231/factory-already-registered-user-factorygirlduplicatedefinitionerror
http://stackoverflow.com/questions/8409787/factorygirl-factory-not-registered-user-argumenterror
http://qiita.com/youcune/items/3a1e4ef76e71da43e043
http://j-caw.co.jp/blog/?p=1042
http://source.hatenadiary.jp/entry/2014/02/06/222318