测试 rails 源码里的测试如何运行啊

ane · November 26, 2014 · Last by flowerwrong replied at November 26, 2014 · 4184 hits

我跑 activemodel 里的测试文件提示错误,应该怎么测试?

====================================================================================

最近也觉得 gem 有点乱了,所以花了点时间重新整理了一下,重新执行 bundle install 的时候,依旧提示 2-1-stable 的错误。

最后结论是,原来自己 fork 了分支的 master 和原来 rails/rails 的 master 不是一个分支,自己 fork 的分支会将指引到一个 gemfile 是调用 github 地址的 2-1-stable.大家多注意一下。可以用 git tag 看看应该切到那个分支

rake -T
rake test # 测试全部
ruby -Ilib:test test/minitest/test_minitest_unit.rb # 测试单个文件

#1 楼 @flowerwrong 问题就是会报错,估计是环境问题,我看看吧

#3 楼 @flowerwrong 先是


/Users/ane/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/bundler-1.7.6/lib/bundler/source/git/git_proxy.rb:151:in `allowed_in_path': The git source git://github.com/rails/arel.git is not yet checked out. Please run `bundle install` before trying to start your application (Bundler::GitError)
    from /Users/ane/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/bundler-1.7.6/lib/bundler/source/git/git_proxy.rb:47:in `revision'
    from /Users/ane/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/gems/bundler-1.7.6/lib/bundler/source/git.rb:212:in `revision'

然后我就 bundle install

Updating git://github.com/rails/arel.git
Fetching git://github.com/rails/sprockets-rails.git
fatal: ambiguous argument '2-1-stable': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Git error: command `git rev-parse 2-1-stable` in directory
/Users/ane/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/cache/bundler/git/sprockets-rails-b90575d71445d74093061ab2de02b6c006ea5b4a
has failed.
If this error persists you could try removing the cache directory
'/Users/ane/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/cache/bundler/git/sprockets-rails-b90575d71445d74093061ab2de02b6c006ea5b4a'

然后我就 mv 这个文件&bundle install

结果还是

Updating git://github.com/rails/arel.git
Fetching git://github.com/rails/sprockets-rails.git
fatal: ambiguous argument '2-1-stable': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Git error: command `git rev-parse 2-1-stable` in directory
/Users/ane/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/cache/bundler/git/sprockets-rails-b90575d71445d74093061ab2de02b6c006ea5b4a
has failed.
If this error persists you could try removing the cache directory
'/Users/ane/.rbenv/versions/2.0.0-p576/lib/ruby/gems/2.0.0/cache/bundler/git/sprockets-rails-b90575d71445d74093061ab2de02b6c006ea5b4a'

#4 楼 @ane https://github.com/rails/sprockets-rails/branches 2-1-stable 已经被移除了,现在2-2,两天前的事

#5 楼 @flowerwrong 好像是这么回事,刚刚也是搜到这结果

#6 楼 @ane 我翻看了所有 gemspec,没找到哪里依赖sprockets-rails,你更新看下,或许已经 fix 了。另外我奇怪他为什么从github取,我没有看到在哪里有定义。

#7 楼 @flowerwrong 你的测试没问题?

#8 楼 @ane 你是bundle install就卡了?

我刚测试了下bundle exec rake test_sqlite3

Finished in 334.927932s, 12.7819 runs/s, 35.1568 assertions/s.

4281 runs, 11775 assertions, 0 failures, 0 errors, 2 skips

#9 楼 @flowerwrong 奇怪了

➜  activemodel git:(master) ✗ bundle install
Updating git://github.com/rails/arel.git
fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository
Retrying git fetch --force --quiet --tags 'git://github.com/rails/arel.git' "refs/heads/*:refs/heads/*" due to error (2/3): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags 'git://github.com/rails/arel.git' "refs/heads/*:refs/heads/*"` in directory /Users/ane/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/cache/bundler/git/arel-8151ac946644aab31601d7c0ed944eb9d7ea1e6b has failed.
If this error persists you could try removing the cache directory '/Users/ane/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/cache/bundler/git/arel-8151ac946644aab31601d7c0ed944eb9d7ea1e6b'
fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository
Retrying git fetch --force --quiet --tags 'git://github.com/rails/arel.git' "refs/heads/*:refs/heads/*" due to error (3/3): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags 'git://github.com/rails/arel.git' "refs/heads/*:refs/heads/*"` in directory /Users/ane/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/cache/bundler/git/arel-8151ac946644aab31601d7c0ed944eb9d7ea1e6b has failed.
If this error persists you could try removing the cache directory '/Users/ane/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/cache/bundler/git/arel-8151ac946644aab31601d7c0ed944eb9d7ea1e6b'
fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository
Git error: command `git fetch --force --quiet --tags 'git://github.com/rails/arel.git'
"refs/heads/*:refs/heads/*"` in directory
/Users/ane/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/cache/bundler/git/arel-8151ac946644aab31601d7c0ed944eb9d7ea1e6b
has failed.
If this error persists you could try removing the cache directory
'/Users/ane/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/cache/bundler/git/arel-8151ac946644aab31601d7c0ed944eb9d7ea1e6b'

我没看出来,试下

gem update --system # 更新gem
gem update # 更新已安装gem

gem list | grep bundler # 列出已安装的bundler版本
gem cleanup bundler # 移除旧版本

https://github.com/bundler/bundler/issues/1947

You need to Sign in before reply, if you don't have an account, please Sign up first.