加载页面后,我有运行和隐藏的代码,并根据xhr返回的数据显示各种项目.
我的集成测试看起来像这样:
it "should not show the blah" do
page.find('#blah').visible?.should be_true
end
Run Code Online (Sandbox Code Playgroud)
当我在上下文中手动转到该测试运行的页面时,#blah 并不像我预期的那样可见.我怀疑Capybara正在查看页面的初始状态(在这种情况下是不可见的),在JS运行之前评估DOM的状态并且未通过测试.
是的,我设置:js => true了包含的描述块:)
任何想法将不胜感激!我希望我不必在这里故意拖延,感觉不稳定,会减慢速度.
如何从rbenv卸载或删除ruby版本.我已经安装了两个版本的ruby.切换到ruby 1.9.3时,我遇到了分段错误.任何人都可以请求帮助,如何从rbenv中删除特定版本?
我有一个rake任务,在我的rails应用程序中填充一些初始数据.例如,国家,州,移动运营商等
我现在设置它的方式是,我在/ db/fixtures中的文件中有一堆create语句,还有一个处理它们的rake任务.例如,我有一个模型是主题.我在/ db/fixtures中有一个theme.rb文件,如下所示:
Theme.delete_all
Theme.create(:id => 1, :name=>'Lite', :background_color=>'0xC7FFD5', :title_text_color=>'0x222222',
:component_theme_color=>'0x001277', :carrier_select_color=>'0x7683FF', :label_text_color=>'0x000000',
:join_upper_gradient=>'0x6FAEFF', :join_lower_gradient=>'0x000000', :join_text_color=>'0xFFFFFF',
:cancel_link_color=>'0x001277', :border_color=>'0x888888', :carrier_text_color=>'0x000000', :public => true)
Theme.create(:id => 2, :name=>'Metallic', :background_color=>'0x000000', :title_text_color=>'0x7299FF',
:component_theme_color=>'0xDBF2FF', :carrier_select_color=>'0x000000', :label_text_color=>'0xDBF2FF',
:join_upper_gradient=>'0x2B25FF', :join_lower_gradient=>'0xBEFFAC', :join_text_color=>'0x000000',
:cancel_link_color=>'0xFF7C12', :border_color=>'0x000000', :carrier_text_color=>'0x000000', :public => true)
Theme.create(:id => 3, :name=>'Blues', :background_color=>'0x0060EC', :title_text_color=>'0x000374',
:component_theme_color=>'0x000374', :carrier_select_color=>'0x4357FF', :label_text_color=>'0x000000',
:join_upper_gradient=>'0x4357FF', :join_lower_gradient=>'0xffffff', :join_text_color=>'0x000000',
:cancel_link_color=>'0xffffff', :border_color=>'0x666666', :carrier_text_color=>'0x000000', :public => true)
puts "Success: Theme data loaded"
Run Code Online (Sandbox Code Playgroud)
这里的想法是我想为用户安装一些股票主题.我有这个方法的问题.
设置ID不起作用.这意味着如果我决定添加一个主题,让我们称之为"红色",那么我只想将主题语句添加到此fixture文件并调用rake任务来重新设置数据库.如果我这样做,因为主题属于其他对象,并且在重新初始化时它们的id发生了变化,所有链接都会被破坏.
我的问题首先是,这是处理数据库播种的好方法吗?在上一篇文章中,我向你推荐了这个.
如果是这样,我怎么能对ID进行硬编码,这有什么缺点吗?
如果没有,那么种子数据库的最佳方法是什么?
我将真正感谢包含最佳实践的长期和深思熟虑的答案.
我看到在Ruby(和动态类型语言,通常)中,一种非常常见的做法是传递散列,而不是声明具体的方法参数.例如,不是使用参数声明一个方法,而是像这样调用它:
def my_method(width, height, show_border)
my_method(400, 50, false)
Run Code Online (Sandbox Code Playgroud)
你可以这样做:
def my_method(options)
my_method({"width" => 400, "height" => 50, "show_border" => false})
Run Code Online (Sandbox Code Playgroud)
我想知道你对它的看法.这是好事还是坏事,我们应该这样做吗?在什么情况下使用这种做法是有效的,它有什么危险的情况?
我正在尝试使用Net::HTTP.get()https网址:
@data = Net::HTTP.get(uri, Net::HTTP.https_default_port())
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试打印结果时,我得到以下结果:
无法将URI :: HTTPS转换为String
这是怎么回事?我正在使用Ruby 1.8.7(OS X)
我rvm用来管理不同的红宝石及其宝石.我的shell是zsh,配置了基本设置的oh-my-zsh.启用oh-my-zsh插件是ruby,rails,osx和git.这是我用来安装ruby-1.8.7和rails-3.0.7的命令.
rvm install 1.8.7
rvm use 1.8.7
gem install rails -v=3.0.7
Run Code Online (Sandbox Code Playgroud)
然后我打字rails并得到:
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
Run Code Online (Sandbox Code Playgroud)
我也尝试过更彻底的安装,比如rubygems在切换到ruby-1.8.7之后重新安装,或创建一个全新的gemset,但没有运气.
这是rvm信息:
ruby-1.8.7-p352@rails:
system:
uname: "Darwin yicai.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"
rvm: …Run Code Online (Sandbox Code Playgroud) 我想获取created_at字段小于今天(日期)的所有记录.有什么像:
MyTable.find_by_created_at(< 2.days.ago)
Run Code Online (Sandbox Code Playgroud) 我已成功安装rvm,但是当我运行以下命令时
sudo apt-get update
Run Code Online (Sandbox Code Playgroud)
要么:
rvm install 2.0.0
Run Code Online (Sandbox Code Playgroud)
我有以下错误:
W: Failed to fetch http://ppa.launchpad.net/cheleb/blender-svn/ubuntu/dists/precise/main/source/Sources 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/cheleb/blender-svn/ubuntu/dists/precise/main/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/cheleb/blender-svn/ubuntu/dists/precise/main/binary-i386/Packages 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/ferramroberto/oneiric/ubuntu/dists/precise/main/source/Sources 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/ferramroberto/oneiric/ubuntu/dists/precise/main/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/ferramroberto/oneiric/ubuntu/dists/precise/main/binary-i386/Packages 404 Not Found
Run Code Online (Sandbox Code Playgroud)
我该如何解决这些错误?
我无法理解为什么Cocoapod无法找到我运行时创建的pod规范pod install.有人能帮我解决这个问题吗?
我正在我的库podspec文件中定义一个子规范,如下所示:
s.subspec 'mysubspec' do |c|
c.dependency 'ABC','1.0.0'
end
Run Code Online (Sandbox Code Playgroud)
此依赖关系ABC列在库Podfile中:
pod 'ABC', :git => 'git@github.com:myrepo/Podspecs.git', :branch => 'xyz'
Run Code Online (Sandbox Code Playgroud)
ABC.podspecmyrepo/Podspecs分支xyz中的Podspec文件如下所示:
Pod::Spec.new do |s|
s.name = "ABC"
s.version = "1.0.0"
s.source = { :git => "git@github.com:myrepo/Podspecs.git", :branch => "xyz" }
end
Run Code Online (Sandbox Code Playgroud)
错误是 [!] Unable to find a specification for ABC (= 1.0.0)
解决方案: 在导入子规范之前导入pod ABC并将标记添加到podspec.