私は私のAPIをテストしようと、いくつかのユニットテストを持っている:staticメソッドが見つからない - NoMethodError - ルビー
class ClassToBeTested
def self.something_first
# Do Something
end
def self.something_second
# Do Something
end
end
私は次のようにテストクラスにそれらを呼び出す:
class MyTest < ActionDispatch::IntegrationTest
test 'should get something_first' do
assert ClassToBeTested.something_first
end
test 'should get something_second' do
assert ClassToBeTested.something_second
end
end
これで、次のエラーが発生します。
Error: MyTest#test_should_get_something_first: NoMethodError: undefined method
something_first' for ClassToBeTested test/services/my_test.rb:89:in
block in 'bin/rails test test/services/my_test.rb:88
私は多くのことを試しましたが、問題は何か分かりません。
インスタンスのメソッドは機能しますか? – user3309314
まだ試してみませんでしたが、クラスには静的メソッドしかありません – user2524707
おそらく何が間違っているのか調べるのに役立ちます。 – user3309314