Commit 1d1c4570c7d1ef8d9cf45974ba61898c0b97c177

* added spec_dsl file for custom matchers
* Added basic Project model
* remove public/index.html
Revert "* added spec_dsl file for custom matchers"

This reverts commit b153a5399928578f8b88a7840b65e02257c696ef.

Conflicts:

Commit diff

app/models/project.rb

 
1class Project < ActiveRecord::Base
2 belongs_to :user
3
4 validates_presence_of :name
5end
toggle raw diff

app/views/layouts/application.rhtml

spec/fixtures/projects.yml

 
1# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2one:
3 id: 1
4 name: MyString
5 description: MyText
6 user_id: 1
7 created_at: 2007-08-19 16:56:36
8 updated_at: 2007-08-19 16:56:36
9two:
10 id: 2
11 name: MyString
12 description: MyText
13 user_id: 1
14 created_at: 2007-08-19 16:56:36
15 updated_at: 2007-08-19 16:56:36
toggle raw diff

spec/models/project_spec.rb

 
1require File.dirname(__FILE__) + '/../spec_helper'
2
3describe Project do
4 before(:each) do
5 @project = Project.new(:name => "foo project")
6 end
7
8 it "should have valid associations" do
9 @project.should have_valid_associations
10 end
11
12 it "should have a name to be valid" do
13 project = Project.new
14 project.should_not be_valid
15 project.name = "foo"
16 project.should be_valid
17 end
18end
toggle raw diff

spec/spec_dsl.rb

 
1module KeyserSource
2 module SpecDSL
3 # original code by caboose court3nay (?)
4 class HaveValidAssociations
5 def matches?(model)
6 @failed_association = nil
7 @model_class = model.class
8
9 model.class.reflect_on_all_associations.each do |assoc|
10 model.send(assoc.name, true) rescue @failed_association = assoc.name
11 end
12 !@failed_association
13 end
14
15 def failure_message
16 "invalid association \"#{@failed_association}\" on #{@model_class}"
17 end
18 end
19
20 def have_valid_associations
21 HaveValidAssociations.new
22 end
23 end
24end
toggle raw diff