我可以在一个文件中运行所有测试:
rake test TEST=path/to/test_file.rb
Run Code Online (Sandbox Code Playgroud)
但是,如果我想在该文件中只运行一个测试,我该怎么做?
我正在寻找类似的功能:
rspec path/to/test_file.rb -l 25
Run Code Online (Sandbox Code Playgroud) 我试图期待rspec测试中的错误.
lambda {Participant.create!({:user_id => three.id, :match_id => match.id, :team => 1})}.should raise_error StandardError
Run Code Online (Sandbox Code Playgroud)
现在我只是用StandardError它来确保它正常工作.
1) StandardError in 'Participant should never allow more participants than players'.
This game is already full. Cannot add another player.
/home/josiah/Projects/Set-Match/app/models/participant.rb:12:in `do_not_exceed_player_count_in_match'
./spec/models/participant_spec.rb:24:
Run Code Online (Sandbox Code Playgroud)
它显然会抛出错误,但我的测试仍然失败.
思考?
我是Clojure的新手,我在运行单元测试时遇到了一些麻烦.
(ns com.bluepojo.scratch
(:require clojure.test))
(defn add-one
([x] (+ x 1))
)
(is (= (add-one 3) 4))
Run Code Online (Sandbox Code Playgroud)
得到:
java.lang.Exception: Unable to resolve symbol: is in this context
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
更新:
这有效:
(clojure.test/is (= (add-one 3) 4))
Run Code Online (Sandbox Code Playgroud)
我如何做到这一点,以便我不必在之前声明clojure.test?
我一直在学习Clojure,因为我来自Ruby,在Java背景之前,我在程序上思考起来很困难.
有没有更"'lispy'方式来编写这段代码,还是这样可以吗?
(defn foo
([s t]
(let [x (+ 4 (- t s))]
(if (> 2 (if (> 6 x)
x
6)
x)
x
2))))
Run Code Online (Sandbox Code Playgroud) 我在这个应用程序中使用S3来上传文件,因为Heroku有一个只读文件系统.我如何将我的s3.yml提供给Heroku,但是避免将其检入主存储库?
另一个问题(这里:)有我尝试的解决方案,但他们没有工作.
我在工作中代理,并且无法弄清楚如何让RubyGems完成它.
这里有一些输出可以帮助:
josiah@BOX-OF-DOOOM:/etc$ export HTTP_PROXY=http://jkiehl:supersecret@www-proxy.myproxysdomain.com:80/
josiah@BOX-OF-DOOOM:/etc$ sudo gem i cucumber
ERROR: http://rubygems.org/ does not appear to be a repository
ERROR: Could not find a valid gem 'cucumber' (>= 0) in any repository
josiah@BOX-OF-DOOOM:/etc$ sudo gem i -p cucumber
ERROR: While executing gem ... (OptionParser::InvalidArgument)
invalid argument: -p cucumber
josiah@BOX-OF-DOOOM:/etc$ sudo gem i -P cucumber
ERROR: While executing gem ... (OptionParser::InvalidArgument)
invalid argument: -P
josiah@BOX-OF-DOOOM:/etc$ sudo gem i --http-proxy cucumber
ERROR: While executing gem ... (OptionParser::InvalidArgument)
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?我很困惑.
我打电话的时候
myDB = this.openOrCreateDatabase("DatabaseName", MODE_PRIVATE, null);
Run Code Online (Sandbox Code Playgroud)
数据库文件在哪里创建?
我找不到任何地方.O_O
我正在使用已经存在并由其他应用程序使用的数据库.
设计数据库的人没有使用多个表名,因此DataMapper在跟随关联时选择了错误的表名.
例如:
class Foo
has n :components # => the table name here should be COMPONENT, but datamapper uses COMPONENTS
end
Run Code Online (Sandbox Code Playgroud)
我该如何改变这种行为?
ruby ×3
clojure ×2
amazon-s3 ×1
android ×1
associations ×1
coding-style ×1
database ×1
datamapper ×1
git ×1
heroku ×1
minitest ×1
proxy ×1
rspec ×1
rubygems ×1
sqlite ×1
test-is ×1
unit-testing ×1