Skip to content

Commit

Permalink
Start of testing for zero-configness
Browse files Browse the repository at this point in the history
  • Loading branch information
benmcredmond committed Oct 29, 2012
1 parent 1811684 commit 41e69e7
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 8 deletions.
82 changes: 80 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,96 @@ PATH
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.2.8)
actionpack (= 3.2.8)
mail (~> 2.4.4)
actionpack (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.0)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
activemodel (3.2.8)
activesupport (= 3.2.8)
builder (~> 3.0.0)
activerecord (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.8)
activemodel (= 3.2.8)
activesupport (= 3.2.8)
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.4)
coderay (1.0.7)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.0)
minitest (1.6.0)
journey (1.0.4)
json (1.7.5)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.8)
mime-types (1.19)
multi_json (1.3.6)
polyglot (0.3.3)
pry (0.9.10)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.3.1)
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.2)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.8)
actionmailer (= 3.2.8)
actionpack (= 3.2.8)
activerecord (= 3.2.8)
activeresource (= 3.2.8)
activesupport (= 3.2.8)
bundler (~> 1.0)
railties (= 3.2.8)
railties (3.2.8)
actionpack (= 3.2.8)
activesupport (= 3.2.8)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
slop (3.3.2)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.11)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)

PLATFORMS
ruby

DEPENDENCIES
actionpack
intercom-rails!
minitest
pry
rails
rake
8 changes: 5 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env rake

begin
require 'bundler/setup'
rescue LoadError
Expand All @@ -10,10 +11,11 @@ Bundler::GemHelper.install_tasks
require 'rake/testtask'

Rake::TestTask.new("test") do |test|
test.libs.push "lib"
test.libs.push "test"
test.libs << 'lib'
test.libs << 'test'

test.test_files = FileList['test/**/*_test.rb']
test.warning = true
test.warning = false
test.verbose = true
end

Expand Down
4 changes: 3 additions & 1 deletion intercom-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Gem::Specification.new do |s|
s.test_files = Dir["test/**/*"]

s.add_dependency 'activesupport', ">3.0"
s.add_development_dependency 'minitest'
s.add_development_dependency 'rake'
s.add_development_dependency 'rails'
s.add_development_dependency 'actionpack'
s.add_development_dependency 'pry'
end
4 changes: 3 additions & 1 deletion lib/intercom-rails.rb
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
require 'intercom-rails/railtie' if defined? Rails
require 'intercom-rails/script_tag_helper'
require 'intercom-rails/action_controller_patch'
require 'intercom-rails/railtie' if defined? Rails
34 changes: 34 additions & 0 deletions test/action_controller_test_setup.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
require 'intercom-rails'

require 'minitest/autorun'
require 'action_controller'
require 'action_controller/test_case'

def dummy_user
user = Struct.new(:email, :name).new
user.email = 'ben@intercom.io'
user.name = 'Ben McRedmond'
user
end

TestRoutes = ActionDispatch::Routing::RouteSet.new
TestRoutes.draw do
get ':controller(/:action)'
end


class ActionController::Base

include TestRoutes.url_helpers
include TestRoutes.mounted_helpers

end

class ActionController::TestCase

def setup
super
@routes = TestRoutes
end

end
27 changes: 27 additions & 0 deletions test/intercom-rails/action_controller_patch_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'action_controller_test_setup'

class TestController < ActionController::Base

#include IntercomRails::ActionControllerPatch

#def not_logged_in
#end

def logged_in
@user = dummy_user
render :text => "Hello world", :content_type => 'text/html'
end

end


class ActionControllerPatchTest < ActionController::TestCase

tests TestController

def test_user_present_response
get :logged_in
assert_equal "Hello world", @response.body
end

end
2 changes: 1 addition & 1 deletion test/intercom-rails/script_tag_helper_test.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "active_support/core_ext/string/output_safety"
require 'intercom-rails/script_tag_helper'
require 'intercom-rails'
require 'minitest/autorun'

class IntercomRailsTest < MiniTest::Unit::TestCase
Expand Down

0 comments on commit 41e69e7

Please sign in to comment.