Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vicmaster/1243589 to your computer and use it in GitHub Desktop.
Save vicmaster/1243589 to your computer and use it in GitHub Desktop.
module ActionController
class Base
def self.protect_from_forgery; end
def self.before_filter(args); end
def self.layout(args); end
end
end
RSpec.configure do |config|
config.mock_with :rr
end
root = File.realpath File.join(File.dirname(__FILE__), '..', '..')
$:.unshift root
require File.join 'app', 'controllers', 'application_controller'
require File.join 'lib', 'fvaults', 'acts', 'localizable'
describe ApplicationController do
let(:params) { {} }
let(:session) { {} }
before do
stub(subject).params { params }
stub(subject).session { session }
end
describe '#country_id' do
context 'when passing a country id that is not set in the session yet' do
before do
params[:country_id] = "1"
dont_allow(Country ||= Class.new).first
end
it 'sets the params country id' do
subject.country_id.should == params[:country_id]
end
end
context 'when no country id is passed' do
before do
mock(Country ||= Class.new).first { mock!.id { 1 } }
end
it 'sets the params country id' do
subject.country_id.should == 1
end
end
end
describe '#localize' do
let(:country) { mock!.locale { 'en_US' } }
let(:countries) { mock }
before do
mock(subject).country_id { 1 }
mock(Country ||= Class.new).find(1) { country }
mock(Country ||= Class.new).all { countries }
end
specify { subject.localize }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment