This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Rename Controller to Listener

  • Loading branch information...
1 parent b45b806 commit 47ab53416693cd4e8ed60435d3a601105d33e4ed Joe Ferris and Mike Burns committed with jferris Aug 3, 2012
View
@@ -1,6 +1,6 @@
require 'turning/version'
require 'turning/callbacks'
-require 'turning/controller'
+require 'turning/listener'
require 'turning/renderer'
require 'turning/static_cascade'
require 'turning/railtie'
@@ -1,5 +1,5 @@
module Turning
- class Controller
+ class Listener
def initialize(renderer = nil)
@renderer = renderer || default_renderer
end
@@ -15,7 +15,7 @@ def default_renderer
end
def view_path
- self.class.name.underscore.sub(/_controller$/, '')
+ self.class.name.underscore.sub(/_listener$/, '')
end
def storage
View
@@ -12,7 +12,7 @@ class Railtie < ::Rails::Railtie
end
initializer('turning.url_helpers') do
- Turning::Controller.class_eval do
+ Turning::Listener.class_eval do
include Rails.application.routes.url_helpers
end
end
@@ -5,14 +5,14 @@
include Rack::Test::Methods
it 'listens to events and renders the view to a static file' do
- controller_class = Class.new(Turning::Controller) do
+ listener_class = Class.new(Turning::Listener) do
def initialize(model)
super()
@model = model
end
def self.name
- 'ExamplesController'
+ 'ExamplesListener'
end
def listen
@@ -35,9 +35,9 @@ def trigger_update
create_view('examples/index.html.erb', '<%= @greeting %>')
model = model_class.new
- controller = controller_class.new(model)
+ listener = listener_class.new(model)
- controller.listen
+ listener.listen
model.trigger_update
get '/'
@@ -1,55 +1,55 @@
require 'spec_helper'
-require 'turning/controller'
+require 'turning/listener'
-describe Turning::Controller do
+describe Turning::Listener do
it 'sets up a listener' do
listening = false
- concrete_controller = Class.new(Turning::Controller) do
+ concrete_listener = Class.new(Turning::Listener) do
define_method :listen do
listening = true
end
end
- concrete_controller.new(mock_renderer).listen
+ concrete_listener.new(mock_renderer).listen
listening.should be
end
it 'renders' do
- concrete_controller = Class.new(Turning::Controller) do
+ concrete_listener = Class.new(Turning::Listener) do
def do_it
render 'index', 'hello-index', greeting: 'hello'
end
end
renderer = mock_renderer
- concrete_controller.new(renderer).do_it
+ concrete_listener.new(renderer).do_it
renderer.should have_rendered('index', 'hello-index', greeting: 'hello')
end
it 'renders without assigns' do
- concrete_controller = Class.new(Turning::Controller) do
+ concrete_listener = Class.new(Turning::Listener) do
def do_it
render 'index', 'index-unassigned'
end
end
renderer = mock_renderer
- concrete_controller.new(renderer).do_it
+ concrete_listener.new(renderer).do_it
renderer.should have_rendered('index', 'index-unassigned', {})
end
it 'provides url helpers' do
- concrete_controller = Class.new(Turning::Controller) do
+ concrete_listener = Class.new(Turning::Listener) do
def do_it
render 'index', root_path
end
end
renderer = mock_renderer
- concrete_controller.new(renderer).do_it
+ concrete_listener.new(renderer).do_it
renderer.should have_rendered('index', '/', {})
end

0 comments on commit 47ab534

Please sign in to comment.