Skip to content

Commit

Permalink
upgrade mocha
Browse files Browse the repository at this point in the history
Change-Id: I2209531a3bfaf68932455dc9a1eb2471067b754f
Reviewed-on: https://gerrit.instructure.com/18550
Tested-by: Jenkins <[email protected]>
Reviewed-by: Brian Palmer <[email protected]>
QA-Review: Cody Cutrer <[email protected]>
  • Loading branch information
ccutrer committed Mar 12, 2013
1 parent 23191e2 commit 4030981
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ end
group :test do
gem 'bluecloth', '2.0.10' # for generating api docs
gem 'parallelized_specs', '0.4.16'
gem 'mocha', '0.12.3', :require => 'mocha_standalone'
gem 'mocha', '0.13.3', :require => false
gem 'rcov', '0.9.9'
gem 'rspec', '1.3.2'
gem 'rspec-rails', '1.3.4'
Expand Down
19 changes: 9 additions & 10 deletions spec/models/stream_item_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
end

describe ".update_all_with_invalidation" do
# TODO: uncomment when this bug is fixed https://github.com/freerange/mocha/issues/99
# it "invalidates stream item cache keys and runs update_all (the original)" do
# # expect
# StreamItemCache.expects(:invalidate_context_stream_item_key).twice
# updates, conditions, options = ['updates', {:conditions => ''}, {:options => ''}]
# StreamItemInstance.expects(:original_update_all).with(updates, conditions, options)
# # when
# StreamItemInstance.update_all_with_invalidation(['code_1', 'code_2'],
# updates, conditions, options)
# end
it "invalidates stream item cache keys and runs update_all (the original)" do
# expect
StreamItemCache.expects(:invalidate_context_stream_item_key).twice
updates, conditions, options = ['updates', {:conditions => ''}, {:options => ''}]
StreamItemInstance.expects(:original_update_all).with(updates, conditions, options)
# when
StreamItemInstance.update_all_with_invalidation(['code_1', 'code_2'],
updates, conditions, options)
end
end
end
17 changes: 15 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# require 'spec/autorun'
require 'spec/rails'
require 'webrat'
require 'mocha_standalone'
require 'mocha/api'
require File.dirname(__FILE__) + '/mocha_extensions'

Dir.glob("#{File.dirname(__FILE__).gsub(/\\/, "/")}/factories/*.rb").each { |file| require file }
Expand Down Expand Up @@ -104,14 +104,27 @@ def outside_transaction?
end
end

module MochaRspecAdapter
include Mocha::API
def setup_mocks_for_rspec
mocha_setup
end
def verify_mocks_for_rspec
mocha_verify
end
def teardown_mocks_for_rspec
mocha_teardown
end
end

Spec::Runner.configure do |config|
# If you're not using ActiveRecord you should remove these
# lines, delete config/database.yml and disable :active_record
# in your config/boot.rb
config.use_transactional_fixtures = true
config.use_instantiated_fixtures = false
config.fixture_path = Rails.root+'spec/fixtures/'
config.mock_with :mocha
config.mock_with MochaRspecAdapter

config.include Webrat::Matchers, :type => :views

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.join( File.dirname( __FILE__ ), 'test_helper' )

require 'mocha'
require 'mocha/api'

class Aardvark < ActiveRecord::Base
simply_versioned :keep => 3
Expand Down

0 comments on commit 4030981

Please sign in to comment.