我mini-test用于测试框架.我使用omniauthgem进行身份验证.我simplecov用于代码覆盖.我用"bundle exec rake"或运行我的测试"rake minitest:controllers".我举一个控制器的例子.当我运行时rake minitest:controllers,控制器代码覆盖率变为100%.但是,当我运行时bundle exec rake,控制器代码覆盖率变为60%.
SessionsController.rb代码:
class SessionsController < ApplicationController
def create
auth = request.env["omniauth.auth"]
person=Person.find_by_provider_and_uid(auth.provider,auth.uid) || Person.create_with_omniauth(auth)
redirect_to root_path
end
end
Run Code Online (Sandbox Code Playgroud)
SessionsController_test.rb
require "minitest_helper"
describe SessionsController do
before do
request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:identity]
@person = Fabricate.build(:person)
end
it "should create authentication" do
assert_difference('Person.count') do
post :create, :provider => "identity"
end
assert_redirected_to root_path @person
end
end
Run Code Online (Sandbox Code Playgroud)
我想知道如果我在写测试时错过了一点.我等你的想法.提前致谢.
minitest_helper.rb
require 'simplecov'
Simplecov.start
ENV["RAILS_ENV"] = "test" …Run Code Online (Sandbox Code Playgroud) 我将离子框架用于我的混合移动应用程序.默认情况下,页面转换是从左到右滑动到android.我想改变这种效果.例如,我想将此效果作为滑动到顶部.如何更改离子的视图过渡效果?提前致谢...
我使用asp.net-mvc,实体框架.我的观点如下:
<td class="center">
<span id="spanitem_@item.UrunId">@item.Fiyat</span>
<input type="text" id="textfiyat_@item.UrunId" value="" class="displaynone textwidth90"/>
</td>
<td class="center">
<span id="spanitem_@item.UrunId">@item.Adet</span>
<input type="text" id="textadet_@item.UrunId" value="" class="displaynone textwidth90"/>
</td>
<td class="center">
<span id="spanitem_@item.UrunId">
@item.Fiyat)*@item.Adet
</span>
</td>
Run Code Online (Sandbox Code Playgroud)
Fiyat字段为十进制,Adet字段为int.我想展示他们的倍增.但是我不能.我怎样才能做到这一点.谢谢...
如何测试方法的参数?
def create_person child
end
Run Code Online (Sandbox Code Playgroud)
上面的代码是我的方法.它需要一个名为"child"的参数.我尝试测试这个参数.所以,如果方法没有参数,测试会给我错误.我使用minitest和Ruby on Rails.