- 查看每次git 提交历史 git log
- 恢复到某个版本 git reset –hard [此版本号编号]
- 恢复到上次提交 git reset –hard HEAD^ 上上次为 HEAD^^ 多次为 HEAD~num
- 恢复到之前版本后git log 不再显示恢复到的版本之后的提交情况 可使用 git reflog 查看全部更新历史
打标签
- git tag [tag-name]在当前分支最后一次提交打标签打标签
- git tag [tag-name] [commit-id] 在某次提交da'biao'qian
- 创建带有说明的标签 git tag -a [tag-name] -m [message] [commit-id]
- 推送到远程 git push [origin] [tag-name]
- 删除本地标签 git tag -d [tag-name]
- 推送所有未推送标签 git push [origin] – tags
- 删除远程标签 git tag -d [tag-name] git push origin :refs/tags/v0.9
- git命令起别名 git config –global alias.co checkout缩短输入长度
Coffeescript的=>
瘦箭头 ->用于 function创建
1 2 |
|
胖箭头=>把 this作为参数代入function 在function中使用this 为外部定义function的this,起到作用域转移的作用
1 2 3 |
|
Ruby元编程1
ruby元编程之eigenclass
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
Js闭包
创建一个对象时如果该对象用到某个内部作用域的变量,那么对这个内部作用域创建一个闭包
eg
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
RSPEC学习1
rails 安装 rspec - gem ‘rspec-rails’
创建rspec配置文件 - rails g rspec:install
should与should_not - 对象如有valid?之类的方法,test可这么写model.should be_valid或model.should_not be_valid - model.should == xx 等同 model.should eq xx
expect - expect(model).to eq some_thing
let与before - let与before(:each)的一个区别是before可以初始化变量,let不能before可以这样
1 2 3 |
|
- before(:each) 每个测试相互独立,分别调用这个
- before(:all)只调用这个一次
- let可用于定义变量,如下,在测试用例中可使用 king_of_zombie变量
1 2 3 |
|
Load RSpec 2.x support by adding the following line (typically to your spec_helper.rb file): require ‘capybara/rspec’ If you are using Rails, put your Capybara specs in spec/features. If you are not using Rails, tag all the example groups in which you want to use Capybara with :type => :feature. You can now write your specs like so: describe “the signin process”, :type => :feature do before :each do User.make(:email => ‘user@example.com’, :password => ‘caplin’) end
1 2 3 4 5 6 7 8 9 10 |
|
http://rubydoc.info/gems/rspec-rails/file/Capybara.md https://github.com/rspec/rspec-rails
Many users have been confused by the co-existence of the the Capybara::DSL (visit/page) alongside the rack-test DSL (get|post|put|delete|head/response.body) in examples in spec/requests and spec/controllers. As of rspec-rails-2.11.1 and capybara-2.0.0.beta2, these are separated as follows:
Capybara::DSL is included - spec/features
rack-test DSL is included in - spec/requests and spec/controllers
Capybara::RSpecMatchers is added to examples in: - spec/features - spec/controllers - spec/views - spec/helpers - spec/mailers
2012年6月,Rspec开发团队宣布,在v2.11中使用了新句法 来替代传统的should式句法,如
1 2 3 |
|
新句法会把要测试的值传递给 expect() 方法,然后和匹配器比较:
1 2 3 |
|
当有多个it “xxxx” do end 而测试的主题一致时, 可用
1 2 3 |
|