小编mir*_*lon的帖子

Capybara匹配存在按钮或链接

网页上的用户不区分"按钮"和"链接样式为按钮".有没有办法添加检查页面上是否有"按钮或链接"?

比如Capybara有步骤:

page.should have_button('Click me')
Run Code Online (Sandbox Code Playgroud)

找不到按钮设置的链接.

ruby-on-rails capybara

29
推荐指数
2
解决办法
2万
查看次数

IntelliJ IDEA 13调试器不会在java for maven项目的断点处停止

我在System.out.println("test")命令行上有一个断点.我相信命令是通过执行来达到的,因为我看到打印的字符串"test".但断点被忽略了.

断点始终是一个红色圆圈,没有勾或十字.我认为这是一个问题,当IDEA认为该类未加载时,因为该命令已执行.

我可以在各种情况下重现它:

  1. 当我按下调试(使用maven配置install exec:exec -DforkMode=never)

  2. 远程调试 - 我在控制台中以调试模式运行maven目标:

    mvnDebug install exec:exec -DforkMode=never

    要么

    mvnDebug install exec:exec

    IDEA中的远程调试配置:

    • 运行远程JVM的参数:
      -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000
    • 对于JDK 1.4.X:
      -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
    • 运输:插座
    • 调试器模式:附加
    • 主持人:localhost
    • 港口:8000

在这两种情况下,调试器只打印"连接到目标VM,地址:'localhost:8000',传输:'socket'"

我也试过File > Invalidate Caches / Restart 并清理构建,但断点仍然被忽略.

组态:

Ubuntu 13.10
IntelliJ IDEA Ultimate build 133.944
Apache Maven 3.0.4
Java版本:1.7.0_51,供应商:Oracle Corporation
操作系统名称:"linux",版本:"3.11.0-17-generic",arch:"amd64",family: "UNIX"

编辑:pom.xml的相关部分:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.2.1</version>
  <configuration>
    <executable>java</executable>
      <arguments>
        <argument>-D--secret--.server.configuration=/usr/local/etc</argument>
        <argument>-classpath</argument><classpath/>
        <argument>com.--secret--.Server</argument>
      </arguments>
  </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

java debugging breakpoints intellij-idea maven

18
推荐指数
1
解决办法
4万
查看次数

检查数组是否在coffeescript中有一些项目

coffeescript中是否有一些方法在数组中包含一些项时返回true?像ruby中的方法一样present?:

[].present? false
[1].present? true
Run Code Online (Sandbox Code Playgroud)

根据http://arcturo.github.com/library/coffeescript/07_the_bad_parts.html,coffeescript中的数组空虚由其长度决定

alert("Empty Array")  unless [].length
Run Code Online (Sandbox Code Playgroud)

这对我来说似乎很蹩脚.

arrays coffeescript

13
推荐指数
2
解决办法
2万
查看次数

将scala future转换为java future

我有一个生成的java接口,包含一个方法:

public Future<?> getCustomersAsync(AsyncHandler<Customer> asyncHandler);
Run Code Online (Sandbox Code Playgroud)

我想用Akka实现它.我写了以下内容:

override def getCustomerAsync(asyncHandler: AsyncHandler[Customer]): Future[_] = {
  myActorRef.ask(GetCustomer, system.actorOf(Props[Responder]))
}
Run Code Online (Sandbox Code Playgroud)

问题是ask退货scala.concurrent.Future[Any]和方法必须返回java.util.concurrent.Future[?].

Error:(33, 17) type mismatch;
 found   : scala.concurrent.Future[Any]
 required: java.util.concurrent.Future[?]
    myActorRef.ask(GetCustomer, system.actorOf(Props[Responder]))
                  ^
Run Code Online (Sandbox Code Playgroud)

我该怎么做这个转换?

java scala future akka scala-java-interop

13
推荐指数
2
解决办法
4782
查看次数

更改颜色时,Highcharts区域fillOpacity不起作用

我想要一个不透明度为0.1的面积图.如果我没有指定颜色,一切正常:

plotOptions: {
    series: {
        fillOpacity: 0.1
    }
}
series: [{
   name: '1',
   data: [1,2,3],
   type: 'area'
}
Run Code Online (Sandbox Code Playgroud)

但是当我更改颜色时,忽略不透明度:

plotOptions: {
    series: {
        fillOpacity: 0.1
    }
}
series: [{
   name: '2',
   data: [0,1,2],
   type: 'area'
   color: 'red'
}
Run Code Online (Sandbox Code Playgroud)

http://jsfiddle.net/4HkXf/

opacity highcharts

12
推荐指数
2
解决办法
2万
查看次数

绑定popstate事件不起作用

我试图在浏览器的控制台中输入以下代码:

window.onpopstate = function() {alert(1);}
Run Code Online (Sandbox Code Playgroud)

然后单击后退按钮.没有警报显示.难道我做错了什么?或者是否不允许将popstate事件从控制台绑定到页面?

使用Chrome 24和Firefox 18

javascript firefox google-chrome browser-history popstate

7
推荐指数
2
解决办法
1万
查看次数

以任何顺序匹配多个收益率

我想使用rspec测试迭代器.在我看来,唯一可能的产量匹配器是yield_successive_args(根据https://www.relishapp.com/rspec/rspec-expectations/v/3-0/docs/built-in-matchers/yield-matchers).其他匹配器仅用于单一屈服.

但是yield_successive_args如果屈服是以指定的其他顺序而失败.

是否有任何方法或很好的解决方法来测试以任何顺序产生的迭代器?

类似于以下内容:

expect { |b| array.each(&b) }.to yield_multiple_args_in_any_order(1, 2, 3)
Run Code Online (Sandbox Code Playgroud)

ruby iterator rspec yield ruby-on-rails

7
推荐指数
1
解决办法
343
查看次数

IntelliJ不断从akka教程中删除context.dispatcher的导入

我正在关注akka-in-action教程,在第2章中,有一个类(https://github.com/RayRoestenburg/akka-in-action/blob/master/chapter2/src/main/scala/com/ goticks/RestInterface.scala):

trait RestApi extends HttpService with ActorLogging { actor: Actor =>
  import context.dispatcher
  import com.goticks.TicketProtocol._
  ...
Run Code Online (Sandbox Code Playgroud)

import context.dispatcher从未使用过,但它与评论定义:

  /**
   * Returns the dispatcher (MessageDispatcher) that is used for this Actor.
   * Importing this member will place an implicit ExecutionContext in scope.
   */
  implicit def dispatcher: ExecutionContextExecutor
Run Code Online (Sandbox Code Playgroud)

但是,IntelliJ会将导入标记为"未使用",并在"优化导入"时将其删除,从而导致错误value pipeTo is not a member of scala.concurrent.Future[Any].

有没有办法告诉IntelliJ这个导入不打算"使用",而只是简单地提供一个上下文?

或者是否应该更新教程以不使用这种"未使用的导入"?

scala intellij-idea akka executioncontext

7
推荐指数
1
解决办法
2228
查看次数

记录Akka中的所有消息,而不修改所有接收方法

我想将所有收到的消息记录到我的Akka应用程序中的所有演员.akka.actor.debug.receive如果actor接收方法是a,则有一个配置将记录发送给actor的所有消息LoggingReceive.

根据http://doc.akka.io/docs/akka/current/additional/faq.html,它表示包装所有接收方法,LoggingReceive如同如何记录来自Akka(Java)的所有传入消息

def receive = {
  LoggingReceive {
    case x ? // do something
  }
}
Run Code Online (Sandbox Code Playgroud)

有没有办法隐式地或通过配置?

logging scala messages akka

6
推荐指数
1
解决办法
905
查看次数

找不到案例类的JsonWriter或JsonFormat类型

按照http://www.smartjava.org/content/first-steps-rest-spray-and-scala上的教程,有一些意外的错误消息.到底是怎么回事?我是否通过implicit val personFormat = jsonFormat3(Person)调用定义了隐式JsonWriter ?

scala> import spray.json.DefaultJsonProtocol
import spray.json.DefaultJsonProtocol

scala> object MyJsonProtocol extends DefaultJsonProtocol {
  implicit val personFormat = jsonFormat3(Person)
}
     |      | defined object MyJsonProtocol

scala> case class Person(name: String, fistName: String, age: Long)
defined class Person

scala> import spray.json._
import spray.json._

scala> import MyJsonProtocol._
import MyJsonProtocol._

scala> Person(name="a", fistName="b", age = 10).toJson
<console>:45: error: Cannot find JsonWriter or JsonFormat type class for Person
              Person(name="a", fistName="b", age = 10).toJson
                                                       ^
Run Code Online (Sandbox Code Playgroud)

json scala spray-json

6
推荐指数
1
解决办法
4666
查看次数