Skip to content
Browse files

Got the generator running and a request dispatched to the test endpoint

  • Loading branch information...
1 parent 6062a0a commit 641d2ca82533a0e8894a29792b318ef71ed73d92 @jferris jferris committed
View
10 features/rails.feature
@@ -3,13 +3,13 @@ Feature: Install the Gem in a Rails application
Background:
Given I have built and installed the "hoptoad_notifier" gem
- @wip
Scenario: Use the gem without vendoring the gem in a Rails application
When I generate a new Rails application
And I configure the Hoptoad shim
And I configure my application to require the "hoptoad_notifier" gem
And I run the hoptoad generator with "-k myapikey"
- Then I should receive a Hoptoad notification
+ Then the command should have run successfully
+ And I should receive a Hoptoad notification
And I should see the Rails version
Scenario: vendor the gem and uninstall
@@ -18,9 +18,11 @@ Feature: Install the Gem in a Rails application
And I configure my application to require the "hoptoad_notifier" gem
And I unpack the "hoptoad_notifier" gem
And I run the hoptoad generator with "-k myapikey"
- And I uninstall the "hoptoad_notifier" gem
+ Then the command should have run successfully
+ When I uninstall the "hoptoad_notifier" gem
And I run "rake hoptoad:test"
- Then I should receive two Hoptoad notifications
+ Then the command should have run successfully
+ And I should receive two Hoptoad notifications
Scenario: Configure the notifier by hand
When I generate a new Rails application
View
4 features/step_definitions/rails_application_steps.rb
@@ -232,3 +232,7 @@ def initialize(*args)
Then /^I should see that "([^\"]*)" is not considered a framework gem$/ do |gem_name|
Then %{I should not see "[R] #{gem_name}"}
end
+
+Then /^the command should have run successfully$/ do
+ @terminal.status.should == 0
+end
View
2 lib/hoptoad_notifier/notice.rb
@@ -1,3 +1,5 @@
+require 'builder'
+
module HoptoadNotifier
class Notice
View
20 lib/hoptoad_notifier/rails3_tasks.rb
@@ -11,18 +11,8 @@
:api_key => ENV['API_KEY'])
end
- task :log_stdout do
- require 'logger'
- RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
- end
-
desc "Verify your gem installation by sending a test exception to the hoptoad service"
- task :test => ['hoptoad:log_stdout', :environment] do
- # require 'ruby-debug'
- # debugger
-
- puts "running rake hoptoad:test task"
-
+ task :test => [:environment] do
RAILS_DEFAULT_LOGGER.level = Logger::DEBUG
require 'app/controllers/application_controller'
@@ -83,17 +73,15 @@ def logger
end
class HoptoadVerificationController < ApplicationController; end
+ RailsRoot::Application.routes_reloader.reload_if_changed
RailsRoot::Application.routes.draw do |map|
match 'verify' => 'application#verify', :as => 'verify'
end
-
puts 'Processing request.'
+ RailsRoot::Application.configuration.logger = Logger.new(STDOUT)
env = Rack::MockRequest.env_for("/verify")
- response = RailsRoot::Application.call(env)
-
- p response
-
+ RailsRoot::Application.call(env)
end
end
View
2 lib/hoptoad_notifier/railtie.rb
@@ -8,5 +8,7 @@ class Railtie < Rails::Railtie
rake_tasks do
require "hoptoad_notifier/rails3_tasks"
end
+
+ config.middleware.insert_after ActionDispatch::ShowExceptions, HoptoadNotifier::Rack
end
end
View
10 lib/rails_generators/hoptoad/hoptoad_generator.rb
@@ -23,12 +23,12 @@ def ensure_api_key_was_configured
end
end
- # def api_key
- # options[:api_key]
- # end
+ def api_key
+ options[:api_key]
+ end
def generate_initializer
- api_key = options[:api_key]
+ # api_key = options[:api_key]
template 'initializer.rb', 'config/initializers/hoptoad.rb'
end
@@ -41,6 +41,6 @@ def generate_initializer
# end
def test_hoptoad
- run "rake hoptoad:test --trace"
+ puts run("rake hoptoad:test --trace")
end
end

0 comments on commit 641d2ca

Please sign in to comment.
Something went wrong with that request. Please try again.