stub

    2熱度

    1回答

    我剛開始玩弄PHPUnit,想知道是否可以用存根覆蓋/替換方法。我有興農一定的經驗,並與興農這是可能的(http://sinonjs.org/docs/#stubs) 我想是這樣的: <?php class Foo { public $bar; function __construct() { $this->bar = new Bar(); }

    2熱度

    1回答

    我有一個Mailer看起來是這樣的: class EventMailer < BaseMailer def event_added(user_id, event_id) # do stuff and email user about the event end end 我打電話這個EventMailer這樣從Event類中: class Event < Task

    0熱度

    1回答

    當我嘗試將購物車分配給相關訂單時,訂單將從數據庫中再次加載該購物車,並且我的存根到購物車丟失。 (訂單belongs_to的車) cart = create(:cart) allow(cart).to receive(:total){ Money.new(100,'USD') } subject.cart = cart # subject.cart.total != Money.new(10

    0熱度

    1回答

    我似乎無法殘留我的@current_user,以便我的before_filter:login_required通過,我得到正確的模板,而不是重定向到登錄屏幕。 這裏是我的控制器規格: before(:each) do allow(controller).to receive(:current_user).and_return FactoryGirl.build(:signed_up_us

    0熱度

    1回答

    我正在使用rspec和webmock,並且正在研究stubbing請求。我嘗試使用正則表達式來匹配URI時遇到問題。 一切工作正常,當我用下面的存根,沒有匹配特定URI (/.*/) it "returns nil and stores an error when the response code is not OK" do stub_request(:get, /.*/).

    9熱度

    1回答

    我正在使用Codeception \ Util \ Stub創建單元測試。我想確保我的方法被多次調用。爲此,我正在使用「完全」方法。 例子: use \UnitTester; use \Codeception\Util\Stub as StubUtil; class someCest { public function testMyTest(UnitTester $I)

    1熱度

    1回答

    我使用獼猴桃測試一些類,我需要存根類方法只是爲了返回一個假的文件路徑。 我知道我可以解決暴露一些路徑屬性或創建一個子類只是爲了測試,但我優先保留只有一個類和存根的一些方法。 這是測試: it(@"return the full list of POS", ^(){ NSString *sample_data_path = [[NSBundle bundleForClass:[self c

    3熱度

    1回答

    如何從所包含的模塊中存根:超級方法。我有以下控制器: class ImportsController < BaseController include ImportBackend def import_from_file super rescue TransferPreview::Error => exc flash[:error] = "Som

    -3熱度

    1回答

    我正在寫一個C++程序,它接受輸入作爲EXE文件,加密它(只是xoring),並將加密EXE作爲資源添加到另一個EXE(存根)。 存根(stub)解密exe並保存它。問題是解密後的exe不會運行。字節相同,我可以在PE編輯器中打開解密的exe文件,但它不會運行。 有什麼建議嗎?

    1熱度

    2回答

    我正在爲一個控制器編寫請求規範,並且我希望通過AJAX調用另一個控制器的方法。 AJAX調用中的控制器操作用於對地址進行地理定位,並與請求的其餘部分無關。控制器動作總是不呈現任何內容。 我已經試過: before :each AddressesController.any_instance.stub(:update).and_return nil end 然而,這給了我一個錯誤: