Skip to content

Commit

Permalink
Updated the tests to use the latest micro_mock.
Browse files Browse the repository at this point in the history
  • Loading branch information
hopsoft committed Jan 15, 2013
1 parent 87b1987 commit eab6964
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 37 deletions.
16 changes: 6 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (3.2.9)
activesupport (3.2.11)
i18n (~> 0.6)
multi_json (~> 1.0)
celluloid (0.12.3)
facter (>= 1.6.12)
timers (>= 1.0.0)
coderay (1.0.8)
facter (1.6.14)
i18n (0.6.1)
method_source (0.8.1)
micro_mock (0.1.1)
micro_test (0.3.0)
celluloid
multi_json (1.3.7)
micro_mock (1.0.0)
micro_test (0.3.5)
os
multi_json (1.5.0)
os (0.9.6)
pry (0.9.10)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.3.1)
slop (3.3.3)
timers (1.0.1)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion lib/coast/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Coast
VERSION = "0.9.6"
VERSION = "0.9.7"
end
52 changes: 26 additions & 26 deletions test/test_coast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,51 @@ class TestCoast < MicroTest::Test
# Creates a mock model instance [ActiveRecord::Base].
def self.mock_model
mock = MicroMock.make.new
mock.stub(:destroy) { @destroyed = true }
mock.stub(:destroyed?) { @destroyed }
mock.stub(:update_attributes) { |*args| @attributes_updated = true }
mock.stub(:save) { |*args| @saved = true }
mock.class.stub(:find) { |*args| TestCoast.mock_model }
mock.class.stub(:all) { (1..5).map { TestCoast.mock_model } }
mock.def(:destroy) { @destroyed = true }
mock.def(:destroyed?) { @destroyed }
mock.def(:update_attributes) { |*args| @attributes_updated = true }
mock.def(:save) { |*args| @saved = true }
mock.class.def(:find) { |*args| TestCoast.mock_model }
mock.class.def(:all) { (1..5).map { TestCoast.mock_model } }
mock
end

# Creates a mock request instance [ActionDispatch::Request].
def self.mock_request
mock = MicroMock.make.new
mock.stub(:request) { @request ||= MicroMock.make.new }
mock.stub(:params) { @params ||= {} }
mock.stub(:flash) { @flash ||= {} }
mock.def(:request) { @request ||= MicroMock.make.new }
mock.def(:params) { @params ||= {} }
mock.def(:flash) { @flash ||= {} }
mock
end

# Creates a mock controller instance [ActionController::Base].
def self.mock_controller
mock = MicroMock.make.new
mock.class.send :include, Coast
mock.stub(:authorize!) { |*args| @authorize_invoked = true }
mock.stub(:authorize_invoked?) { @authorize_invoked }
mock.stub(:respond_to) { |&block| @responded = true; block.call(format) }
mock.stub(:responded?) { @responded }
mock.stub(:render) { |*args| @performed = @rendered = true }
mock.stub(:performed?) { @performed }
mock.stub(:rendered?) { @rendered }
mock.stub(:redirect_to) { |*args| @redirected = true; render }
mock.stub(:redirected?) { @redirected }
mock.stub(:request) { @request ||= TestCoast.mock_request }
mock.stub(:params) { request.params }
mock.stub(:flash) { request.flash }
mock.stub(:format) { @format ||= TestCoast.mock_format }
mock.stub(:root_url) { "/" }
mock.def(:authorize!) { |*args| @authorize_invoked = true }
mock.def(:authorize_invoked?) { @authorize_invoked }
mock.def(:respond_to) { |&block| @responded = true; block.call(format) }
mock.def(:responded?) { @responded }
mock.def(:render) { |*args| @performed = @rendered = true }
mock.def(:performed?) { @performed }
mock.def(:rendered?) { @rendered }
mock.def(:redirect_to) { |*args| @redirected = true; render }
mock.def(:redirected?) { @redirected }
mock.def(:request) { @request ||= TestCoast.mock_request }
mock.def(:params) { request.params }
mock.def(:flash) { request.flash }
mock.def(:format) { @format ||= TestCoast.mock_format }
mock.def(:root_url) { "/" }
mock
end

# Creates a mock format instance [ActionController::MimeResponds::Collector].
def self.mock_format
mock = MicroMock.make.new
mock.stub(:html) { |&block| @html = true; block.call if block }
mock.stub(:xml) { |&block| @xml = true; block.call if block }
mock.stub(:json) { |&block| @json = true; block.call if block }
mock.def(:html) { |&block| @html = true; block.call if block }
mock.def(:xml) { |&block| @xml = true; block.call if block }
mock.def(:json) { |&block| @json = true; block.call if block }
mock
end

Expand Down

0 comments on commit eab6964

Please sign in to comment.