This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= form_for([@forum, @topic]) do |f| | |
- if @topic.errors.any? | |
%div{id: 'error_explanation'} | |
%h2 | |
= pluralize(@topic.errors.count, "error") | |
prohibited this topic from being saved: | |
- for message in @topic.errors.full_messages | |
%li | |
= message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe "CreateTopics" do | |
it "creates topics" do | |
@forum = Forum.create(name: 'Ruby') | |
visit new_forum_topic_path, @forum.slug | |
fill_in "Name", with: "Test" | |
click_button "Submit" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
require 'faker' | |
feature 'Create user' do | |
scenario 'creates a user successfully with a valid username, email and password' do | |
register_with Faker::Internet.user_name, 'test123', 'test123', Faker::Internet.email | |
user_sees_success_message "Registered successfully!" | |
end | |
scenario 'notifies the user if his username is invalid' do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FactoryGirl.define do | |
factory :category do | |
name 'Programming' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Topic | |
is valid if all parameters match (FAILED - 1) | |
Failures: | |
1) Topic is valid if all parameters match | |
Failure/Error: build(:topic).should be_valid | |
ActiveRecord::RecordInvalid: | |
Validation failed: Username has already been taken | |
# C:in `object' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= form_for([@forum, @topic]) do |f| | |
- if @topic.errors.any? | |
%div{class: 'alert'} | |
%h2 | |
= pluralize(@topic.errors.count, 'error') | |
prohibited this topic from being saved: | |
- for message in @topic.errors.full_messages | |
%li | |
= message |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= form_for(:user) do |f| | |
- if flash[:alert] | |
%div{class: 'alert'} | |
= flash[:alert] | |
= f.label :email | |
%div{class: 'field'} | |
= f.email_field :email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parameters: | |
{"_method"=>"put", | |
"authenticity_token"=>"eDv4pcLTU0m3os+7OImIOdNQxouyQoSb3FojGMXMNh8=", | |
"forum_id"=>"ruby", | |
"topic_id"=>"asdasdasdasdasd"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
# Prevent CSRF attacks by raising an exception. | |
# For APIs, you may want to use :null_session instead. | |
protect_from_forgery with: :exception | |
private | |
def current_user | |
@current_user ||= User.find(session[:user_id]) if session[:user_id] | |
rescue ActiveRecord::RecordNotFound |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
OlderNewer