I have Ruby code that uses inverse elements in several places and you want to test it. I am using FlexMock and want to mock this method somehow. I know that the Kernel ,: ` method , but cannot make it work with FlexMock. How would you do that? Here is a sample method that I want to test:
def foo result = `ls` if result.to_a.length > 0 true else false end end
, , backticks Kernel.`, , FlexMock, , . , , , - ? ! , backtick .
, , . , pierr, , , . , , .
flexmock, .
Kernel.` "cmd"
`cmd`
. :
it "should call system ls" do Kernel.should_receive(:`).with("ls") Kernel.` "ls" end
rspec
Source: https://habr.com/ru/post/1721255/More articles:The best open source database for a large web application - databaseIcon conflict IRQ - assemblyHow can I cancel a cancel / redo operation? - undoInitializing C # Generators Using Type Values - genericsOpening pdf in .NET - .netAutomatically split large SQL Server database tables - sql-serverAutomatically creating CRUD forms for .net Windows Forms applications - ormPyGTK video list height - pythonCtrl + Arrows: which algorithm or standard? - javascriptIs using CSS CSS styles a waste of time? - flexAll Articles