Posted: March 30th, 2012 | Author: jgeiger | Filed under: ruby | Tags: rails, rspec, ruby | No Comments »
I was trying to learn about view specs since doing everything in Cucumber has been considered to be a bit of overkill recently. I was looking for a solution to deal with current_user and this is what I’m using.
items/show.html.haml
|
|
.content - if @item.user == current_user Hello! This is the rest of the content. |
show.html_spec.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
require 'spec_helper' describe "items/show" do before do @user = mock_model(User) view.stub(:current_user).and_return(@user) end context "when logged in as the item owner" do it "should display 'Hello!'" do assign(:item, stub_model(Item, user: @user)) render rendered.should have_content("Hello!") end end context "when logged in as anyone else" do it "should not display the 'Hello!' link" do assign(:item, stub_model(Item, user: nil)) render rendered.should_not have_content("Hello!") end end end |
Posted: March 24th, 2012 | Author: jgeiger | Filed under: ruby | Tags: ruby, vim | No Comments »
I’ve been working on a project which has a really nice set of vim plugins with a decent configuration. I’ve been trying to send in a few patches but it was a bit of a pain to use mine but keep it updated with the main repo. A bit of searching gave me a nice setup.
This clones my fork and also adds the parent as the upstream remote.
|
|
cd ~ git clone git@github.com:jgeiger/vim-config.git ~/.vim cd ~/.vim git submodule update --init ln -s ~/.vim/vimrc ~/.vimrc git remote add upstream https://github.com/Casecommons/vim-config.git |
Now if you add this to your .gitconfig you can do an easy git pu to pull in changes from both branches.
|
|
[alias] pu = !"git fetch origin -v; git fetch upstream -v; git merge upstream/master" |
Thanks
http://gitready.com/intermediate/2009/02/12/easily-fetching-upstream-changes.html
Posted: March 22nd, 2012 | Author: jgeiger | Filed under: ruby, web | Tags: ruby, vim | No Comments »
So I’ve been trying to get vim working on my macbook with the command-t plugin for file searching. I spent quite a while trying to get it working a while ago and finally did a really simple thing and it just worked.
|
|
cd ~ git clone git@github.com:jgeiger/vim-config.git ~/.vim cd ~/.vim git submodule update --init ln -s ~/.vim/vimrc ~/.vimrc sudo mv /usr/bin/vim /usr/bin/vim72 brew install https://raw.github.com/Homebrew/homebrew-dupes/master/vim.rb cd .vim/bundle/command-t/ruby/command-t/ /usr/bin/ruby extconf.rb |
I’m using rbenv with ruby 1.9.3-p125 as my main ruby, but you need to make sure that you compile command-t against whatever ruby vim as compiled with. The homebrew-dupes forumla uses the system ruby (which lives at /usr/bin/ruby) and even if you have rbenv global set to another ruby, you can always directly use the system ruby.
Thanks to:
https://github.com/Casecommons/vim-config
https://github.com/Casecommons/casecommons_workstation/blob/master/recipes/vim.rb