我正在使用Jasmine BDD Javascript库并且非常享受它.我有测试代码,我想重用(例如,测试基类的多个实现或在稍微不同的上下文中运行相同的测试),我不知道如何使用Jasmine.我知道我可以将代码从jasmine函数移到可重用的类中,但我喜欢代码读取散布Jasmine函数的方式(描述,它),我不想将规范与测试代码分开,除非我不得不.有没有人使用Jasmine遇到这个问题,你是如何处理它的?
我正在开发一个Android应用程序项目Cordova
,在我有一个简单的Sqlite
数据库.
--------------------
ID | Name | Number |
--------------------
Run Code Online (Sandbox Code Playgroud)
由于我是Android应用程序的新手,我只是准备好了UI.我有两个text inputs
,一个<div>
显示表数据的标签和3 buttons
.当用户点击每列时,弹出窗口显示删除或编辑行内容.
这是HTML
UI 的代码:
<body>
<h1>My first App</h1>
<p>Open Database</p>
<div id="qrpopup" > //The hidden div tag for implementing the popup
<hr/>
<input type="text" id="editNameBox"><br>
<input type="text" id="editNumberBox"><br>
<button onclick="goDelete()">Delete</button>
<button onclick="goEdit()">Edit</button>
<button onclick="document.getElementById('qrpopup').style.display='none';">Discard</button>
</div>
<div>
Name<input type="text" value="Name" id="txtName">
Number<input type="text" value="123" id="txtNumber"><hr/>
</div>
<div id="tblDiv"></div>
<div style="text-align: center">
<button onclick="goInsert()">Insert</button>
<button onclick="goSearch()">Search</button>
<button onclick="successCB()">Show All</button>
</div>
</body> …
Run Code Online (Sandbox Code Playgroud) 每当两个并发HTTP请求转到我的Rails应用程序时,第二个总是返回以下错误:
ApplicationController的副本已从模块树中删除但仍处于活动状态!
从那里它给出了一个无益的堆栈跟踪效果"我们经历了标准服务器的东西,在ApplicationController上运行了你的第一个before_filter (我检查过;它只是先运行哪个过滤器) ",然后提供以下内容:
/home/matchu/rails/torch/vendor/rails/activesupport/lib/active_support/dependencies.rb:414:in"load_missing_constant'
/home/matchu/rails/torch/vendor/rails/activesupport/lib/active_support/dependencies.rb:96:in`const_missing'
我假设是一个通用的回应,并没有真正说太多.
谷歌似乎告诉我,开发Rails引擎的人会遇到这种情况,但我不这样做.我所做的就是将我的Rails应用程序从2.2(2.1?)升级到2.3.
导致此错误的可能原因是什么,以及如何跟踪实际发生的情况?我知道这个问题很模糊,所以其他任何信息都有帮助吗?
更重要的是:我刚刚尝试在"生产"环境中进行测试,并且错误似乎不会持续存在.那么这只会影响发展吗?我不需要太担心吗?
我有一个表单,我正在尝试设置...用户可以有很多帖子,每个帖子都可以有很多人观看它.
Watch模型以多态形式设置为"可观察",因此它可以应用于不同类型的模型.它具有user_id,watchable_id,watchable_type和时间戳作为属性/字段.
这是非常好的,所以当人们评论帖子时,观看帖子的用户可以收到有关它的电子邮件.
我要做的是向用户显示他们可以在每个帖子上标记的用户列表,这不是问题.这就是我现在正在使用的
<% semantic_form_for @update do |f| %>
<%= f.input :subject, :input_html => { :class => 'short' } %>
<%= f.input :site, :include_blank => false, :input_html => { :class => 'short' } %>
<label>Tag Users (they will get notified of this update)</label>
<%= f.input :user, :as => :check_boxes, :label => ' ', :wrapper_html => { :class => "radiolist clearfix" }, :for => :watch, :name => "Watch" %>
<%= f.input :note, :label => 'Update'%>
<% f.buttons do %>
<%= …
Run Code Online (Sandbox Code Playgroud) 我有两个很多很多的模型.他们在我的应用程序的第一页上使用,我在加载它们时遇到问题.
两个型号只有少量项目(<200),我想在每个findAll
请求中完全加载两个模型.但是当第一个模型被加载时,Ember开始逐项获取第二个模型的缺失数据.如果我尝试单独加载模型,我会收到错误并且必须设置{async:true}
为hasMany
attr.出于某种原因,Ember没有认识到第二个模型的请求的json.
无论如何都要获取两个模型并等到两个负载再继续之前?
谢谢.
与RSpec和Capybara合作,我得到了一个有趣的测试失败模式,它在测试用例中有一些细微的线条重排......这些都不重要.
我正在开发自己的身份验证系统.它目前正在工作,我可以使用浏览器和会话工作等登录/退出.但是,尝试测试这是失败的.正在发生的事情我不太明白,这似乎取决于(看似)不相关的电话的顺序.
require 'spec_helper'
describe "Sessions" do
it 'allows user to login' do
#line one
user = Factory(:user)
#For SO, this method hashes the input password and saves the record
user.password! '2468'
#line two
visit '/sessions/index'
fill_in 'Email', :with => user.email
fill_in 'Password', :with => '2468'
click_button 'Sign in'
page.should have_content('Logged in')
end
end
Run Code Online (Sandbox Code Playgroud)
原样,该测试失败......登录失败.在将'调试器'调用插入规范和控制器后,我可以看到原因:就控制器而言,用户没有插入数据库:
编辑在ApplicationController中添加
class ApplicationController < ActionController::Base
helper :all
protect_from_forgery
helper_method :user_signed_in?, :guest_user?, :current_user
def user_signed_in?
!(session[:user_id].nil? || current_user.new_record?)
end
def guest_user?
current_user.new_record?
end
def current_user …
Run Code Online (Sandbox Code Playgroud) $scope.displayyears = [];
$scope.Joinyear = function(display) {
$scope.yeardisplay = display;
$scope.yeardisp = $scope.displayyears.push($scope.yeardisplay);
$scope.displayyearss = uniq($scope.yeardisp)
}
Run Code Online (Sandbox Code Playgroud)
它抛出错误,如"uniq未定义"..我们如何检查唯一性?
我正在尝试推送一个先前因网络中断而中断的容器.但我得到这个错误:
Error: push rimian/ruby-node-npm is already in progress
Run Code Online (Sandbox Code Playgroud)
但是当我跑步时,我docker ps
看不到任何动态.
我该怎么办?
如果我在Javascript中有一个看起来像的数组
searchComponents = ['element1', 'element2', 'element3'];
Run Code Online (Sandbox Code Playgroud)
将它变成如下句子的必要逻辑是什么:
"element1,element2和element3"
同样,如果只有两个元素,它应该如下:
"element1和element2"
等等等等.我被卡住了.
我想输出其中一个选择字段供用户选择他们的时区.我的用户模型将时区保存为以秒为单位的整数.但如果不实际,我可以改变它.
像这样的东西:
<select>
...
<option value="x">+9:00 (Darwin, Australia)</option>
<option value="x">+10:00 (Sydney, Australia)</option>
...
</select>
Run Code Online (Sandbox Code Playgroud)
我看到Ruby on Rails中有一个Time Class ...有人能指出我正确的方向吗?
javascript ×3
android ×1
angularjs ×1
arrays ×1
bdd ×1
capybara ×1
cordova ×1
docker ×1
ember-data ×1
ember.js ×1
factory-bot ×1
formtastic ×1
jasmine ×1
rspec-rails ×1
rspec2 ×1
ruby ×1
rubygems ×1
sqlite ×1
string ×1
timezone ×1