Skip to content

Instantly share code, notes, and snippets.

require 'spec_helper'
describe User do
pending "add some examples to (or delete) #{__FILE__}"
end
require 'spec_helper'
describe User do
before(:each) do
@attr = { :name => "Example User", :email => "[email protected]" }
end
it "should create a new instance given valid attributes" do
User.create!(@attr)
describe User do
before(:each) do
@attr = { :name => "Example User", :email => "[email protected]" }
end
.
.
.
it "should require a name" do
no_name_user = User.new(@attr.merge(:name => ""))
describe User do
before(:each) do
@attr = { :name => "Example User", :email => "[email protected]" }
end
it "should create a new instance given valid attributes" do
User.create!(@attr)
end
describe User do
before(:each) do
@attr = { :name => "Example User", :email => "[email protected]" }
end
.
.
.
it "should require an email address" do
no_email_user = User.new(@attr.merge(:email => ""))
describe User do
before(:each) do
@attr = { :name => "Example User", :email => "[email protected]" }
end
it "should create a new instance given valid attributes" do
User.create!(@attr)
end
describe User do
before(:each) do
@attr = { :name => "Example User", :email => "[email protected]" }
end
.
.
.
it "should reject names that are too long" do
long_name = "a" * 51
describe User do
before(:each) do
@attr = { :name => "Example User", :email => "[email protected]" }
end
it "should create a new instance given valid attributes" do
User.create!(@attr)
end
describe User do
before(:each) do
@attr = { :name => "Example User", :email => "[email protected]" }
end
.
.
.
it "should accept valid email addresses" do
addresses = %w[[email protected] [email protected] [email protected]]
describe User do
before(:each) do
@attr = { :name => "Example User", :email => "[email protected]" }
end
it "should create a new instance given valid attributes" do
User.create!(@attr)
end