30 Jun '14, 12am

settingslogicを使った環境毎の定義と、rspecでの値の一時的な書き換え

require 'rails_helper' RSpec.describe FilesController, :type => :controller do describe "GET 'read'" do it "returns http success" do get 'read', { :format => 'json' } expect(response).to be_success expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json['content']).to eq('This is a test.') end it "file not found." do allow(Settings.file).to receive(:name) { 'error.txt' } get 'read', { :format => 'json' } expect(response.status).to eq(500) end end end

Full article: http://dev.classmethod.jp/server-side/ruby-on-rails/using...

Tweets

[小ネタ]springを使用してrspecが起動できない?

dev.classmethod.jp 30 Jun '14, 12am

$ spring rspec spec/ Version: 1.1.3 Usage: spring COMMAND [ARGS] Commands for spring itself: binstub Generate spring based...

[Rails]既存DBを操作するAPIを作成する | Developers.IO

dev.classmethod.jp 03 Jul '14, 12am

$ rails console Loading development environment (Rails 4.1.2) irb(main):001:0> WpUser.all WpUser Load (0.2ms) SELECT `wp_u...