是否可以在rspec中測試複數函數?Rails rspec factorygirl複數測試
let(:schedule) { FactoryGirl.create(:schedule) }
Failure/Error: it { should have_selector('h1', text: pluralize(Schedule.count.to_s, "schedule")) }
NoMethodError:
undefined method `pluralize' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xb607068c>
答:(爲指出由以下埃裏克·C)
describe SchedulesHelper do
describe "pluralize schedule" do
if(Schedule.count > 0)
it { pluralize(1, "schedule").should == "1 schedule" }
else
it { pluralize(0, "schedule").should == "0 schedules" }
end
end
end
您似乎沒有測試複數方法。您似乎在測試是否存在某個html,並且您正在使用pluralize方法來幫助您。你問是否可以用複數方法測試? –
是的。是否有可能測試'pluralize'? – janejanejane