Created
September 15, 2012 06:59
-
-
Save christopherhein/3726695 to your computer and use it in GitHub Desktop.
Write loops. They make your specs faster to write and more covered.
This file contains hidden or 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 App do | |
| describe "when using the factory" do | |
| subject { create :app } | |
| it { should be_valid } | |
| end | |
| describe "when initializing" do | |
| subject { App } | |
| it { should respond_to :new } | |
| end | |
| describe "when describing attributes" do | |
| columns = %w(id site domain subdomain) | |
| indexes = %w() | |
| columns.each do |column| | |
| it { should have_db_column column.to_sym } | |
| end | |
| indexes.each do |index| | |
| it { should have_db_index index.to_sym } | |
| end | |
| end | |
| describe "when relating" do | |
| has_manys = %w(users resource_types) | |
| has_manys.each do |association| | |
| it { should have_many association.to_sym } | |
| end | |
| end | |
| describe "when validating" do | |
| presences = %w(site domain) | |
| uniques = %w(domain) | |
| accessibles = %w(site domain subdomain) | |
| before { create :app } | |
| presences.each do |presence| | |
| it { should validate_presence_of presence.to_sym } | |
| end | |
| uniques.each do |unique| | |
| it { should validate_uniqueness_of unique.to_sym } | |
| end | |
| accessibles.each do |accessible| | |
| it { should allow_mass_assignment_of accessible.to_sym } | |
| end | |
| it { should_not allow_value("chris hein.dev").for :domain } | |
| it { should_not allow_value("w w w").for :subdomain } | |
| end | |
| describe "when calling #to_param" do | |
| subject { create :app } | |
| it "should return the domain for default finder" do | |
| subject.to_param.should eq subject.domain | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment