我正在使用Rails 5,并尝试使用rspec测试服务。我按照说明创建了“ spec”目录,并将测试文件放在其中。
require 'app/services/crypto_currency_service.rb'
describe CryptoCurrencyService do
describe ".sell" do
it "basic_sell" do
last_buy_price = 3000
last_transaction = MoneyMakerTransaction.new({
:transaction_type => "buy",
:amount_in_usd => "100",
:btc_price_in_usd => "#{last_buy_price}"
})
@client = Coinbase::Wallet::Client.new(api_key: ENV['COINBASE_KEY'], api_secret: ENV['COINBASE_SECRET'])
sell_price = 4000
assert sell_price > last_buy_price * (1 + MoneyMakerThreshhold.find_buy.pct_change)
allow(@client).to receive(:sell_price).and_return({"base"=>"BTC", "currency"=>"USD", "amount"=>"#{sell_price}"})
svc = CryptoCurrencyService.new
svc.sell(last_transaction)
last_transaction = MoneyMakerTransaction.find_latest_record
assert last_transaction.transaction_type, "sell"
end
end
end
Run Code Online (Sandbox Code Playgroud)
但是当我尝试运行测试时,出现此错误,抱怨无法找到我的文件...
localhost:myapp davea$ bundle exec rspec
An error occurred while loading ./spec/crypto_currency_service_spec.rb.
Failure/Error: require 'app/services/crypto_currency_service.rb'
LoadError: …Run Code Online (Sandbox Code Playgroud) 我读到 rbenv 只能用于为单个项目切换 Ruby 环境。我的系统上安装了 Ruby 2.4,但我只想将 2.3 版用于特定项目。我认为使用“rbenv local”会治愈疼痛,但它不会......
localhost:myproject davea$ rbenv local 2.3.0
localhost:myproject davea$ bundle install
Your Ruby version is 2.4.0, but your Gemfile specified 2.3.0
localhost:myproject davea$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
Run Code Online (Sandbox Code Playgroud)
我如何只在这个项目中使用 Ruby 2.3?
尽管遵循此处的建议 - Angular2 代码中的 TypeScript 错误:找不到名称 'module',我仍然收到此错误。我正在使用 Angular 5 和 npm 6.9.0。我正在尝试在这里完成本教程 - https://medium.freecodecamp.org/learn-how-to-create-your-first-angular-app-in-20-min-146201d9b5a7。
我在 ./src/app/app.component.ts 文件的顶部有这个
import { Component,trigger,animate,style,transition,keyframes } from '@angular/core';
import { FormsModule } from '@angular/forms';
@NgModule({
imports: [
BrowserModule,
FormsModule //<----------make sure you have added this.
],
})
Run Code Online (Sandbox Code Playgroud)
但是当我运行我的应用程序时出现错误
localhost:todo-app davea$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2019-05-17T17:06:29.377Z
Hash: e9b5158cd1cb6d5685c7
Time: 2561ms
chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
chunk {main} …Run Code Online (Sandbox Code Playgroud) 我正在使用 Angular 7 构建一个小项目。当你运行时
ng serve
Run Code Online (Sandbox Code Playgroud)
并且一个 NodeJS 服务器被启动来处理请求,每个请求是否阻塞直到处理完成?我们正在尝试评估在生产中使用它与使用更传统的应用程序服务器相比的效果如何。
我正在将BeautifulSoup 4与Python 3.7一起使用。我有以下HTML ...
<tr>
<td class="info"><div class="title">...</div></td>
</tr>
<tr class="ls">
<td colspan="3">Less similar results</td>
</tr>
<tr>
<td class="info"><div class="title">...</div></td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我想提取带有class =“ title”的DIV,但是,我只想在表中其TD文本=“缺少相似结果”的元素之前找到那些DIV。现在我有这个
elts = soup.find("td", class_="info").find_all("div", class_="title")
Run Code Online (Sandbox Code Playgroud)
但是,这将返回该类的所有DIV,甚至是那些我要筛选的元素之后发生的DIV。如何优化搜索以仅包含特定TD之前的结果?
我正在使用带有 Azure 函数的 Python 3.8。我有以下项目布局...
myproject
__app__
__init__.py
objects
__init__.py
tests
__init__.py
functions
__init__.py
objects
__init__.py
test_objects.py
Run Code Online (Sandbox Code Playgroud)
我的应用程序/objects/ init .py 文件像这样开始......
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
"""."""
...
Run Code Online (Sandbox Code Playgroud)
然后我的测试/函数/对象/ init .py 看起来像
import pytest
import azure.functions as func
_import = __import__('__app__/objects')
def test_objects():
...
Run Code Online (Sandbox Code Playgroud)
然而,当我跑步时
pytest tests/functions/test_objects.py
Run Code Online (Sandbox Code Playgroud)
我收到错误
tests/functions/test_objects.py:8: in <module>
_import = __import__('__app__/objects')
E ModuleNotFoundError: No module named '__app__/objects'
Run Code Online (Sandbox Code Playgroud)
引用我的函数的正确方法是什么?我也尝试了“对象”,但这会导致相同的 ModuleNotFoundError 。
I\xe2\x80\x99m 使用 Rails 6.1.4.4。我这个模型有一个 has_many
\nclass MyObject < ApplicationRecord\n\n has_many :products, inverse_of: :application, as: :item\nRun Code Online (Sandbox Code Playgroud)\n如何编写执行左外连接并在 LEFT-OUTER-JOIN-ON 子句中添加条件的作用域?我已经求助于原始sql \xe2\x80\xa6
\nscope :awaiting_funding, ->(resubmissions: false) {\n\n joins("LEFT OUTER JOIN products on products.item_id = my_objects.id and products.product_type = 11 and products.item_type = \xe2\x80\x98MyObject\xe2\x80\x99\xe2\x80\x9d).where('products.id is null')\n\n}\nRun Code Online (Sandbox Code Playgroud)\n但我想将其转换为更像 Rails 的查找器方法。
\n我正在将 Angular 13 与 NgRx/数据和实体 (v 13) 结合使用。我已经定义了以下数据服务,我希望在其中覆盖用于检索实体的 URL ...
export class MyObjectService extends DefaultDataService<MyObject> {
...
getAll(): Observable<FinanceCustomer[]> {
return this.http.get('http://localhost:8085/myapi/myobjects').pipe(
map((response: any) => {
...
return data;
})
);
}
Run Code Online (Sandbox Code Playgroud)
这一切都运行良好,但我很好奇是否可以稍微清理一下。如果我重写另一个方法,我不希望对基本 URL“http://localhost:8081/myapi/”进行两次硬编码(一次在getAll()另一个方法中)。NgRx/data 是否允许我为服务定义自定义基本 URL,然后我可以在我要重写的后续服务调用中引用该 URL?
我使用的是 Windows 10。首次登录时,我使用以下命令启动命令窗口
cmd
Run Code Online (Sandbox Code Playgroud)
然后使用运行服务
myserv -a
Run Code Online (Sandbox Code Playgroud)
我希望这一切在我登录后自动发生。当我不是管理员用户时,如何在 Windows 10 中配置此功能?
我正在使用GWT 2.4.我在TabLayoutPanel的窗格中水平布局小部件时遇到了问题.如何在没有更多可见空间的情况下水平布置面板然后将小部件包裹到下一行?松散地,我像这样创建TabLayoutPanel ......
tabsPanel = new TabLayoutPanel(BAR_HEIGHT_IN_EM, Style.Unit.EM);
for (final Node tabNode : documentNode.getChildren()) {
final ScrollPanel scrollPanel = new ScrollPanel();
...
Widget childWidget = createPanelFromWidgets(childWidgets);
...
scrollPanel.add(childWidget);
tabsPanel.add(scrollPanel, tabName);
}
public static Widget createPanelFromWidgets(final List<Widget> childWidgets) {
final FlowPanel horizPanel = new FlowPanel();
for (final Widget childWidget : childWidgets) {
horizPanel.add(childWidget);
} // for
return horizPanel;
} // createPanelFromWidgets
Run Code Online (Sandbox Code Playgroud)
我出错的任何想法?我认为文档()表示事物会自动横向排列,但我看到所有内容都是垂直排列的.
PS - HorizontalPanel不是一个选项,因为我希望我的元素在没有更多可见区域时换行.
angular ×3
python-3.x ×2
service ×2
angular13 ×1
command ×1
django ×1
finder ×1
gwt ×1
import ×1
left-join ×1
ngrx-entity ×1
node-modules ×1
node.js ×1
npm ×1
panel ×1
project ×1
pytest ×1
rbenv ×1
rspec ×1
ruby ×1
scope ×1
tdd ×1
typescript ×1
version ×1
windows-10 ×1