Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: thunderboltlabs/engine-of-war
base: master
...
head fork: thunderboltlabs/engine-of-war
compare: fix_error_handling_in_tests
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 5 files changed
  • 0 commit comments
  • 1 contributor
Commits on Mar 11, 2012
Tammer Saleh WIP 4142b3f
View
4 engine_of_war.gemspec
@@ -17,8 +17,8 @@ Gem::Specification.new do |gem|
gem.add_dependency 'sinatra', ">= 1.3"
gem.add_dependency "compass"
- gem.add_dependency "padrino"
- gem.add_dependency "active_support"
+ gem.add_dependency "padrino", ">= 0.10.5"
+ gem.add_dependency "activesupport", ">= 3.1.0"
gem.add_dependency "builder"
gem.add_dependency 'haml'
gem.add_dependency 'sass', ">= 3.1.7"
View
46 lib/engine_of_war/app.rb
@@ -7,7 +7,6 @@ class EngineOfWar::App < Sinatra::Base
config.sass_dir = 'views/css'
end
- disable :show_exceptions
set :haml, format: :html5
set :scss, Compass.sass_engine_options
set :github_info, nil
@@ -34,27 +33,9 @@ def self.site_title
end
def self.newrelic_key=(key)
- load_newrelic(key, name) unless ENV["RACK_ENV"] == "development" or ENV["RACK_ENV"].nil?
- end
-
- def load_newrelic(key, name)
- puts "Loading NewRelic for #{name}"
- require 'newrelic_rpm'
- require 'rpm_contrib'
- NewRelic::Agent.manual_start(monitor_mode: true,
- license_key: key,
- app_name: name,
- monitor_mode: true,
- log_level: "info",
- log_file_path: "STDOUT",
- transaction_tracer: { enabled: false },
- error_collector: { enabled: true })
- end
-
- def render_page_with_layout(page)
- render_page(page,
- layout: "layouts/#{page.layout}",
- layout_engine: :haml)
+ unless %w(test development).include?(ENV["RACK_ENV"]) or ENV["RACK_ENV"].nil?
+ load_newrelic(key, name)
+ end
end
helpers do
@@ -112,4 +93,25 @@ def data(file)
content_type ext
render :"#{name}", :layout => false
end
+
+ def load_newrelic(key, name)
+ puts "Loading NewRelic for #{name}"
+ require 'newrelic_rpm'
+ require 'rpm_contrib'
+ NewRelic::Agent.manual_start(monitor_mode: true,
+ license_key: key,
+ app_name: name,
+ monitor_mode: true,
+ log_level: "info",
+ log_file_path: "STDOUT",
+ transaction_tracer: { enabled: false },
+ error_collector: { enabled: true })
+ end
+
+ def render_page_with_layout(page)
+ render_page(page,
+ layout: "layouts/#{page.layout}",
+ layout_engine: :haml)
+ end
+
end
View
67 spec/error_pages_spec.rb
@@ -1,34 +1,45 @@
require "spec_helper"
-describe "when not raising errors" do
- before do
- Capybara.app.disable :raise_errors
- Capybara.app.disable :show_exceptions
- end
-
- after do
- Capybara.app.enable :raise_errors
- Capybara.app.enable :show_exceptions
- end
-
- describe "given a /public/500.html page" do
- before do
- create_template("raise.html.haml", ".h1= raise RuntimeError")
- create_template("500.haml", "Bam")
- end
+describe "normal tests" do
+ describe "given a template with an error" do
+ before { create_template("raise.html.haml", ".h1= raise RuntimeError") }
- it "renders the page when there's an error" do
- visit "/raise"
- page.should have_selector('body p:contains("Bam")')
- end
- end
-
- describe "given a /public/404.html page" do
- before { create_template("404.haml", "wat") }
-
- it "renders the page when there's a not-found error" do
- visit "/thispagetotallydoesntexist"
- page.should have_selector('body p:contains("wat")')
+ it "raises an error" do
+ p ENV["RACK_ENV"]
+ lambda { visit "/raise" }.should raise_error(RuntimeError)
end
end
end
+
+# describe "when not raising errors" do
+# before do
+# Capybara.app.disable :raise_errors
+# Capybara.app.disable :show_exceptions
+# end
+#
+# after do
+# Capybara.app.enable :raise_errors
+# Capybara.app.enable :show_exceptions
+# end
+#
+# describe "given a /public/500.html page" do
+# before do
+# create_template("raise.html.haml", ".h1= raise RuntimeError")
+# create_template("500.haml", "Bam")
+# end
+#
+# it "renders the page when there's an error" do
+# visit "/raise"
+# page.should have_selector('body p:contains("Bam")')
+# end
+# end
+#
+# describe "given a /public/404.html page" do
+# before { create_template("404.haml", "wat") }
+#
+# it "renders the page when there's a not-found error" do
+# visit "/thispagetotallydoesntexist"
+# page.should have_selector('body p:contains("wat")')
+# end
+# end
+# end
View
10 spec/image_filter_spec.rb
@@ -1,6 +1,6 @@
require "spec_helper"
-describe "given a textile template with an image link " do
+describe "given a textile template with an image link" do
before { create_template("layouts/application.html.haml", "%h1 Layout\n= yield") }
describe "and an image link" do
@@ -53,7 +53,13 @@
subject { page }
it { should_not have_selector('img[alt]') }
- it { should have_selector('a[href="http://google.com"] img') }
+ it do
+ show_files
+ puts File.read(Capybara.app.settings.views + "/posts/bar.html.textile")
+ puts File.read(Capybara.app.settings.public_folder + "/images/file/meta.yml")
+ puts page.source
+ should have_selector('a[href="http://google.com"] img')
+ end
end
end
View
24 spec/spec_helper.rb
@@ -3,12 +3,13 @@
require 'capybara/rspec'
require 'fakeweb'
+ENV["RACK_ENV"] = "test"
+
require "engine_of_war.rb"
Capybara.app = EngineOfWar::App
-Capybara.app.set :root, "/tmp/engine-#{$$}"
-Capybara.app.enable :raise_errors
-Capybara.app.enable :show_exceptions
+Capybara.app.set :root, "/tmp/engine-#{$$}"
+
FakeWeb.allow_net_connect = false
def create_template(path, content)
@@ -31,17 +32,24 @@ def create_file(path, content)
end
def show_files
- pp Dir[File.join(File.dirname(Capybara.app.settings.views), "**", "*")]
+ pp Dir[File.join(Capybara.app.settings.root, "**", "*")]
end
def create_dirs
- FileUtils.mkdir_p(Capybara.app.settings.views)
- FileUtils.mkdir_p(Capybara.app.settings.public_folder)
+ mkdir(Capybara.app.settings.views)
+ mkdir(Capybara.app.settings.public_folder)
end
def remove_dirs
- FileUtils.rm_rf(Capybara.app.settings.views)
- FileUtils.rm_rf(Capybara.app.settings.public_folder)
+ rmdir(Capybara.app.settings.root)
+end
+
+def mkdir(dir)
+ FileUtils.mkdir_p(dir)
+end
+
+def rmdir(dir)
+ FileUtils.rm_rf(dir)
end
RSpec.configure do |config|

No commit comments for this range

Something went wrong with that request. Please try again.