我写了日志:
Logger.info(payload|>inspect)
Run Code Online (Sandbox Code Playgroud)
有效载荷是二进制格式,可能相当大.
出于调试目的,我需要完全编写它,但是,我得到:
15:04:31.269 [info] <<10, 36, 102, 102, 100, ...>>
Run Code Online (Sandbox Code Playgroud)
像这样,但我缩短了线条以适应(更大).
所以,我有这个表格声明:
<%= form_for 'students_list', {:url => update_students_list_stream_url(@stream), :method=>:patch} do |students_list_form| %>
Run Code Online (Sandbox Code Playgroud)
正如 API 文档中所述,但这会导致我出错:
No route matches [POST] "/streams/26/edit-students-list"
Run Code Online (Sandbox Code Playgroud)
所以它仍然尝试发布,即使我的 HTML 输入有:
<input type="hidden" name="_method" value="patch" />
Run Code Online (Sandbox Code Playgroud)
来自 Rails 指南:
Rails 通过使用名为“_method”的隐藏输入来模拟 POST 上的其他方法来解决此问题,该输入被设置为反映所需的方法:
我很困惑
@raw_array[i]=~/[\W]/
Run Code Online (Sandbox Code Playgroud)
非常简单的正则表达式.当我尝试使用一些非拉丁字母(俄语为具体)时,条件是错误的.
我该怎么办?
我想知道,当我尝试测试 Capybara+Rspec 功能(例如更新记录)时,我无法捕获记录是否已更新?
\n\n例如,我有测试:
\n\nscenario "updates list" do\n @student = FactoryGirl.create(:student)\n @stream.students << @student\n FactoryGirl.create(:account, :account_holder=>@student)\n visit program_stream_path(@program, @stream)\n click_link "\xd0\xa0\xd0\xb5\xd0\xb4\xd0\xb0\xd0\xba\xd1\x82\xd0\xb8\xd1\x80\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x82\xd1\x8c \xd1\x81\xd0\xbf\xd0\xb8\xd1\x81\xd0\xbe\xd0\xba \xd1\x81\xd1\x82\xd1\x83\xd0\xb4\xd0\xb5\xd0\xbd\xd1\x82\xd0\xbe\xd0\xb2"\n expect(current_path).to eq edit_students_list_stream_path(@stream)\n within("#student_0") do\n fill_in "\xd0\x98\xd0\xbc\xd1\x8f", :with => "\xd0\x98\xd0\xbc\xd1\x8f"\n fill_in "\xd0\xa4\xd0\xb0\xd0\xbc\xd0\xb8\xd0\xbb\xd0\xb8\xd1\x8f", :with => "\xd0\xa4\xd0\xb0\xd0\xbc\xd0\xb8\xd0\xbb\xd0\xb8\xd1\x8f"\n fill_in "\xd0\xad\xd0\xbb\xd0\xb5\xd0\xba\xd1\x82\xd1\x80\xd0\xbe\xd0\xbd\xd0\xbd\xd0\xb0\xd1\x8f \xd0\xbf\xd0\xbe\xd1\x87\xd1\x82\xd0\xb0", :with => "randommail@mail.ru"\n print page.html\n end\n #print page.html\n click_button "\xd0\xa1\xd0\xbe\xd1\x85\xd1\x80\xd0\xb0\xd0\xbd\xd0\xb8\xd1\x82\xd1\x8c \xd0\xb8\xd0\xb7\xd0\xbc\xd0\xb5\xd0\xbd\xd0\xb5\xd0\xbd\xd0\xb8\xd1\x8f"\n expect(current_path).to eq program_stream_path(@program, @stream)\n expect(page).to have_content "randommail@mail.ru"\n end\nRun Code Online (Sandbox Code Playgroud)\n\n通过此测试,我可以确保不存在路由错误并且操作已处理,但我无法检查记录是否确实已更新?
\n\n expect(page).to have_content "randommail@mail.ru"\nRun Code Online (Sandbox Code Playgroud)\n\n此行引发失败,但正如您所看到的,我用该值填充了电子邮件字段。在浏览器中我可以看到记录已更新。那么,Capybara 不适合测试这部分应用程序吗?
\n\n编辑:我 print page.html在提交后添加了相关输出:
<table class="table spacer">\n<tr>\n<th>\xd0\xa4\xd0\xb0\xd0\xbc\xd0\xb8\xd0\xbb\xd0\xb8\xd1\x8f …Run Code Online (Sandbox Code Playgroud) 我有模型Conversation, User,它们通过 相连has_many *, through: users_conversations。
我有这个范围:
class Conversation < ActiveRecord::Base
has_many :users_conversations
has_many :users, through: :users_conversations
scope :by_participants, ->(ids) {
joins(:users).where("users.id = ALL (ARRAY[?])", ids)
}
end
Run Code Online (Sandbox Code Playgroud)
预计会找到所有所需用户(严格)参与的对话。
Conversation.by_participants first
Failure/Error: its(:first) {is_expected.to eq(@conversation)}
ActiveRecord::StatementInvalid:
PG::UndefinedFunction: ERROR: operator does not exist: uuid = text
LINE 1: ...= "users_conversations"."user_id" WHERE (users.id = ALL (ARR...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT …Run Code Online (Sandbox Code Playgroud) 重要事项证明从18.3迁移到18.3.4会导致此问题,并且迁移回18.3会将其删除.
一切都工作到一刻.然后它只是停止工作.
def work do
HTTPotion.get("https://ssl-third-party.com",
ibrowse: [
is_ssl: true,
ssl_options: [
certfile: Path.join(File.cwd!, "cert_dev.pem"),
password: "pass" |> to_charlist,
]
])
end
Run Code Online (Sandbox Code Playgroud)
响应:
%HTTPotion.ErrorResponse{message: "closed"}
Run Code Online (Sandbox Code Playgroud)
我从iex shell尝试了几个没有elixir包装(hackney + ibrowse)的erlang库:
iex(5)> url = <<"https://ssl-third-party.com">>
iex(6)> headers = []
[]
iex(8)> payload = <<>>
""
iex(9)> options=[:insecure]
[:insecure]
iex(10)> :hackney.request(m, url, headers, payload, options)
{:error, :closed}
###
iex(1)> a = "https://ssl-third-party.com" |> to_char_list
iex(2)> :ibrowse.send_req(a, [], :get)
{:error, {:conn_failed, {:error, :closed}}}
Run Code Online (Sandbox Code Playgroud)
虽然我可以连接到其他主机.
应用程序启动,我可以从同一会话发出请求.
连接适用于简单的curl请求.
Erlang测试 - 18.3.4/19.0.2
OS X El Capitan. …
所以,这里我只想在窗口关闭时提醒true(我的意思是浏览器中的特殊标签).
$(document).ready(function(){
});
$(window).unload(function(){
alert('true'); });
Run Code Online (Sandbox Code Playgroud)
$(window)里面也尝试过$(document).ready(),没什么.
我有bookManageReducer.jsx:
import { combineReducers } from 'redux'
import {
REQUEST_BOOKS_PAGE,
RECEIVE_BOOKS_PAGE
} from '../constants/dashboardConstants'
const books = (state = [], action) => {
switch (action.type) {
case RECEIVE_BOOKS_PAGE:
return action.books
default:
return state
}
}
const booksState = (state = {isFetching: false}, action) => {
switch (action.type) {
case REQUEST_BOOKS_PAGE:
return {isFetching: true}
case RECEIVE_BOOKS_PAGE:
return {isFetching: true}
default:
return state
}
}
// ...
const booksManageReducer = combineReducers({ books, employees, employeesList, booksPagination, booksState })
export default booksManageReducer …Run Code Online (Sandbox Code Playgroud) 有这样的DOM结构:
<div class="info" id="step1">
<a href="#" id="next_step_1"> ok </a>
</div>
<div class="info" id="step2">
<a href="#" id="next_step_2"> ok </a>
</div>
<div class="info" id="step3">
<a href="#" id="next_step_3"> ok </a>
</div>
Run Code Online (Sandbox Code Playgroud)
...(等等)
Div .info有display:none属性(除了1),所以我想要实现:当我点击ok时,这个div淡出,接下来div淡入.
当然,为每个div编写函数并不是DRY,所以我尝试了这个:
for (var i=1; i<5; i++){
$("body").delegate('#next_step_'+i, 'click', function(){
$("#step"+i).fadeOut();
$("#step"+i+1).fadeIn();
});
}
Run Code Online (Sandbox Code Playgroud)
这段代码不起作用,我试过:
for (var i=1; i<5; i++){
$("body").delegate('#next_step_'+i, 'click', function(){
alert("#step"+i)
});
}
Run Code Online (Sandbox Code Playgroud)
警报工作(所以代表i是1)但警报是#step5.
这让我感到困惑,我认为JS为每个div输出5个函数...帮助我解决这个问题.
iex(1)> a = :erlang.timestamp
{1458, 585479, 931609}
iex(2)> b = :erlang.timestamp
{1458, 585484, 197713}
iex(3)> :erlang.now_diff(a,b)
** (UndefinedFunctionError) undefined function: :erlang.now_diff/2
:erlang.now_diff({1458, 585479, 931609}, {1458, 585484, 197713})
Run Code Online (Sandbox Code Playgroud)
所以我可以访问elixir中的erlang函数,访问它们:erlang,但是now_diff/2是未定义的.
我有一个想法,这个计时器不是标准的erlang模块,需要/需要/导入,但我怎么弄不清楚?
PS如果没有像这个erlang函数那样高精度计算时间戳diff的函数,请不要建议timex.我没有找到阅读文档.
elixir ×3
javascript ×2
jquery ×2
regex ×2
ruby ×2
capybara ×1
erlang ×1
postgresql ×1
react-redux ×1
reactjs ×1
redux ×1
rspec ×1