Permalink
Browse files

In the middle of porting coast to micro_test.

  • Loading branch information...
1 parent 8b9613f commit 0e44539b7cf4a09b00e4c1ec07e60ad2379ba101 @hopsoft committed Nov 17, 2012
View
@@ -3,7 +3,8 @@ source "https://rubygems.org"
gem "activesupport"
group :test do
- gem "minitest", "2.12.0"
+ gem "micro_test", "0.3.0.rc3"
+ gem "micro_mock"
gem "pry"
- gem "turn"
+ gem "pry-stack_explorer"
end
View
@@ -1,28 +1,36 @@
GEM
remote: https://rubygems.org/
specs:
- activesupport (3.2.3)
+ activesupport (3.2.9)
i18n (~> 0.6)
multi_json (~> 1.0)
- ansi (1.4.2)
- coderay (1.0.6)
- i18n (0.6.0)
- method_source (0.7.1)
- minitest (2.12.0)
- multi_json (1.2.0)
- pry (0.9.8.4)
+ binding_of_caller (0.6.8)
+ 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.0.5)
+ micro_test (0.3.0.rc3)
+ celluloid
+ multi_json (1.3.7)
+ pry (0.9.10)
coderay (~> 1.0.5)
- method_source (~> 0.7.1)
- slop (>= 2.4.4, < 3)
- slop (2.4.4)
- turn (0.9.4)
- ansi
+ method_source (~> 0.8)
+ slop (~> 3.3.1)
+ pry-stack_explorer (0.4.7)
+ binding_of_caller (~> 0.6.8)
+ slop (3.3.3)
+ timers (1.0.1)
PLATFORMS
ruby
DEPENDENCIES
activesupport
- minitest (= 2.12.0)
+ micro_mock
+ micro_test (= 0.3.0.rc3)
pry
- turn
+ pry-stack_explorer
View
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Nathan Hopkins
+
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,15 +1,23 @@
+require "rake"
+require File.join(File.dirname(__FILE__), "lib", "coast", "version")
+
Gem::Specification.new do |s|
s.name = "coast"
- s.version = "0.9.1"
- s.date = "2012-04-06"
+ s.version = Coast::VERSION
s.summary = "Coast"
- s.description = "Resourceful behavior for Rails controllers with a Sinatra like DSL."
+ s.description = "Resourceful behavior for Rails controllers with a simple DSL."
s.authors = [ "Nathan Hopkins" ]
- s.email = [ "nate.hop@gmail.com" ]
- s.files = [ "lib/coast.rb" ]
- s.test_files = [ "spec/coast_spec.rb" ]
+ s.email = [ "natehop@gmail.com" ]
+ s.files = FileList[
+ "lib/coast.rb",
+ "lib/**/*.rb",
+ "LICENSE.txt",
+ "README.md"
+ ]
+ s.test_files = FileList[
+ "test/**/*.rb"
+ ]
s.homepage ="https://github.com/hopsoft/coast"
s.add_dependency("activesupport")
s.license = "MIT"
-
end
View
@@ -1,3 +1,8 @@
+require "rubygems"
+require "bundler"
+Bundler.require :default
+require File.join(File.dirname(__FILE__), "coast", "version")
+
# Makes any controller resourceful by providing the following actions:
# * new
# * edit
@@ -0,0 +1,3 @@
+module Coast
+ VERSION = "0.9.2"
+end
View
@@ -1,244 +0,0 @@
-require "rubygems"
-
-# fix MiniTest issue with 1.9
-unless defined? Gem::Deprecate
- module Gem
- Deprecate = Module.new do
- include Deprecate
- end
- end
-end
-
-require "bundler/setup"
-Bundler.require(:default, :test)
-require "minitest/autorun"
-require "active_support/all"
-
-dirname = File.dirname(__FILE__)
-require File.join(dirname, "mock")
-Dir.glob(File.join(dirname, "..", "lib", "*.rb")) { |f| require f }
-MODEL_PATH = File.join(dirname, "testable_model.rb")
-CONTROLLER_PATH = File.join(dirname, "testable_controller.rb")
-load MODEL_PATH
-load CONTROLLER_PATH
-
-
-
-
-describe Coast do
- RESTFUL_METHODS = %w(index show new edit create update destroy)
- ITEM_METHODS = %w(show new edit create update destroy)
- UI_METHODS = %w(new edit)
- READ_METHODS = %w(index show)
- MUTATE_METHODS = %w(create update destroy)
-
- # Resets the mock class defs.
- def reset
- Coast.send(:remove_const, :TestableController)
- Coast.send(:remove_const, :TestableModel)
- load MODEL_PATH
- load CONTROLLER_PATH
- Coast::TestableController.set_resourceful_model Coast::TestableModel
- end
-
- # class method tests ============================================================================
-
- describe :set_authorize_method do
- it "sets the method used to perform authorization checks" do
- reset
- Coast::TestableController.set_authorize_method :authorize!
- assert Coast::TestableController.authorize_method == :authorize!
- end
- end
-
- describe :authorize_method= do
- it "sets the method used to perform authorization checks" do
- reset
- Coast::TestableController.authorize_method = :authorize!
- assert Coast::TestableController.authorize_method == :authorize!
- end
- end
-
- describe :set_resourceful_model do
- it "sets the model that the controller manages" do
- reset
- model = Object.new
- Coast::TestableController.set_resourceful_model model
- assert Coast::TestableController.resourceful_model == model
- end
- end
-
- describe :resourceful_model= do
- it "sets the model that the controller manages" do
- reset
- model = Object.new
- Coast::TestableController.resourceful_model = model
- assert Coast::TestableController.resourceful_model == model
- end
- end
-
- def verify_callback_setter(event, action)
- reset
- Coast::TestableController.send(event, action, &(lambda {}))
- assert Coast::TestableController.new.respond_to?("#{event}_#{action}")
- end
-
- describe :before do
- it "stores a before callback for all RESTful actions" do
- RESTFUL_METHODS.each { |m| verify_callback_setter :before, m }
- end
- end
-
- describe :respond_to do
- it "stores a respond_to callback for all RESTful actions" do
- RESTFUL_METHODS.each { |m| verify_callback_setter :respond_to, m }
- end
- end
-
- describe :after do
- it "stores an after callback for all RESTful actions" do
- RESTFUL_METHODS.each { |m| verify_callback_setter :after, m }
- end
- end
-
-
-
-
-
-
-
-
-
-
-
- # instance method tests =========================================================================
-
-
- it "supports all RESTful methods" do
- reset
- controller = Coast::TestableController.new
- RESTFUL_METHODS.each { |m| controller.must_respond_to m }
- end
-
- # %w(index show new).each do |method|
- RESTFUL_METHODS.each do |method|
- describe "##{method}" do
- before do
- reset
- end
-
- it "responds and renders" do
- controller = Coast::TestableController.new
- controller.send(method)
- assert controller.responded?, "Did not respond"
- assert controller.rendered?, "Did not render"
- end
-
- it "renders for the formats html, xml, json" do
- controller = Coast::TestableController.new
- controller.send(method)
- assert controller.html, "Did not respond to the html format"
- assert controller.xml, "Did not respond to the xml format"
- assert controller.json, "Did not respond to the json format"
- end
-
- it "invokes the callbacks before, respond_to, after" do
- callbacks = []
-
- Coast::TestableController.class_eval do
- before(method) { callbacks << :before }
- respond_to(method) { callbacks << :respond_to }
- after(method) { callbacks << :after }
- end
-
- controller = Coast::TestableController.new
- controller.send(method)
- assert callbacks.include?(:before), "Did not invoke the before callback"
- assert callbacks.include?(:respond_to), "Did not invoke the respond_to callback"
- assert callbacks.include?(:after), "Did not invoke the after callback"
- end
-
- it "allows :respond_to callback to perform the render" do
- Coast::TestableController.respond_to(method) { @performed = true }
- controller = Coast::TestableController.new
- controller.send(method)
- assert controller.responded? == false, "Did not allow :respond_to callback to perform the render"
- end
-
- it "invokes the authorize_method when set" do
- Coast::TestableController.authorize_method = :authorize!
- controller = Coast::TestableController.new
- controller.send(:index)
- assert controller.authorize_invoked?, "Did not invoke the authorize_method"
- end
-
- end
- end
-
- ITEM_METHODS.each do |method|
- describe "##{method}" do
- before do
- reset
- end
-
- it "allows :before callback to set the item" do
- item = Object.new
- Coast::TestableController.before(:index) { @resourceful_item = item }
- controller = Coast::TestableController.new
- controller.index
- assert controller.instance_eval { @resourceful_item } == item, "Did not allow :before callback to set the resourceful_item"
- end
-
- it "sets a custom named instance variable for the item" do
- item = Object.new
- Coast::TestableController.before(:index) { @resourceful_item = item }
- controller = Coast::TestableController.new
- controller.index
- variable = controller.instance_eval { instance_variable_get(item_instance_var_name) }
- assert variable != nil, "Did not set a custom instance variable for the item"
- assert variable == item, "Did not set a custom instance variable for the item to the correct value"
- end
-
- end
- end
-
- MUTATE_METHODS.each do |method|
- describe "##{method}" do
- before do
- reset
- end
-
- it "redirects" do
- controller = Coast::TestableController.new
- controller.send(method)
- assert controller.redirected?, "Did not redirect"
- end
- end
- end
-
-
- describe "#index" do
- before do
- reset
- end
-
- it "allows :before callback to set the list" do
- list = [ Object.new ]
- Coast::TestableController.before(:index) { @resourceful_list = list }
- controller = Coast::TestableController.new
- controller.index
- assert controller.instance_eval { @resourceful_list } == list, "Did not allow :before callback to set the resourceful_list"
- end
-
- it "sets a custom named instance variable for the item" do
- list = [ Object.new ]
- Coast::TestableController.before(:index) { @resourceful_list = list }
- controller = Coast::TestableController.new
- controller.index
- variable = controller.instance_eval { instance_variable_get(list_instance_var_name) }
- assert variable != nil, "Did not set a custom instance variable for the item"
- assert variable == list, "Did not set a custom instance variable for the item to the correct value"
- end
- end
-
-end
Oops, something went wrong.

0 comments on commit 0e44539

Please sign in to comment.