我是一个刚接触Rails的Django人。我正在尝试让rspec-rails为我工作,但是当我运行
$ bundle exec rails generate rspec:install
我明白了..。
Could not find diff-lcs-1.2.5 in any of the sources
Run `bundle install` to install missing gems.
这很麻烦,因为
diff-lcs (1.2.5)
在Gemfile.lock中我已经删除了Gemfile.lock并重新运行了包,但是没有用。我也添加了gem 'diff-lcs‘到我的Gemf
我正在尝试在一个非常基本的ruby项目(不是rails)上设置一个测试,但无法找到使其工作的方法。我遵循了指南,它只是安装gem,运行bundle安装并添加到我的spec/spec_helper.rb配置中:
RSpec.configure do |config|
config.include FactoryBot::Syntax::Methods
config.before(:suite) do
FactoryBot.find_definitions
end
end
然后,我在spec文件夹中创建了一个工厂/order_factories.rb文件,如下所示:
Fact
我目前正在设置一些Cucumber测试,我的Hook文件包含以下内容:
require 'watir'
Before do
@browser = Watir::Browser.new :chrome
end
After do
@browser.close
end
当我运行我的功能文件时,我得到了以下内容:
cannot load such file -- watir (LoadError)
/Users/marklane/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/rubygems/custom_require.rb:36:i
我有一个关于gem ZenTest的问题,我的gemfile中没有ZenTest,当我想用“rails generate integration_test layout link”生成一个集成测试时,我有这个错误:
could not find ZenTest-4.11.0 in any any of the source
所以我尝试了bundle install和bundle update,但是没有什么改变,我也尝试安装ZenTest,我仍然有同样的错误
gemefile.lock:
specs:
abstract (1.0.0)
actionmailer (3.0.7)
actionp
我刚刚用bundler创建了一个新的gem,并将rspec作为开发依赖项添加到了gemspec中。
rspec版本为3.2.0
bundle --binstubs
bin/rspec
输出为:
Bundler is using a binstub that was created for a different gem. ... stack level too deep
这是什么?当我输入"rspec“时,一切正常,但是bin/rspec有什么问题呢?
附注:我在一个新gem中使用了带有独立gemset的RVM,Ruby的版本是2.2.0
附言:我的捆绑包是:
Using rake 1
当我在env.rb中要求'active_record‘时,我得到了错误
constant Logger::Format not defined (NameError)
/usr/local/rvm/gems/ruby-1.9.3-p125@test/gems/activerecord-1.6.0/lib/active_record/support/clean_logger.rb:5:in remove_const' /usr/local/rvm/gems/ruby-1.9.3-p125@test/gems/activerecord-1.6.0/lib/active_record
我在做一个宝石。
尽管指定了activemodel的版本,但gem实际上使用的是activemodel 4.0.0。从4.0.0开始,构造函数只接受一个参数。因此,当我尝试传递第二个参数时,会得到一个参数错误:
/Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-4.0.0/lib/active_record/core.rb:180:in `initialize': wrong number of arguments (2 for 1) (ArgumentError)
为什么Rubygem
好的,所以我正在做下面的Ruby教程:
并且我已经将所有的文件保存在c:/learn_ruby下
当我在目录"00_hello“中运行rake时,我得到以下错误:
c:\learn_ruby\00_hello>rake
(in c:/learn_ruby)
rake aborted!
Could not find 'rspec' (~> 2) - did find: [rspec-3.0.0]
Checked in 'GEM_PATH=C:/Users/******/.gem/ruby/1.9.1;C:/Ruby193/lib/ruby/gems/1
我在Cucumber给出无法使用的错误消息时遇到了麻烦,或者它可能是我可以更改的Rails中的设置?这就是我的错误消息的样子:
expected to find text "edit" in "Internal Server Error undefined method `empty?' for nil:NilClass WEBrick/1.3.1 (Ruby/2.0.0/2013-05-14) at lvh.me:58126" (RSpec::Expectations::ExpectationNotMetError)
./features
我试图在两个html文本的主体之间产生一个类似于人类可读的wiki差异。我使用的是diff-lcs,第一步是将字符串(字符数组)分成一个句子数组,但保留它们的标点符号。
"I am a lion. Hear me roar! Where is my cub? Never mind, found him.".magic_split(/[.?!]/)
# => "I am a lion." "Hear me roar!" "Where is my cub?" "Never mind, found him."
这应
我安装了最新的Rspec gem和依赖项,但是当我调用script/rails generate rspec:install时,我得到这个错误:找不到生成器rspec:install。
怎么了?
Ruby 1.9.2和Rails 3.0.3
我的捆绑包列表:
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.3)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.3)
Using erubis (2.6.6)
Using
在运行规范文件时,我会收到以下错误:
我读过以下几个问题,但没有用:
我不确定我是否用rspec和factory_girl正确地设置了Ruby项目。以下是相关的文件:
player.rb
class Player
attr_accessor :name
def initialize(string)
@name = string
end
end
players.rb (工厂)
require './player'
FactoryGirl.define do
factory :player do
name
这不是我第一次遇到这种情况,但下面是一个具体的例子:
$ bundle update rails
Fetching source index for http://rubygems.org/
Bundler could not find compatible versions for gem "builder":
In Gemfile:
rails (~> 3.0.0) ruby depends on
builder (~> 2.1.2) ruby
hoptoad_notifier (>= 0) ruby depends on
当我使用"spec xxx.rb“测试某些ruby代码时,我得到了以下错误:
Missing these required gems:
webrat ~> 0.4.4
You're running:
ruby 1.8.7.174 at /usr/local/bin/ruby
rubygems 1.3.5 at /root/.gem/ruby/1.8, /usr/local/lib/ruby/gems/1.8
Run `rake gems:install` to install the missing gems.
我已经在运行0.5.3宝石了。以下是我的服
您的帮助我们将不胜感激。我是编程新手,我想尝试开始alexch的Learn_Ruby,但我被困在了第一课: 00_hello。我正在运行"rake“测试,我收到了奇怪的错误:
Justins-MacBook-Pro:00_hello Justin$ rake
(in /Users/Justin/Desktop/learn_ruby-master)
rake aborted!
undefined method `gem' for main:Object
/Users/Justin/Desktop/learn_ruby-master/Rakefile:2
(See full tra
我在/home/david/apps/jruby上安装了jruby,但没有在.bash_profile中设置。我在.bash_profile的/home/david/apps/ruby/bin有红宝石布景。
我创建了一个hello world的宝石。
/home/david/apps/jruby/bin/jruby -S rake install
test 0.0.1 built to pkg/test-0.0.1.gem
test (0.0.1) installed
然后
/home/david/apps/jruby/bin/jruby -S gem list --local
*** LO