Permalink
Browse files

Tests green again.

  • Loading branch information...
1 parent 8622534 commit 58636eccfa0153d5674689a3d3fe4825efae43fe @josevalim josevalim committed Feb 15, 2010
View
@@ -7,3 +7,4 @@ rdoc/*
test/dummy/db/schema.rb
pkg
log/*
+public/javascripts/rails_metrics.js
View
@@ -43,7 +43,7 @@ begin
s.homepage = "http://github.com/engineyard"
s.description = "Metrics measurement for your app on top of ActiveSupport::Notifications"
s.authors = ["José Valim"]
- s.files = FileList["[A-Z]*", "{app,config,generators,lib}/**/*", "init.rb"]
+ s.files = FileList["[A-Z]*", "{app,config,lib,public}/**/*"]
end
Jeweler::GemcutterTasks.new
@@ -41,13 +41,31 @@ def payload_inspect(hash)
content = []
hash.each do |key, value|
- value = value.inspect unless value.is_a?(String)
- content << (content_tag(:b, key.to_s.humanize).safe_concat("<br />") << value)
+ content << (content_tag(:b, key.to_s.humanize).safe_concat("<br />") << pretty_inspect(value))
end
content.map!{ |c| content_tag(:p, c) }
content.join("\n").html_safe
end
+
+ # Inspect a value using a more readable format.
+ def pretty_inspect(object)
+ case object
+ when String
+ object
+ when Array
+ "[#{object.map(&:inspect).join(", ")}]"
+ when Hash
+ hash = object.map { |k,v| " #{k.inspect} => #{pretty_inspect(v)}" }.join(",\n")
+ if object.size == 1
+ "{ #{hash[2..-1]} }"
+ else
+ "{\n#{hash}\n}"
+ end
+ else
+ object.inspect
+ end
+ end
end
module Scoping
@@ -3,7 +3,7 @@
<head>
<title>RailsMetrics: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'rails_metrics' %>
- <%= javascript_include_tag 'rails_metrics/raphael-min', 'rails_metrics/g.raphael-min', 'rails_metrics/g.pie-min', :cache => "rails_metrics.js" %>
+ <%= javascript_include_tag 'rails_metrics/raphael-min', 'rails_metrics/g.raphael-min', 'rails_metrics/g.pie-min', :cache => "rails_metrics" %>
</head>
<body>
<%= content_tag(:div, content_tag(:p, notice), :class => :notice) if notice.present? %>
View
@@ -0,0 +1,102 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{rails_metrics}
+ s.version = "0.0.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Jos\303\251 Valim"]
+ s.date = %q{2010-02-15}
+ s.description = %q{Metrics measurement for your app on top of ActiveSupport::Notifications}
+ s.email = %q{contact@engineyard.com}
+ s.extra_rdoc_files = [
+ "README.rdoc"
+ ]
+ s.files = [
+ "CHANGELOG.rdoc",
+ "Gemfile",
+ "MIT-LICENSE",
+ "README.rdoc",
+ "Rakefile",
+ "app/controllers/rails_metrics_controller.rb",
+ "app/helpers/rails_metrics_helper.rb",
+ "app/views/layouts/rails_metrics.html.erb",
+ "app/views/rails_metrics/_request.html.erb",
+ "app/views/rails_metrics/_row.html.erb",
+ "app/views/rails_metrics/all.html.erb",
+ "app/views/rails_metrics/chart.html.erb",
+ "app/views/rails_metrics/index.html.erb",
+ "app/views/rails_metrics/show.html.erb",
+ "config/routes.rb",
+ "lib/rails_metrics.rb",
+ "lib/rails_metrics/async_consumer.rb",
+ "lib/rails_metrics/engine.rb",
+ "lib/rails_metrics/middleware.rb",
+ "lib/rails_metrics/orm/active_record.rb",
+ "lib/rails_metrics/payload_parser.rb",
+ "lib/rails_metrics/store.rb",
+ "lib/rails_metrics/version.rb",
+ "public/images/rails_metrics/arrow_down.png",
+ "public/images/rails_metrics/arrow_up.png",
+ "public/images/rails_metrics/cancel.png",
+ "public/images/rails_metrics/chart_pie.png",
+ "public/images/rails_metrics/page_white_delete.png",
+ "public/images/rails_metrics/page_white_go.png",
+ "public/images/rails_metrics/tick.png",
+ "public/javascripts/rails_metrics.js.js",
+ "public/javascripts/rails_metrics/g.pie-min.js",
+ "public/javascripts/rails_metrics/g.raphael-min.js",
+ "public/javascripts/rails_metrics/raphael-min.js",
+ "public/stylesheets/rails_metrics.css"
+ ]
+ s.homepage = %q{http://github.com/engineyard}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.5}
+ s.summary = %q{Metrics measurement for your app on top of ActiveSupport::Notifications}
+ s.test_files = [
+ "test/dummy/app/controllers/application_controller.rb",
+ "test/dummy/app/controllers/users_controller.rb",
+ "test/dummy/app/helpers/application_helper.rb",
+ "test/dummy/app/models/metric.rb",
+ "test/dummy/app/models/notification.rb",
+ "test/dummy/app/models/user.rb",
+ "test/dummy/config/application.rb",
+ "test/dummy/config/boot.rb",
+ "test/dummy/config/environment.rb",
+ "test/dummy/config/environments/development.rb",
+ "test/dummy/config/environments/production.rb",
+ "test/dummy/config/environments/test.rb",
+ "test/dummy/config/initializers/backtrace_silencers.rb",
+ "test/dummy/config/initializers/cookie_verification_secret.rb",
+ "test/dummy/config/initializers/session_store.rb",
+ "test/dummy/config/routes.rb",
+ "test/dummy/db/migrate/20100106152343_create_metrics.rb",
+ "test/dummy/db/migrate/20100108120821_create_users.rb",
+ "test/integration/instrumentation_test.rb",
+ "test/integration/navigation_test.rb",
+ "test/orm/active_record_test.rb",
+ "test/payload_parser_test.rb",
+ "test/rails_metrics_test.rb",
+ "test/store_test.rb",
+ "test/support/helpers.rb",
+ "test/support/instrumentation.rb",
+ "test/support/mock_store.rb",
+ "test/support/webrat/integrations/rails.rb",
+ "test/test_helper.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end
+
@@ -9,6 +9,8 @@
Bundler.require
require "rails_metrics"
+Rails.public_path = File.expand_path("../../../..", __FILE__)
+
module Dummy
class Application < Rails::Application
# Remove this in next release
@@ -1,10 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# Add new inflection rules using the following format
-# (all these examples are active by default):
-# ActiveSupport::Inflector.inflections do |inflect|
-# inflect.plural /^(ox)$/i, '\1en'
-# inflect.singular /^(ox)en/i, '\1'
-# inflect.irregular 'person', 'people'
-# inflect.uncountable %w( fish sheep )
-# end
@@ -1,5 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# Add new mime types for use in respond_to blocks:
-# Mime::Type.register "text/richtext", :rtf
-# Mime::Type.register_alias "text/html", :iphone
No changes.
@@ -37,8 +37,8 @@ class InstrumentationTest < ActionController::IntegrationTest
assert_kind_of Time, sql.started_at
assert_kind_of Time, template.started_at
- assert_equal Hash[:formats => [:html], :controller => "UsersController", :method => :get,
- :action => "index", :path => "/users", :status => 200], action.payload
+ assert_equal Hash[:status=>200, :end_point=>"UsersController#index",
+ :formats=>[:html]], action.payload
assert_equal Hash[:sql => "SELECT `users`.* FROM `users`",
:name => "User Load"], sql.payload
@@ -7,54 +7,35 @@ class NagivationTest < ActionController::IntegrationTest
wait
end
- test "can navigate notifications" do
+ test "can navigate all notifications" do
get "/rails_metrics"
+ click_link "All metrics"
assert_contain "action_view.render_template"
assert_contain "action_controller.process_action"
assert_contain ActiveSupport::Notifications.instrumenter.id
id = Metric.last.id
- within Metric.last do
+ within "#rails_metric_#{id}" do
click_link "Show"
end
assert_contain "action_view.render_template"
- click_link "Back"
+ click_link "action_view.render_template"
- within Metric.last do
+ within "#rails_metric_#{id}" do
click_button "Delete"
end
- assert_not_contain "action_view.render_template"
assert_contain "Metric ##{id} was deleted with success"
- end
- test "can navigate with pagination" do
- get "/rails_metrics"
- assert_contain "Showing 1 - 4 of 4 metrics"
-
- get "/rails_metrics?limit=2"
- assert_contain "Showing 1 - 2 of 4 metrics"
-
- click_link "Next"
- assert_contain "Showing 3 - 4 of 4 metrics"
-
- assert_raise Webrat::NotFoundError do
- click_link "Next"
- end
-
- click_link "Previous"
- assert_contain "Showing 1 - 2 of 4 metrics"
-
- assert_raise Webrat::NotFoundError do
- click_link "Previous"
- end
+ get "/rails_metrics/all"
+ assert_not_contain "action_view.render_template"
end
- test "can nagivate with by scopes" do
- get "/rails_metrics"
+ test "can nagivate all metrics with by scopes" do
+ get "/rails_metrics/all"
click_link "active_record.sql"
assert_contain "Showing 1 - 1 of 1 metrics filtered by name"
@@ -63,22 +44,22 @@ class NagivationTest < ActionController::IntegrationTest
assert_contain "Showing 1 - 4 of 4 metrics"
end
- test "can nagivate with order by scopes" do
- get "/rails_metrics"
+ test "can nagivate all metrics with order by scopes" do
+ get "/rails_metrics/all"
click_link "Order by latest"
assert_contain "ordered by latest"
click_link "Show"
assert_contain "action_view.render_template"
- get "/rails_metrics"
+ click_link "Back"
click_link "Order by earliest"
assert_contain "ordered by earliest"
click_link "Show"
assert_contain "rack.request"
- get "/rails_metrics"
+ click_link "Back"
click_link "Order by fastest"
assert_contain "ordered by fastest"
@@ -87,13 +68,36 @@ class NagivationTest < ActionController::IntegrationTest
end
test "can destroy all notifications in a given scope" do
- get "/rails_metrics"
-
+ get "/rails_metrics/all"
click_link "active_record.sql"
assert_contain "Showing 1 - 1 of 1 metrics filtered by name"
click_button "Delete all"
assert_contain "All 1 selected metrics were deleted."
+
+ click_link "All metrics"
assert_contain "Showing 1 - 3 of 3 metrics"
end
+
+ test "can navigate all metrics with pagination" do
+ get "/rails_metrics/all"
+ assert_contain "Showing 1 - 4 of 4 metrics"
+
+ get "/rails_metrics/all?limit=2"
+ assert_contain "Showing 1 - 2 of 4 metrics"
+
+ click_link "Next"
+ assert_contain "Showing 3 - 4 of 4 metrics"
+
+ assert_raise Webrat::NotFoundError do
+ click_link "Next"
+ end
+
+ click_link "Previous"
+ assert_contain "Showing 1 - 2 of 4 metrics"
+
+ assert_raise Webrat::NotFoundError do
+ click_link "Previous"
+ end
+ end
end
@@ -10,7 +10,8 @@ class RailsMetricsTest < ActiveSupport::TestCase
instrument "rails_metrics.something"
wait
- assert_equal "rails_metrics.something", MockStore.instances.last.name
+ assert_equal 2, MockStore.instances.size
+ assert_equal "rails_metrics.something", MockStore.instances.first.name
end
test "does not send an event to the store if it matches an ignored pattern" do
@@ -19,7 +20,7 @@ class RailsMetricsTest < ActiveSupport::TestCase
begin
instrument "rails_metrics.something"
wait
- assert MockStore.instances.empty?
+ assert MockStore.instances.none? { |m| m.name == "rails_metrics.something" }
ensure
RailsMetrics.ignore_patterns.pop
end
@@ -29,9 +30,9 @@ class RailsMetricsTest < ActiveSupport::TestCase
instrument "rails_metrics.kicker"
wait
- assert_equal 1, MockStore.instances.size
- assert_equal "rails_metrics.kicker", MockStore.instances.last.name
- assert MockStore.instances.last.kicked?
+ assert_equal 2, MockStore.instances.size
+ assert MockStore.instances.first.kicked?
+ assert_equal "rails_metrics.kicker", MockStore.instances.first.name
end
test "does not send an event if not listening" do
Oops, something went wrong.

0 comments on commit 58636ec

Please sign in to comment.