我想在黄瓜功能文件的后台步骤中添加一个示例表.我该怎么做呢?
我想做这样的事情:
Background:
Given <username> has logged in
Examples:
|username|
|User 1 |
|User 2 |
Scenario: .....
Run Code Online (Sandbox Code Playgroud) 我目前正在阅读Peter Hilton的"Play for Scala".我刚刚完成了第一个示例Play应用程序的结束,您可以在其中构建回形针目录.
但是在编译时我得到一个编译错误,告诉我没有找到值'flash'.通常这是我犯过的一个简单的错误,但鉴于我只是按照书中的指南我无法确定修复.
错误位于"NewProduct"函数的第52行和第53行
这是代码:
package controllers
import play.api.mvc.{Action, Controller}
import models.Product
import play.api.data.Form
import play.api.data.Forms.{mapping, longNumber, nonEmptyText}
import play.api.i18n.Messages
import play.api.mvc.Flash
object Products extends Controller {
private val productForm: Form[Product] = Form(
mapping(
"ean" -> longNumber.verifying(
"validation.ean.duplicate", Product.findByEan(_).isEmpty),
"name" -> nonEmptyText,
"description" -> nonEmptyText
)(Product.apply)(Product.unapply)
)
def list = Action {implicit request =>
val products = Product.findAll
Ok(views.html.products.list(products))
}
def show(ean: Long) = Action {implicit request =>
Product.findByEan(ean).map {product =>
Ok(views.html.products.details(product))
}.getOrElse(NotFound)
}
def save = Action …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用来自不同文件的类.
something.rb
class Something
def initialize
end
def getText
'Some example text'
end
end
Run Code Online (Sandbox Code Playgroud)
another.rb
class Another
end
somethingVar = Something.new
puts somethingVar.getText
Run Code Online (Sandbox Code Playgroud)
这给了我错误
/usr/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /home/chris/RubymineProjects/untitled1/another.rb
/home/chris/RubymineProjects/untitled1/another.rb:4:in `<top (required)>': uninitialized constant Something (NameError)
from -e:1:in `load'
from -e:1:in `<main>'
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?