- 浏览: 269667 次
- 性别:
- 来自: 尤溪
文章分类
最新评论
-
palytoxin:
我现在也发现是这样
关于分享 -
float2net:
Java社区,分享有利于提高。
关于分享 -
hz_qiuyuanxin:
头晕啊,啊邱
RSpec学习笔记 -
reyesyang:
...
关于分享 -
Hooopo:
一般实现map都先实现each
在 Ruby 中对树状结构(tree)进行 map 操作
=======Rails2=======
用RSpec测试Authlogic的Session时,调用Session.new出现如下错误:
You must activate the Authlogic::Session::Base.controller with a controller object before creating objects
解决办法:在spec_helper.rb中添加一行代码:
Spec::Runner.configure do |config| #...... config.include(Authlogic::TestCase) end
然后在Session的测试中加一句:
before :each do #.... activate_authlogic end
===================================
RubyToolBox上看到各种Rails Fixture Replacement工具中,FactoryGirl排名第一。但是居然有这样一个问题:无论我在spec/下建立一个factories.rb文件或者是在spec/factories/下建立一个*.rb文件,FactoryGirl都无法加载到,最后看源代:
if defined? Rails.configuration Rails.configuration.after_initialize do Factory.definition_file_paths = [ File.join(RAILS_ROOT, 'test', 'factories'), File.join(RAILS_ROOT, 'spec', 'factories') ] Factory.find_definitions end else Factory.find_definitions end
发现这个after_initialize方法中的block不会执行,估计是测试环境不会触发这个after_initialize。搜索到这个帖子:http://groups.google.com/group/factory_girl/browse_thread/thread/8add0361e717c240
由于访问google group需要特殊技能,所以copy一份过来:
ook?ook! 写道
Just try: it doesn't, but thank you for the idea.
I'm reading the lib bootstrapper, and it looks like Factory add its
definition file only when Rails is loaded. Debugging the thing, I'm
realizing that Rails.configuration is not yet instance, meaning that I'm not
requiring FG where it expect it.
Trying to initiate FG in environments/test lead to correct beahvior, but why
preventing FG to load factories if not in Rails? It's not a big deal, but I
think FG should load its definition path even if not in a standard Rails
way… I think I'll propose a patch where FG tolerate the fact FG is not
require in environnment.
RFC?
I'm reading the lib bootstrapper, and it looks like Factory add its
definition file only when Rails is loaded. Debugging the thing, I'm
realizing that Rails.configuration is not yet instance, meaning that I'm not
requiring FG where it expect it.
Trying to initiate FG in environments/test lead to correct beahvior, but why
preventing FG to load factories if not in Rails? It's not a big deal, but I
think FG should load its definition path even if not in a standard Rails
way… I think I'll propose a patch where FG tolerate the fact FG is not
require in environnment.
RFC?
由于是上班时间,没有空多作研究,暂时先把代码注释掉一些:
#if defined? Rails.configuration # Rails.configuration.after_initialize do Factory.definition_file_paths = [ File.join(RAILS_ROOT, 'test', 'factories'), File.join(RAILS_ROOT, 'spec', 'factories') ] Factory.find_definitions # end #else # Factory.find_definitions #end
使用正常。
评论
1 楼
yuan
2010-05-10
delayed_job 2.0.0 ~ 2.0.3存在问题,可用的最新版本号为1.8.5。
searchlogic2.4.x 在调用form.check_box时报错:undefined method to_id。目前可用的最新版本为2.3.5。
searchlogic2.4.x 在调用form.check_box时报错:undefined method to_id。目前可用的最新版本为2.3.5。
发表评论
-
rails测试中遇到的一些问题
2010-09-03 11:41 24481,页面的测试。 假设某view中有一个表单,表单里有3个字段 ... -
BDD on Rails
2010-05-11 02:59 0首先,嘿嘿,我对敏捷 ... -
强大的 Rails 2 查询、搜索插件:SearchLogic
2010-04-20 23:31 5342发现还有人在看这个博客,这个 SearchLogic 只支持 ... -
authlogic-openid
2010-04-20 00:32 0http://github.com/binarylogic/a ... -
测试驱动开发实战(authlogic学习笔记)
2010-04-17 00:06 0这会是个很cool的笔记 cucumber还不会用,只用R ... -
RoR简单培训。
2010-04-12 10:08 0目的 上周二Bob给大家从总体上概括了一下Rails的开发。我 ... -
用RSpec和Webrat为页面写测试
2010-03-10 23:26 0The RSpec Book 23章(不完全照书上记,而是我自 ... -
Rails文件上传利器——paperclip笔记
2010-02-27 12:04 14818Githubhttp://wiki.github.com/th ... -
为SearchLogic添加一个remote_form_for方法。
2010-02-10 15:00 1339稍微看了一下,好像挺简单,只是处理了一下参数。 # A ... -
A Guide to Testing Rails Applications
2010-02-03 19:56 0什么是Fixtures fixtures允许你在测试运行之前往 ... -
改个bug
2010-01-20 17:38 1159问题见:http://yuan.iteye.c ... -
reset/reload
2010-01-20 16:26 1080http://caboo.se/doc/classes/Act ... -
Acts As Taggable On Steroids
2010-01-20 13:53 2541参考着mephisto写blog程序 ... -
Active Record Validations and Callbacks
2009-10-18 02:45 2315参考链接:http://guides.ru ... -
Layout in Rails
2009-10-12 17:28 4702参考链接:http://guides.rubyonrails. ... -
Rendering in Rails
2009-10-10 02:10 4455参考链接:http://guides.rubyonrails. ... -
如何为Rails的views写测试。
2009-10-01 16:53 1077原文链接:http://weblog.jamisbuck.or ... -
Rails Form helpers
2009-09-28 03:31 5121参考链接:http://guides.ru ... -
rails2.3 routes笔记
2009-09-23 04:10 2774参考链接:http://guides.ru ... -
rails中分模块开发。
2009-09-18 14:48 2252我没事就喜欢拿blog练手,blog简单嘛。 嗯,其实这是 ...
相关推荐
rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails ...
[Pragmatic Bookshelf] Crafting Rails Applications Expert Practices for Everyday Rails Development (E-Book) ☆ 图书概要:☆ Rails 3 is a huge step forward. You can now easily extend the framework, ...
Ruby on Rails Guides v2 - Ruby on Rails 4.2.5
《Ruby on Rails Tutorial》中文版(原书第2版,涵盖 Rails 4) Ruby 是一门很美的计算机语言,其设计原则就是“让编程人员快乐”。David Heinemeier Hansson 就是看重了这一点,才在开发 Rails 框架时选择了 Ruby...
《Rails之道》按照Rails的各个子系统进行组织编排,分别介绍了Rails的环境、初始过程、配置和日志记录,Rails的分配器、控制器、页面生成和路由,REST、资源和Rails,ActiveRecord的基础、关联、验证和高级技巧,...
一个用Ruby on Rails搭建的图片分享的网站项目.完整源代码
本资源是参照rails敏捷开发第四版书中的例子,rails的版本是rails3.2.6
Bootstrap 3 和 Rails 4(样例用的是Ruby 2.1.1,Rails 4.1.4) Table of Contents Preface 1 Chapter 1: Introducing Web Application Development in Rails 7 Why Bootstrap with Rails? 8 Setting up a Todo ...
adminlte-rails, AdminLTE Rails gem 将AdminLTE主题与 Rails 资产管道集成 AdminLTE Rails gem AdminLTE 是后端的高级 Bootstrap 主题。英镑 AdminLTE Rails gem 与 Rails 资产管道集成了英镑AdminLTE主题。安装将...
Ruby on Rails helps you produce high-quality, beautiful-looking web applications quickly. You concentrate on creating the application, and Rails takes care of the details., Tens of thousands of ...
中文世界唯一一本Rails 4.0.0 + Ruby 2.0.0 的自學書籍
使用Aptana+Rails开发Rails Web应用 有Aptana的安装配置等等,中文
rails文档 rails api 英文
Ruby On Rails 框架自它提出之日起就受到广泛关注,在“不要重复自己”,“约定优于配置”等思想的指导下,Rails 带给 Web 开发者的是极高的开发效率。 ActiveRecord 的灵活让你再也不用配置繁琐的 Hibernate 即可...
rails指南 中文版
minitest-rails, Rails的Minitest集成 minitestRails 5的Minitest集成 安装gem install minitest-rails这将安装以下宝石:minitest配置创建一个新的Rail
Ruby+on+Rails+3+Tutorial.pdf 应用Rails进行敏捷Web开发第4版.pdf (Agile Web Development with Rails) Rails.Recipes.Rails.3.Edition.pdf
If you’re a web developer or designer ready to learn Ruby on Rails, this hands-on guide is the ideal way to get started. Rather than toss you into the middle of the framework’s Model-View-Controller...