Quantcast
Channel: HAPPY*TRAP » Ruby
Viewing all articles
Browse latest Browse all 12

Rails + VCRでActiveRecord::Fixture::FormatError

$
0
0


Rails + VCRでHTTPのリクエスト/レスポンスをキャプチャして、その結果を読み込むと以下のようなエラーになりました。

ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError

VCRの出力したYAMLをみても、特にフォーマットに問題なさそうで困ったのですが、GitHubのissuesに回避方法がありました。

The issue can be fixed by:
* Moving the vcr fixtures outside of rails fixtures (using the corresponding vcr config method)
VCR Cassettes inside test/fixtures on Rails 3 · Issue #9 · vcr/vcr

曰く、VCRの出力場所をRailsのfixturesディレクトリの外に設定するとよい、とのこと。

1
2
# c.cassette_library_dir = 'test/fixtures/vcr_cassettes' # エラー
c.cassette_library_dir = 'test/vcr_cassettes'

試してみたところ、無事、エラーが解消しました。感謝。


環境
CentOS6.4
Ruby2.0.0p247
Rails4.0.1
Vcr2.7.0

Viewing all articles
Browse latest Browse all 12

Trending Articles