a valid factory' do brenno.should be_valid end it 'responds to admin? method' do brenno.respond_to?(:admin?).should be_true brenno.admin?.should be_true end end
a valid factory' do expect(user).to be_valid end describe '#admin?' do context 'when user is an admin' do subject(:user) { build_stubbed :user, :admin } it 'returns true' do expect(user.admin?).to be_true end end context 'when user is a content manager' do subject(:user) { build_stubbed :user, :content_manager } it 'returns false' do expect(user.admin?).to be_false end end end end
create :johndoe } subject { get :show, :id => user } context 'as user' do before { stubbed_sign_in user } context 'accessing others accounts' do subject { get :show, :id => admin } it 'redirects' do expect(subject).to redirect_to user_root_path end end context 'accessing your own account' do subject { get :show, :id => user } it 'success' do expect(subject).to be_success end it 'assigns @user' do subject expect(assigns :user).to eql user end end end end
user' do let(:user) { build_stubbed :user } context 'accessing others accounts' do before do admin = build_stubbed(:admin) User.stub(:find).and_return(admin) get :show, :id => admin end it 'redirects to user dashboard' do expect(response).to redirect_to user_root_path end end context 'accessing your own account' do before do User.stub(:find).and_return(admin) get :show, :id => user end it 'responds successfully' do expect(response).to be_success end it 'assigns user to @user' do expect(assigns :user).to eql user end end end end
describe 'GET#index' do before { get :index } it_behaves_like 'restrictable' context 'when accessed by an admin' do let(:user) { build_stubbed :administrator } context 'with one coordinator registered' do let(:coordinator) { build :coordinator } around do |example| Coordinator.should_receive(:page).and_return([coordinator]) example.run end it { expect(assigns :coordinators).to have_exactly(1).coordinator } end end end end
a new random password' do user.set_random_password! user.encrypted_password.should_not be nil end end end describe(User) { it_behaves_like PasswordSecured }
|number_of_eaten_cocadas| most_eaten_answer = number_of_eaten_cocadas > 1 ? true : false it "returns #{most_eaten_answer} when #{number_of_eaten_cocadas}/3 is eaten" do time_travel do eat_cocadas(number_of_eaten_cocadas) tiago.eaten_most_of_cocadas_in_weeks?(3).should eql(most_eaten_answer) end end end end end
weeks' do context 'with 1/3 is eaten' do it 'returns false' do time_travel do eat_cocadas 1 expect(tiago.eaten_most_of_cocadas_in_weeks? 3).to eql false end end end context 'with 2/3 is eaten' do it 'returns true' do time_travel do eat_cocadas 2 expect(tiago.eaten_most_of_cocadas_in_weeks? 3).to eql true end end end end end