Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Commit

Permalink
moved specs, created spec_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
robmckinnon committed Apr 24, 2008
1 parent 0909a29 commit 14ab2df
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
6 changes: 3 additions & 3 deletions spec/answer_groups_spec.rb → spec/lib/answer_groups_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/../lib/questions'
require File.dirname(__FILE__) + '/../lib/answers'
require File.dirname(__FILE__) + '/../lib/answer_groups'
require File.dirname(__FILE__) + '/../../lib/questions'
require File.dirname(__FILE__) + '/../../lib/answers'
require File.dirname(__FILE__) + '/../../lib/answer_groups'
require File.dirname(__FILE__) + '/answers_spec_data'

describe AnswerGroups, 'when creating' do
Expand Down
6 changes: 3 additions & 3 deletions spec/answers_spec.rb → spec/lib/answers_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/../lib/questions'
require File.dirname(__FILE__) + '/../lib/answers'
require File.dirname(__FILE__) + '/../lib/answer_groups'
require File.dirname(__FILE__) + '/../../lib/questions'
require File.dirname(__FILE__) + '/../../lib/answers'
require File.dirname(__FILE__) + '/../../lib/answer_groups'
require File.dirname(__FILE__) + '/answers_spec_data'

describe Answers, 'when creating' do
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion spec/questions_spec.rb → spec/lib/questions_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require File.dirname(__FILE__) + '/../lib/questions'
require File.dirname(__FILE__) + '/../../lib/questions'
require File.dirname(__FILE__) + '/answers_spec_data'
require 'hpricot'

Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'spec'
require 'spec/rails'
require File.expand_path(File.dirname(__FILE__) + "/spec_utils.rb")

Spec::Runner.configure do |config|
# If you're not using ActiveRecord you should remove these
Expand Down Expand Up @@ -42,6 +43,6 @@
# config.mock_with :rr
#
# == Notes
#
#
# For more information take a look at Spec::Example::Configuration and Spec::Runner
end
11 changes: 11 additions & 0 deletions spec/spec_utils.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

# e.g. assert_model_has_many Answer, :questions
def assert_model_has_many(model, association_name)
association = model.reflect_on_association(association_name.to_sym)
assert_not_nil association, "Could not find an association for #{association_name}"

assert_equal :has_many, association.macro

assert association.klass.column_names.include?(association.primary_key_name)
end

0 comments on commit 14ab2df

Please sign in to comment.