ITeye博客

夜鸣猪的Ruby On Rails 空间

夜鸣猪 · 共 628 篇文章

10款原型设计工具

个人比较喜欢Axure和 原型草图工具Balsmiq Mockups介绍 MockFlow MockFlow allows you to design and collaborate (in real-time) user interface mockups for your software and websites. It comes with numerous built-in components & icons. Axure Axure enables application designers to create wireframes, flow diagrams, protot…

2011-11-29 07:52 · 评论(0)

关于watir selenium和webdriver soda cucumber

watir和selenium在自动化测试web测试领域强硬增长。这一趋势日渐强势,各种搭配和框架丛生。 简单的搜集,我看到了cucumber配合watir的框架,看到例教,和类似的测试集成框架,也看到分布式测试框架 简单使用: 安装 gem install watir-webdriver require 'watir-webdriver' b = Watir::Browser.new b.goto 'bit.ly/watir-webdriver-demo' b.text_field(:id => 'entry_0').set 'your name' b.select_list(:id => …

2011-11-29 01:34 · Ruby On Rails · Unit Test · 评论(0)

Ruby On Rails 面试系列七,一个面试练习题

现在面试流行让你写代码放到github上,这是其中一个要求: Please create a todo-list application with the following capabilities: Login and account creation RSpec & Cucumber Tests Bonus points for incorporating Ajax(Drag & Drop to-do items) CSS Nice templates/layouts Updating THIS README See: Tom Preston Werner See: Matt Park…

2011-11-28 12:26 · Ruby 1.9 · rake · 评论(0)

回馈开源社区赢IPAD-帮RailsCasts宣传

RailsCasts.com,致力于推广Rails知识,持续发布前沿的Rails技术展示和讲解视频,当前发布视频数量已经达到300部。从事Rails开发的程序员或多或少,或直接或间接的都从RailsCasts上受益过。 作为RailsCasts的制作者Ryan Bates ( rbates on Twitter and ryanb on GitHub),以“是时间回馈开源社区”组织活动,宣传RailsCasts,庆祝视频数量达到300部,以便有更多的人了解RailsCasts。 活动大致情况如下: 在github上,找一个你喜欢的项目,提交一个pull request,项目提交要有一定质量。…

2011-11-27 07:13 · Ruby On Rails · 评论(0)

关于json

js.erb alert('New object id: ' + <%= @user.id %>); 在这个文件里读rails变量到js,实际是可以直接运行rails 标注一个render json需要include和only选择的 respond_to do |format| format.html # index.html.erb format.json { render :json => @things.to_json(:include => { :photos => { :only => [:id, :url] } }) } end 这个有个比较cool的做法 class Thing…

2011-11-26 22:03 · Ruby On Rails · Ruby 1.9 · 评论(0)

ruby 1.9 irb rails console不能用readline问题

Update: 2012/03/27 当前版本ruby1.9.3p135 ubuntu 11.10 解决办法先试试 rvm requirements #先安装依赖的包 rvm remove 1.9.2 rvm install 1.9.2 遇到问题是rvm use用不了,其他都能用,提示 RVM is not a function, selecting rubies with 'rvm use ...' will not work. 是一个所谓的“Run as login shell”问题,官方有介绍 https://rvm.beginrescueend.com/integration/gno…

2011-11-24 02:49 · Ruby On Rails · Ruby 1.9 · 评论(0)

ruby 1.9 简单的文件操作

#读文件 f = File.open("myfile.txt", "r") f.each_line do|line| puts "I read this line: #{line}" end File.foreach("myfile.txt") do|line| puts "I read this line: #{line}" end f = File.open("myfile.txt", "r") line = f.gets puts "The line I read is: #{line}" #写操作 File.open('filename','w') do |f| f.puts lin…

2011-11-21 00:23 · Ruby 1.9 · 评论(0)

MiniTest::Mock 二,进一步示例分析

据说,如果对mock stub 和fakes概念不熟悉的话可以看看 这个 我自己看了一下,没懂。还是看例子容易些 例如,有这么个东西需要测试 class MailPurge def initialize(imap) @imap = imap end def purge(date) # IMAP wants dates in the format: 8-Aug-2002 formatted_date = date.strftime('%d-%b-%Y') @imap.authenticate('LOGIN', 'user', 'password') @imap.select('INBOX') …

2011-11-21 00:15 · Ruby技巧 · Unit Test · 评论(1)

MiniTest::Mock Ruby1.9 标准库支持

官方说明如下 主要一个expect一个verify #Expect that method name is called, optionally with args, and returns retval. @mock.expect(:meaning_of_life, 42) @mock.meaning_of_life # => 42 @mock.expect(:do_something_with, true, [some_obj, true]) @mock.do_something_with(some_obj, true) # => true args is compared to the…

2011-11-20 10:54 · Ruby On Rails · Unit Test · 评论(0)

Ruby 1.9 Rspec 风格 Unit Test MiniTest::Spec介绍

MiniTest是1.9后加到ruby标准库里的。其中,有几个部分当在1.9中写 require 'test/unit' 时,会兼容的把MiniTest:Unit载入,然而MiniTest::Unit只是增加了assertions 比较显著的部分是MiniTest::Spec和MiniTest::Mock, 夜猪 对此比较感冒,当然效果是比不了Rspec啦,比如before do还是不能支持before :all do这样的回调。对于ruby标准库来说还是不错的开始。简介如下: 例如之前的unittest可能会这么写 require 'test/unit' class TestArray <…

2011-11-20 10:46 · Ruby On Rails · Unit Test · 评论(0)

Module方法调用好不好

以前说,用module给class加singleton方法,和extend到类include到类的instance 现在看看这个 module Prober def probe_invoke(type, data = {}) p = Probe.new({:probe_type => type.to_s, :data => data.to_json, :probe_status => 0, :retries => 0}) p.save end end 掉的时候 require 'prober' include Prober probe_invoke("send_sms", sms_text)…

2011-11-20 01:58 · RubyOnRails · 评论(0)

ORM是是非非

简单讲,开发的时候方便了(敏捷开发?),运行的时候慢了,而且,不能深入细节 一些参考吧 回答 ruby面试三 用的 某人 写道 Advantages: Speeds-up Development - eliminates the need for repetitive SQL code. Reduces Development Time. Reduces Development Costs. Overcomes vendor specific SQL differences - the ORM knows how to write vendor specific SQL so you don…

2011-11-20 01:41 · 编程概念 · 评论(0)

jquery的选择器

update : 需要扩展选择器的话: http://www.softwareunity.com/jquery/JQueryMoreSelectors/ 通俗的讲, Selector选择器就是”一个表示特殊语意的字符串”. 只要把选择器字符串传入上面的方法中就能够选择不同的Dom对象并且以jQuery包装集的形式返回. 但是如何将jQuery选择器分类让 我犯难. 因为书上的分类和jQuery官方的分类截然不同. 最后我决定以实用为主, 暂时不去了解CSS3选择器标准, 而按照jQuery官方的分类进行讲解. jQuery的选择器支持CSS3选择器标准. 下面是W3C最新的CSS3选择器标准…

2011-11-20 01:31 · javascript Jquery ext prototype · 评论(0)

一个ajax和rails交互的例子

首先,这里用了一个,query信息解析的包,如下 https://github.com/rapportive-oss/jquery-parsequery 主要做如下: $.parseQuery({query: "id[]=1&id[]=2", array_keys: /^ids$/, decode: function (input, context) { input = this.default_decode(input); if (context === null) { return input.replace(/\[\]$/, 's') } else if (context === "i…

2011-11-19 01:53 · RubyOnRails · javascript Jquery ext prototype · 评论(0)

Rails 返回hash给javascript

这是一个特别的,不太正统的需求, 因为,大部分时候,ajax的返回,只要返回json类型数据就可以了 然而,如果返回的是partial,partial里有变量是hash,而这个hash又需要jquery的plugin例如图表之类的用,那就需要这个rails的hash转成javascript能认,能读的hash了。 思路呢,还是通过json 就是在haml或者erb页面里吧hash转json 然后 jQuery.parseJSON( json ) var obj = jQuery.parseJSON('{"name":"John"}'); alert( obj.name === "John" …

2011-11-19 01:43 · RubyOnRails · 评论(0)