我很新ruby on rails
,我一直在尝试twitter-bootstrap
用作资产,所以我把它包含在我的Gemfile中,捆绑并成功安装.但是我注意到它依赖于我执行"bundle"命令时未显示的某些依赖项.
它需要的依赖性
(1) Libv8
(2) Less
(3) Less-rails
Run Code Online (Sandbox Code Playgroud)
错误信息:
cannot load such file -- less
(in c:/Sites/todo/app/assets/stylesheets/bootstrap_and_overrides.css.less)
[code]
Extracted source (around line #8):
5: <!--[if lt IE 9]>
6: <script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
7: <![endif]-->
8: <%= stylesheet_link_tag "application", :media => "all" %>
9: <%= javascript_include_tag "application" %>
10: <%= csrf_meta_tags %>
11: <meta name="viewport" content="width=device-width, initial-scale=1.0">
[/code]
Trace
app/views/layouts/application.html.erb:8:in `_app_views_layouts_application_html_erb__560528188_27183396'
app/controllers/lists_controller.rb:7:in `index'
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)
它显然会抛出错误,但我的测试仍然失败.
思考?
随着Rails的一个普通的ActiveRecord/SQL设置在控制台当我执行命令*.where
,*.all
等我回来的记录项的实际阵列.但是,在切换到Mongoid之后,我改回了一个标准.我如何获得实际结果?
这就是我现在得到的......
ruby-1.9.2-p180 :001 > App.all
=> #<Mongoid::Criteria
selector: {},
options: {},
class: App,
embedded: false>
Run Code Online (Sandbox Code Playgroud) 我是Rails和Rspec的新手,我正在使用Rspec来测试这个包含异常处理的控制器方法:
def search_movies_director
@current_movie = Movie.find(params[:id])
begin
@movies = Movie.find_movies_director(params[:id])
rescue Movie::NoDirectorError
flash[:warning] = "#{@current_movie} has no director info"
redirect_to movies_path
end
end
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚如何正确测试所述路径:无效搜索后(收到错误时)它应该重定向到主页.我试过这样的事情:
describe MoviesController do
describe 'Finding Movies With Same Director' do
#some other code
context 'after invalid search' do
it 'should redirect to the homepage' do
Movie.stub(:find)
Movie.stub(:find_movies_director).and_raise(Movie::NoDirectorError)
get :search_movies_director, {:id => '1'}
response.should redirect_to movies_path
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
运行测试后失败并显示错误: NameError: uninitialized constant Movie::NoDirectorError
如何伪造在此测试中引发错误,以便它实际检查重定向是否发生?
谢谢!
更新:
正如nzifnab解释的那样,它找不到Movie::NoDirectorError
.我忘了定义这个异常类.所以我把它添加到app/models/movie.rb
:
class Movie < ActiveRecord::Base …
Run Code Online (Sandbox Code Playgroud) 我正在运行Rails 3.0.3并且在我的迁移中意外地输入了一个拼写错误:我创建了一个迁移,它创建了一个类型为boolen
(应该已经存在boolean
)的新列.我运行了迁移,Rails并没有警告我这是一个无效的列类型,我可以在以前的版本中发誓它吗?
现在每当我尝试添加,删除或修改迁移中的任何内容时,我都会收到以下错误:
nil的未定义方法`to_sym':NilClass
我甚至无法回滚或丢弃.我有一个早期版本的数据库和文件树保存,但这个问题让我发疯,因为这不是我第一次看到这种情况发生.
如何在没有Rails抱怨的情况下有效地删除列(最好不要手动挖掘数据库)?
我是铁轨上的红宝石新手.什么时候出错了我得到了这个错误:
Template is missing
Missing template errors/error_404 with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}.
Searched in: * "C:/Users/Avi/Documents/Aptana Studio 3 Workspace/social/app/views" * "C:/RubyonRails/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/devise-2.2.4/app/views"
Run Code Online (Sandbox Code Playgroud)
但问题是语法错误或编程错误.
我可以获得错误日志,比如cakephp吗?
我正在尝试使用capistrano命令来创建数据库.我只发现了一个命令deploy:migrate
.有命令db:create
吗?
我在尝试为Rails安装gem install mysql2 -v'0.3.17'时遇到了一些问题.当我尝试通过运行gem install mysql2 -v'0.3.17'或gem install mysql2 -v'0.3.17'来安装它时,它给出了以下错误:
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--with-mysql-dir
--without-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib
--without-mysql-lib=${mysql-dir}/lib
--with-mysql-config
--without-mysql-config
Gem files will remain installed in `..../gems/ruby-1.9.3-p392/gems/mysql2-0.3.17 for inspection`.
Results logged to `.../gems/ruby-1.9.3-p392/extensions/x86_64-darwin-14/1.9.1/mysql2-0.3.17/gem_make.out`
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题并成功安装mysql2?
谢谢大家.
在我的黄瓜-jvm,Maven,junit Setup中我将testRunner文件作为
package com.lebara.testrunner;
import cucumber.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@Cucumber.Options(
glue = {"com.lebara.stepdefs","com.lebara.framework.main", "com.lebara.testrunner"},
features = "C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources",
format = {"pretty", "html:target/cucumber-html-report", "json-pretty:target/cucumber-report.json"},
tags = {"@UserJourney"}
)
public class RunCukesTest {
}
Run Code Online (Sandbox Code Playgroud)
我在上面提到的目录中有我的功能文件.
如果我运行它,我会得到以下异常:
cucumber.runtime.CucumberException: No features found at [C:/Users/sarthak.dayanand/Documents/WebRefreshTest/CukeAutomation/LebaraWebAutomationTest1/src/main/resources/cucumber]...
Run Code Online (Sandbox Code Playgroud)
如果我删除了testrunner中的"features"选项,它会尝试在与我的testrunner.java相同的目录中查找功能文件
cucumber.runtime.CucumberException: No features found at [com/lebara/testrunner]
Run Code Online (Sandbox Code Playgroud)
如果我把功能文件放在那里,它就可以了.
我的问题是为什么我的功能文件没有被我以前的位置拾取,我认为这是黄瓜 - maven设置的默认文件结构.
我如何从那里取货?帮助赞赏.
我正在解析的文档具有以下两种td
标记样式(以及其他td
标记实例):
<td align="right" nowrap bgcolor="#A1C87A">...</td>
<td align="right" nowrap>...</td>
Run Code Online (Sandbox Code Playgroud)
如何编写仅选择第二种类型的选择器,并排除所有其他td
标签?
document.css('td:not([bgcolor="#A1C87A"])')
Run Code Online (Sandbox Code Playgroud)
排除第一种类型,包括第二种类型以及所有其他td
标签.
document.css('td[align="right"][nowrap]')
Run Code Online (Sandbox Code Playgroud)
排除所有其他td
标签,但包括上述两种类型.
ruby ×3
rspec ×2
activemodel ×1
capistrano ×1
css ×1
cucumber ×1
cucumber-jvm ×1
gem ×1
html ×1
migration ×1
mongoid ×1
mysql ×1
nokogiri ×1
stubbing ×1
unit-testing ×1
web ×1