これは私のwork_spec.rbファイルのようです。そのコードの実行中にby_letterundefinedメソッドエラーが発生します。
require 'spec_helper'
require 'factory_girl_rails'
describe Work do
it "has a valid factory" do
FactoryGirl.create(:work).should be_valid
end
it "is invalid without a last_name" do
FactoryGirl.build((:work), last_name: nil).should be_valid
end
it "returns a sorted array of result that match" do
smith = FactoryGirl.create((:work), last_name: "smith")
jones = FactoryGirl.create((:work), last_name: "jones")
johnson = FactoryGirl.create((:work), last_name: "johnson")
Work.by_letter("j").should == [johnson, jones]
end
end
Error receved while running
Work returns a sorted array of result that match
Failure/Error: Work.by_letter("j").should == [johnson, jones]
NoMethodError:
undefined method `by_letter' for #<Class:0x0000000429a708>
# ./spec/models/work_spec.rb:17:in `block (2 levels) in <top (required)>'