minitest

    -1热度

    1回答

    考虑到以下目录结构: “Hello World” 的 ➜ ~/D/w/t/foo tree . . ├── app.rb ├── foo.rb └── test └── test_foo.rb 1 directory, 3 files 如果我跑app.rb我得到的经典响应。 ➜ ~/D/w/t/foo ruby app.rb "Hello world!" 以一看,里

    0热度

    1回答

    我从4.2 - > 5.0.0.1升级了我的Rails应用程序。 其他试验工作正常(如型号,助手,功能),但havinf麻烦我控制器测试。 我在控制器&集成测试了解关键字参数在滑轨5.所以我改变了代码结构如下... ::的ActionView ::模板错误:无不是有效的资产来源 setup do @logo = plogos(:main_logo) end test "should

    0热度

    1回答

    如何测试方法,我有这个类: require 'yaml' class Configuration class ParseError < StandardError; end attr_reader :config def initialize(path) @config = YAML.load_file(path) rescue => e

    1热度

    1回答

    class Post def save Mailer.notify!('bla') true end end 如何测试当post.save被调用时,Mailer.notify方法被触发?并有正确的论点。 使用RSpec我通常做的: expect(Mailer).to receive(:notify!).with('bla') post.save

    0热度

    1回答

    我正在使用Rails 5 API,Pundit和一切进展顺利。我试图测试这个特定的情况,如果你不是资源所有者,你不应该能够查看该用户的信息。 因此,我得到了一些用户夹具的样本数据,莎拉和吉姆是他们中的两个。 我这里得到这个测试案例: test "user show - cannot show other user's info" do get user_path(@sarah), hea

    0热度

    1回答

    我正在写一个控制器测试,我想验证控制器1的call_dashboard_function。 class Controller1 < ApplicationController before_action :init_dashb def call_dashboard_function @dashb.do_something! end def in

    0热度

    2回答

    我的控制器看起来像这样的输出: class CalculatorController < ApplicationController def calculate money = params[:money].to_f @worktime = divide(money, 25) end private def divide(money

    1热度

    2回答

    我有这个模型称为地区和Admin # regions.yml one: name: test two: name: test2 # admins.yml one: name: admin1 two: name: admin2 有定义为JSON柱(store_accessor: :region_ids)上admin.rb列。我如何参考admin

    0热度

    1回答

    我想在Minitest上存根使用Mocha返回另一个存根的函数。 这是代码 @instance = stub('instance') do stubs(:destroy).returns(true) stubs(:id).returns(0) end find_by_id = stub do stubs(:find_by_id).returns(nil) #

    0热度

    1回答

    我想测试显示在页面上的值,显示的数值是代码: <% @user ||= current_user %> <div class="stats"> <a href="<%= following_user_path(@user) %>"> <strong id="following" class="stat"> **<%= @user.following.count %