in my contact details Then I should see these on my profile When I change my contact details Then I should see these on my profile Cucumber::Rails::Database.javascript_strategy = :truncation
end it 'should login' do AuthController.any_instance.stubs(:new_token).returns('12345') post :authenticate, :username => 'john', :password => 'password' JSON.parse(response.body)['token'].should == '12345' end it 'should deny login' do AuthController.any_instance.stubs(:new_token).returns(nil) post :authenticate, :username => 'john', :password => 'any-other-password' response.status.should == '403 Forbidden'.to_i end ... end
Factory(:user_with_rights) end before do stub_warden login_as @user end it 'should login' do AuthController.any_instance.stubs(:new_token).returns('12345') post :authenticate, :username => 'john', :password => 'password' JSON.parse(response.body)['token'].should == '12345' end it 'should deny login' do AuthController.any_instance.stubs(:new_token).returns(nil) post :authenticate, :username => 'john', :password => 'any-other-password' response.status.should == '403 Forbidden'.to_i end ... end
Factory(:user_with_rights) } after :all { @user.destroy } before do stub_warden login_as @user end it 'should login' do AuthController.any_instance.stubs(:new_token).returns('12345') post :authenticate, :username => 'john', :password => 'password' JSON.parse(response.body)['token'].should == '12345' end it 'should deny login' do AuthController.any_instance.stubs(:new_token).returns(nil) post :authenticate, :username => 'john', :password => 'any-other-password' response.status.should == '403 Forbidden'.to_i end ... end
end class Account < ActiveRecord::Base ... validates_uniqueness_of :email, :message =>"Email already taken" ... end it 'should fail validation if the email is not unique' do account1 = Factory.create(:account) lambda { account2 = Factory.create(:account) }.should raise_error end
end class Account < ActiveRecord::Base ... validates_uniqueness_of :email, :message =>"Email already taken" ... end it 'should fail validation if the email is not unique' do Factory.create(:account) Factory.build(:account).should_not be_valid end
update the phone record' do phone.number = '123-4567' post, :update, :phone => phone.attributes response.should be_success phone.reload.number.should == '123-4567' end
'111-1111') } it 'should update the phone record' do Phone.expects(:find).returns(phone) phone.expects(:update_attributes).with do |params| params[:number].should == '123-4567' end.returns(true) post, :update, :phone => {:number => '123-4567') response.should be_success response.should render_template(:phone) end
fetch the first page' do 30.times do { Factory.create(:golf_ball) } get :index // default page_size = 20 response.should render_template('golf_balls/index') end ... end
the first page' do 3.times do { Factory.create(:golf_ball) } get :index, :page_size => 2 response.should render_template('golf_balls/index') end ... end