impressionist 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -1
  3. data/Rakefile +17 -4
  4. data/app/models/impressionist/impressionable.rb +2 -2
  5. data/impressionist.gemspec +4 -3
  6. data/lib/impressionist/engine.rb +8 -25
  7. data/lib/impressionist/load.rb +6 -4
  8. data/lib/impressionist/models/active_record/impression.rb +5 -2
  9. data/lib/impressionist/models/mongoid/impression.rb +8 -15
  10. data/lib/impressionist/models/mongoid/impressionist/impressionable.rb +13 -32
  11. data/lib/impressionist/rails_toggle.rb +22 -0
  12. data/lib/impressionist/setup_association.rb +48 -0
  13. data/lib/impressionist/version.rb +1 -1
  14. data/tests/README +1 -0
  15. data/tests/spec/minitest_helper.rb +4 -0
  16. data/tests/spec/rails_toggle_spec.rb +26 -0
  17. data/tests/spec/setup_association_spec.rb +55 -0
  18. data/{test_app → tests/test_app}/.gitignore +0 -0
  19. data/{test_app → tests/test_app}/.rspec +0 -0
  20. data/{test_app → tests/test_app}/Gemfile +4 -15
  21. data/{test_app → tests/test_app}/README +0 -0
  22. data/{test_app → tests/test_app}/README.rdoc +0 -0
  23. data/{test_app → tests/test_app}/Rakefile +0 -0
  24. data/{test_app → tests/test_app}/app/assets/images/rails.png +0 -0
  25. data/{test_app → tests/test_app}/app/assets/javascripts/application.js +0 -0
  26. data/{test_app → tests/test_app}/app/assets/stylesheets/application.css +0 -0
  27. data/{test_app → tests/test_app}/app/controllers/application_controller.rb +0 -0
  28. data/{test_app → tests/test_app}/app/controllers/articles_controller.rb +0 -0
  29. data/{test_app → tests/test_app}/app/controllers/dummy_controller.rb +0 -0
  30. data/{test_app → tests/test_app}/app/controllers/posts_controller.rb +0 -0
  31. data/{test_app → tests/test_app}/app/controllers/widgets_controller.rb +0 -0
  32. data/{test_app → tests/test_app}/app/helpers/application_helper.rb +0 -0
  33. data/{test_app → tests/test_app}/app/mailers/.gitkeep +0 -0
  34. data/{test_app → tests/test_app}/app/models/.gitkeep +0 -0
  35. data/{test_app → tests/test_app}/app/models/article.rb +0 -0
  36. data/{test_app → tests/test_app}/app/models/dummy.rb +0 -0
  37. data/{test_app → tests/test_app}/app/models/post.rb +0 -0
  38. data/{test_app → tests/test_app}/app/models/user.rb +0 -0
  39. data/{test_app → tests/test_app}/app/models/widget.rb +0 -0
  40. data/{test_app → tests/test_app}/app/views/articles/index.html.erb +0 -0
  41. data/{test_app → tests/test_app}/app/views/articles/show.html.erb +0 -0
  42. data/{test_app → tests/test_app}/app/views/dummy/index.html.erb +0 -0
  43. data/{test_app → tests/test_app}/app/views/layouts/application.html.erb +0 -0
  44. data/{test_app → tests/test_app}/app/views/posts/edit.html.erb +0 -0
  45. data/{test_app → tests/test_app}/app/views/posts/index.html.erb +0 -0
  46. data/{test_app → tests/test_app}/app/views/posts/show.html.erb +0 -0
  47. data/{test_app → tests/test_app}/app/views/widgets/index.html.erb +0 -0
  48. data/{test_app → tests/test_app}/app/views/widgets/new.html.erb +0 -0
  49. data/{test_app → tests/test_app}/app/views/widgets/show.html.erb +0 -0
  50. data/{test_app → tests/test_app}/config.ru +0 -0
  51. data/{test_app → tests/test_app}/config/application.rb +0 -0
  52. data/{test_app → tests/test_app}/config/boot.rb +0 -0
  53. data/{test_app → tests/test_app}/config/cucumber.yml +0 -0
  54. data/{test_app → tests/test_app}/config/database.yml +0 -0
  55. data/{test_app → tests/test_app}/config/environment.rb +0 -0
  56. data/{test_app → tests/test_app}/config/environments/development.rb +0 -0
  57. data/{test_app → tests/test_app}/config/environments/pg_test.rb +0 -0
  58. data/{test_app → tests/test_app}/config/environments/production.rb +0 -0
  59. data/{test_app → tests/test_app}/config/environments/test.rb +0 -0
  60. data/{test_app → tests/test_app}/config/initializers/backtrace_silencers.rb +0 -0
  61. data/tests/test_app/config/initializers/impression.rb +2 -0
  62. data/{test_app → tests/test_app}/config/initializers/inflections.rb +0 -0
  63. data/{test_app → tests/test_app}/config/initializers/mime_types.rb +0 -0
  64. data/{test_app → tests/test_app}/config/initializers/secret_token.rb +0 -0
  65. data/{test_app → tests/test_app}/config/initializers/session_store.rb +0 -0
  66. data/{test_app → tests/test_app}/config/initializers/wrap_parameters.rb +0 -0
  67. data/{test_app → tests/test_app}/config/locales/en.yml +0 -0
  68. data/{test_app → tests/test_app}/config/routes.rb +0 -0
  69. data/{test_app → tests/test_app}/db/migrate/20110201153144_create_articles.rb +0 -0
  70. data/{test_app → tests/test_app}/db/migrate/20110210205028_create_posts.rb +0 -0
  71. data/{test_app → tests/test_app}/db/migrate/20111127184039_create_widgets.rb +0 -0
  72. data/tests/test_app/db/schema.rb +60 -0
  73. data/{test_app → tests/test_app}/db/seeds.rb +0 -0
  74. data/{test_app → tests/test_app}/lib/assets/.gitkeep +0 -0
  75. data/{test_app → tests/test_app}/lib/tasks/.gitkeep +0 -0
  76. data/{test_app → tests/test_app}/lib/tasks/cucumber.rake +0 -0
  77. data/{test_app → tests/test_app}/log/.gitkeep +0 -0
  78. data/{test_app → tests/test_app}/public/404.html +0 -0
  79. data/{test_app → tests/test_app}/public/422.html +0 -0
  80. data/{test_app → tests/test_app}/public/500.html +0 -0
  81. data/{test_app → tests/test_app}/public/favicon.ico +0 -0
  82. data/{test_app → tests/test_app}/public/images/rails.png +0 -0
  83. data/{test_app → tests/test_app}/public/index.html +0 -0
  84. data/{test_app → tests/test_app}/public/javascripts/application.js +0 -0
  85. data/{test_app → tests/test_app}/public/javascripts/controls.js +0 -0
  86. data/{test_app → tests/test_app}/public/javascripts/dragdrop.js +0 -0
  87. data/{test_app → tests/test_app}/public/javascripts/effects.js +0 -0
  88. data/{test_app → tests/test_app}/public/javascripts/prototype.js +0 -0
  89. data/{test_app → tests/test_app}/public/javascripts/rails.js +0 -0
  90. data/{test_app → tests/test_app}/public/robots.txt +0 -0
  91. data/{test_app → tests/test_app}/public/stylesheets/.gitkeep +0 -0
  92. data/{test_app → tests/test_app}/script/cucumber +0 -0
  93. data/{test_app → tests/test_app}/script/rails +0 -0
  94. data/{test_app → tests/test_app}/spec/controllers/articles_controller_spec.rb +0 -0
  95. data/{test_app → tests/test_app}/spec/controllers/dummy_controller_spec.rb +0 -0
  96. data/{test_app → tests/test_app}/spec/controllers/impressionist_uniqueness_spec.rb +45 -45
  97. data/{test_app → tests/test_app}/spec/controllers/posts_controller_spec.rb +0 -0
  98. data/{test_app → tests/test_app}/spec/controllers/widgets_controller_spec.rb +2 -2
  99. data/{test_app → tests/test_app}/spec/fixtures/articles.yml +0 -0
  100. data/{test_app → tests/test_app}/spec/fixtures/impressions.yml +0 -0
  101. data/{test_app → tests/test_app}/spec/fixtures/posts.yml +0 -0
  102. data/{test_app → tests/test_app}/spec/fixtures/widgets.yml +0 -0
  103. data/{test_app → tests/test_app}/spec/initializers/initializers_spec.rb +0 -0
  104. data/{test_app → tests/test_app}/spec/models/bots_spec.rb +0 -0
  105. data/{test_app → tests/test_app}/spec/models/counter_caching_spec.rb +0 -0
  106. data/{test_app → tests/test_app}/spec/models/model_spec.rb +0 -0
  107. data/{test_app → tests/test_app}/spec/rails_generators/rails_generators_spec.rb +0 -0
  108. data/tests/test_app/spec/spec_helper.rb +31 -0
  109. metadata +224 -99
  110. data/lib/impressionist/set_up_association.rb +0 -14
  111. data/spec/spec_helper.rb +0 -5
  112. data/test_app/config/initializers/impression.rb +0 -5
  113. data/test_app/spec/spec_helper.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c1694b326962e72ed2f57841cb4bc799e1a8e4d
4
- data.tar.gz: 35b5e4aa5feff7df8341022ec6b4195d35a7df18
3
+ metadata.gz: cac2802f1a96bf95bc358134f43a869aab3ba449
4
+ data.tar.gz: afab8713bbc4b91bcd84a57a3042cbfce578643e
5
5
  SHA512:
6
- metadata.gz: af17886e092d7fd62bbf70c768cb4b804f3087559f12fa2d2d68ee12f3ca6d859bcf7954790957094310ff76ed7376ae25707638779cbe0d894fd00191a5532b
7
- data.tar.gz: 828a4f2a95741643e28e1ba943515fa9e715cee6a907f62b1a93950630433f27602b208a49f4d0c597d39818a09db9f1fd041c751080f4546926c7f141141e17
6
+ metadata.gz: f92d2ef3618bce991811cb438751bc6e76497bcae951a8a42b1050133ed492c19e77b290f69a141d91087c91a40d851716e834e70645119675b7f5cea41b7229
7
+ data.tar.gz: 8425229ed14a35088bb82ac68c3d4b5b910c694175ae03f4bdef963106745e06fb9e5597f6423e3b5233368670a086a80d46b1a62ba7bbb5737206b4d9ed0cff
data/.travis.yml CHANGED
@@ -2,7 +2,8 @@ language: ruby
2
2
 
3
3
  bundler_args: '--binstubs --without documentation'
4
4
  before_install: gem install bundler
5
- before_script: "cd test_app && bundle install && ./script/rails generate impressionist -f && rake db:migrate && cd .."
5
+
6
+ before_script: "cd tests/test_app && bundle install && ./script/rails generate impressionist -f && rake db:migrate && cd .."
6
7
 
7
8
  rvm:
8
9
  - rbx-18mode
data/Rakefile CHANGED
@@ -1,15 +1,17 @@
1
1
  require 'bundler/setup'
2
2
  require 'rspec/core/rake_task'
3
+ require 'rake/testtask'
3
4
 
4
5
  Bundler::GemHelper.install_tasks
5
6
 
7
+ # Impressionist will use MiniTest instead of RSpec
6
8
  RSpec::Core::RakeTask.new do |task|
7
- task.rspec_opts = "-I ./test_app/spec"
8
- task.pattern = "./test_app/spec/**/*_spec.rb"
9
+ task.rspec_opts = "-I ./tests/test_app/spec"
10
+ task.pattern = "./tests/test_app/spec/**/*_spec.rb"
9
11
  end
10
12
 
11
- task :test => :spec
12
- task :default => :spec
13
+ task :test_app => :spec
14
+ task :default => [:test, :test_app]
13
15
 
14
16
  namespace :impressionist do
15
17
  require File.dirname(__FILE__) + "/lib/impressionist/bots"
@@ -18,4 +20,15 @@ namespace :impressionist do
18
20
  task :bots do
19
21
  p Impressionist::Bots.consume
20
22
  end
23
+
24
+ end
25
+
26
+ # setup :test task to minitest
27
+ # Rake libs default is lib
28
+ # libs << path to load test_helper, etc..
29
+ Rake::TestTask.new do |t|
30
+ t.libs << "tests/spec"
31
+ t.pattern = "tests/spec/**/*_spec.rb"
32
+ t.test_files = FileList["tests/spec/**/*_spec.rb"]
33
+ t.verbose = true
21
34
  end
@@ -32,10 +32,10 @@ module Impressionist
32
32
  options[:filter] == :all ? imps.count : imps.count(options[:filter], :distinct => true)
33
33
  end
34
34
 
35
- def update_impressionist_counter_cache
35
+ def update_impressionist_counter_cache
36
36
  slave = Impressionist::UpdateCounters.new(self)
37
37
  slave.update
38
- end
38
+ end
39
39
 
40
40
  def impressionable?
41
41
  true
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.authors = ['johnmcaliley']
15
15
 
16
16
  s.files = `git ls-files`.split("\n")
17
- s.test_files = `git ls-files -- {spec,test_app/spec}/*`.split("\n")
17
+ s.test_files = `git ls-files -- tests/**/*`.split("\n")
18
18
  s.require_path = 'lib'
19
19
  s.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if s.respond_to? :required_rubygems_version=
20
20
 
@@ -26,11 +26,12 @@ Gem::Specification.new do |s|
26
26
  # Capybara has dropped support for Ruby 1.8.7 onwards version 2.0.3
27
27
  s.add_development_dependency 'capybara', '>= 2.0.3'
28
28
  s.add_development_dependency 'rake', '>= 0.9'
29
- s.add_development_dependency 'rails', '~> 3.1'
29
+ s.add_development_dependency 'rails', '3.2.12'
30
30
  s.add_development_dependency 'rdoc', '>= 2.4.2'
31
31
  s.add_development_dependency 'rspec-rails'
32
32
  s.add_development_dependency 'simplecov'
33
33
  s.add_development_dependency 'sqlite3'
34
34
  s.add_development_dependency 'systemu'
35
-
35
+ s.add_development_dependency 'minitest'
36
+ s.add_development_dependency 'minitest-rails'
36
37
  end
@@ -1,17 +1,10 @@
1
- require "impressionist"
2
- require "rails"
3
-
4
1
  module Impressionist
5
- class Engine < Rails::Engine
2
+ class Engine < ::Rails::Engine
6
3
  attr_accessor :orm
7
4
 
8
- def initialize
9
- define_orm_type(Impressionist.orm)
10
- end
11
-
12
5
  initializer 'impressionist.model' do |app|
13
- require_and_include_orm
14
-
6
+ @orm = Impressionist.orm
7
+ include_orm
15
8
  end
16
9
 
17
10
 
@@ -26,22 +19,12 @@ module Impressionist
26
19
 
27
20
 
28
21
  private
29
- def require_and_include_orm
30
- require "#{root}/app/models/impressionist/impressionable.rb"
31
- require "impressionist/models/#{orm}/impression.rb"
32
- require "impressionist/models/#{orm}/impressionist/impressionable.rb"
33
-
34
- end
35
-
36
- def define_orm_type(str)
37
- @orm = matcher(str.to_s)
38
- end
39
-
40
- def matcher(str)
41
- matched = str.match(/active_record|mongo_mapper|mongoid|/)
42
- matched[0]
43
- end
44
22
 
23
+ def include_orm
24
+ require "#{root}/app/models/impressionist/impressionable.rb"
25
+ require "impressionist/models/#{orm}/impression.rb"
26
+ require "impressionist/models/#{orm}/impressionist/impressionable.rb"
27
+ end
45
28
 
46
29
  end
47
30
  end
@@ -1,7 +1,9 @@
1
- require "impressionist/engine"
1
+ require 'impressionist/engine'
2
2
 
3
- require "impressionist/set_up_association"
3
+ require 'impressionist/setup_association'
4
4
 
5
- require "impressionist/counter_cache"
5
+ require 'impressionist/counter_cache'
6
6
 
7
- require "impressionist/update_counters"
7
+ require 'impressionist/update_counters'
8
+
9
+ require 'impressionist/rails_toggle'
@@ -1,12 +1,15 @@
1
1
  # Responsability
2
+ ## See CounterCache TODO: extract it into a class
2
3
  # * be able to update_counters
3
4
  # * log an error if imps_id and imps_type can not be found
4
- # asks updatable? whether it may or may not be updated
5
+ # * asks updatable? whether it may or may not be updated
5
6
  # FIX exeception raising when no imps_id is found
6
7
 
7
8
  class Impression < ActiveRecord::Base
9
+
8
10
  include Impressionist::CounterCache
9
- include Impressionist::SetUpAssociation
11
+ # sets belongs_to and attr_accessible
12
+ Impressionist::SetupAssociation.new(self).set
10
13
 
11
14
  after_save :impressionable_counter_cache_updatable?
12
15
 
@@ -1,13 +1,15 @@
1
+ ##
2
+ # see active_record/impression.rb
3
+ # same doc applies to here
1
4
  class Impression
2
5
  include Mongoid::Document
3
6
  include Mongoid::Timestamps
4
7
 
5
- attr_accessible :impressionable_type, :impressionable_field, :impressionable_id, :user_id,
6
- :controller_name, :action_name, :view_name, :request_hash, :ip_address,
7
- :session_hash, :message, :referrer
8
-
9
- belongs_to :impressionable, polymorphic: true
8
+ include Impressionist::CounterCache
9
+ Impressionist::SetupAssociation.new(self).set
10
10
 
11
+ field :impressionable_id
12
+ field :impressionable_type
11
13
  field :user_id
12
14
  field :controller_name
13
15
  field :action_name
@@ -18,15 +20,6 @@ class Impression
18
20
  field :message
19
21
  field :referrer
20
22
 
21
- set_callback(:create, :after) do |doc|
22
- unless impressionable_id.nil?
23
- impressionable_class = doc.impressionable_type.constantize
23
+ after_save :impressionable_counter_cache_updatable?
24
24
 
25
- if impressionable_class.impressionist_counter_cache_options
26
- resource = impressionable_class.find(doc.impressionable_id)
27
- resource.try(:update_impressionist_counter_cache)
28
- end
29
- end
30
- end
31
-
32
25
  end
@@ -7,37 +7,25 @@ module Impressionist
7
7
  extend ActiveSupport::Concern
8
8
 
9
9
  module ClassMethods
10
+
10
11
  def is_impressionable(options={})
11
- has_many :impressions, as: :impressionable, dependent: :destroy
12
- @impressionist_cache_options = options[:counter_cache]
13
- if !@impressionist_cache_options.nil?
14
- opts = impressionist_counter_cache_options
15
- field opts[:column_name], type: Integer
16
- end
17
- end
12
+ define_association
13
+ @impressionist_cache_options = options
18
14
 
19
- def impressionist_counter_cache_options
20
- if @impressionist_cache_options
21
- options = { :column_name => :impressions_count, :unique => false }
22
- options.merge!(@impressionist_cache_options) if @impressionist_cache_options.is_a?(Hash)
23
- options
24
- end
15
+ true
25
16
  end
26
17
 
27
- def impressionist_counter_caching?
28
- impressionist_counter_cache_options.present?
29
- end
18
+ private
19
+ def define_association
20
+ has_many(:impressions,
21
+ :as => :impressionable,
22
+ :dependent => :destroy)
23
+ end
30
24
 
31
- def counter_caching?
32
- ::ActiveSupport::Deprecation.warn("#counter_caching? is deprecated; please use #impressionist_counter_caching? instead")
33
- impressionist_counter_caching?
34
- end
35
- end
36
-
37
- def impressionable?
38
- true
39
25
  end
40
26
 
27
+ ##
28
+ # Overides active_record impressionist_count
41
29
  def impressionist_count(options={})
42
30
  options.reverse_merge!(:filter=>:request_hash, :start_date=>nil, :end_date=>Time.now)
43
31
  imps = options[:start_date].blank? ? impressions : impressions.between(created_at: options[:start_date]..options[:end_date])
@@ -45,13 +33,6 @@ module Impressionist
45
33
  filter == :all ? imps.count : imps.where(filter.ne => nil).distinct(filter).count
46
34
  end
47
35
 
48
- def update_impressionist_counter_cache
49
- cache_options = self.class.impressionist_counter_cache_options
50
- column_name = cache_options[:column_name].to_sym
51
- count = cache_options[:unique] ? impressionist_count(:filter => :ip_address) : impressionist_count
52
- old_count = send(column_name) || 0
53
- self.inc(column_name, (count - old_count))
54
- end
55
-
56
36
  end
37
+
57
38
  end
@@ -0,0 +1,22 @@
1
+ module Impressionist
2
+ # Responsability
3
+ # Toggles between rails > 3.1 < 4
4
+ # In order to make attr_accessible available in a rails app < 4
5
+
6
+ class RailsToggle
7
+ # decides where or not to include attr_accessible
8
+ def should_include?
9
+ ask_rails || false
10
+ end
11
+
12
+ private
13
+
14
+ # returns false if rails >= 4
15
+ # true if rails < 4
16
+ def ask_rails
17
+ ::Rails::VERSION::MAJOR.to_i >= 4 ? false : true
18
+ end
19
+
20
+ end
21
+
22
+ end
@@ -0,0 +1,48 @@
1
+ module Impressionist
2
+ # Impressionist::SetupAssociation.new(entity).set
3
+ class SetupAssociation
4
+ def initialize(receiver)
5
+ @receiver = receiver
6
+ end
7
+
8
+ # True or False
9
+ # Note toggle returns false if rails >= 4
10
+ def include_attr_acc?
11
+ toggle && make_accessible
12
+ end
13
+
14
+ def define_belongs_to
15
+ receiver.belongs_to(:impressionable, :polymorphic => true)
16
+ end
17
+
18
+ # returns done if thruthy
19
+ def set
20
+ :done if (include_attr_acc? && define_belongs_to)
21
+ end
22
+
23
+ private
24
+ attr_reader :receiver, :toggle
25
+
26
+ def make_accessible
27
+ receiver.
28
+ attr_accessible(:impressionable_type,
29
+ :impressionable_id,
30
+ :controller_name,
31
+ :request_hash,
32
+ :session_hash,
33
+ :action_name,
34
+ :ip_address,
35
+ :view_name,
36
+ :referrer,
37
+ :message,
38
+ :user_id)
39
+ end
40
+
41
+ def toggle
42
+ t = RailsToggle.new
43
+ t.should_include?
44
+ end
45
+ end
46
+ end
47
+
48
+
@@ -1,3 +1,3 @@
1
1
  module Impressionist
2
- VERSION = "1.4.1"
2
+ VERSION = "1.4.2"
3
3
  end
data/tests/README ADDED
@@ -0,0 +1 @@
1
+ Impressionist uses MiniTest
@@ -0,0 +1,4 @@
1
+ $:.unshift(File.dirname __FILE__)
2
+
3
+ require "minitest/autorun"
4
+ require "minitest/pride"
@@ -0,0 +1,26 @@
1
+ # Responsability
2
+ # Test whether rails version > 4
3
+ # includes attr_accessible if < 4
4
+ require 'minitest_helper'
5
+ require 'impressionist/rails_toggle'
6
+
7
+ module Impressionist
8
+ describe RailsToggle do
9
+
10
+ before {
11
+ @toggle = RailsToggle.new
12
+ }
13
+
14
+ describe "Rails 4" do
15
+
16
+ # see your_minitest_path/lib/minitest/mock.rb
17
+ it "must not include attr_accessible" do
18
+ @toggle.stub :ask_rails, false do
19
+ refute @toggle.should_include?
20
+ end
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,55 @@
1
+ require 'minitest_helper'
2
+ require 'impressionist/setup_association'
3
+
4
+ module Impressionist
5
+ describe SetupAssociation do
6
+
7
+ let(:mock) { Minitest::Mock.new }
8
+ let(:set_up) { SetupAssociation.new(mock) }
9
+
10
+ before do
11
+ # expects attr_accessible to return true
12
+ # and pass 11 arguments
13
+ mock.
14
+ expect(:attr_accessible, true) do |args|
15
+ args.size == 11
16
+ end
17
+
18
+ end
19
+
20
+ describe "attr_accessible" do
21
+
22
+ it "includes" do
23
+ set_up.stub :toggle, true do
24
+ set_up.include_attr_acc?.must_equal true
25
+
26
+ mock.verify
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ describe "belongs_to" do
33
+
34
+ it "active_record" do
35
+ mock.expect(:belongs_to, true, [Symbol, Hash])
36
+ set_up.define_belongs_to.must_equal true
37
+ end
38
+
39
+ end
40
+
41
+ describe "#set" do
42
+
43
+ it "sets an association" do
44
+ def set_up.include_attr_acc?; true; end
45
+
46
+ set_up.stub(:define_belongs_to, true) {
47
+ set_up.set.must_equal :done
48
+ }
49
+
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+ end