こんにちは。
rails 4.1
rspec3.4でmodelのspecを書いています。
以下に記載するように書いているのですが、
be_validマッチャを利用した時点でvalid?メソッドが無いと言われてしまいます。
be_validの使い方やテストデータの生成方法がおかしいのでしょうか?
もしお分かりになるかたいらっしゃいましたら、教えてください!!
どうぞよろしくお願いします。
Specファイル
require 'rails_helper' RSpec.describe testModel, type: :model do let(:testModel){FactoryGirl.create(:test_model)} subject {testModel} context 'passed valid param'do context 'within test_info' do it {is_expected.to be_valid} end end
Factoryファイル
FactoryGirl.define do factory :test_model do test_info {"テキストテキスト"} end end
エラー内容
1) testModel passed valid param within test_info should be valid Failure/Error: it {is_expected.to be_valid} NoMethodError: undefined method `valid?' for #<Class:0x007fb1f9b33618> # ./spec/models/test_model.rb:8:in `block (4 levels) in <top (required)>'
model
class TestModel < ActiveRecord::Base validates :test_info, presence: true end '''
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/05/07 04:32