Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial spec

  • Loading branch information...
commit 835d90f7ed58bddc68cea8f57165e747b8a6d807 1 parent b838abe
Zachary Scott authored
9 Rakefile
View
@@ -1 +1,10 @@
require "bundler/gem_tasks"
+
+require 'rake/testtask'
+
+Rake::TestTask.new do |t|
+ t.pattern = "spec/*_spec.rb"
+end
+
+task(:spec => :test)
+task(:default => :test)
4 glorify.gemspec
View
@@ -18,4 +18,8 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "redcarpet", "~> 2.0"
s.add_runtime_dependency "pygments.rb"
s.add_runtime_dependency "nokogiri"
+
+ s.add_development_dependency "minitest"
+ s.add_development_dependency "rack-test"
+ s.add_development_dependency "rake"
end
1  spec/glorify/blocks.erb
View
@@ -0,0 +1 @@
+<%= glorify('```puts "Hello, world!"```') %>
1  spec/glorify/header.erb
View
@@ -0,0 +1 @@
+<%= glorify("#a sip of glory") %>
1  spec/glorify/layout.erb
View
@@ -0,0 +1 @@
+<%= yield %>
32 spec/glorify_spec.rb
View
@@ -0,0 +1,32 @@
+begin
+ require_relative 'spec_helper'
+rescue NameError
+ require File.expand_path('../spec_helper', __FILE__)
+end
+
+describe Sinatra::Glorify do
+
+ it "should parse a header" do
+ mock_app do
+ get('/') { erb :header }
+ end
+ expected = "<h1>a sip of glory</h1>"
+ get('/')
+ assert last_response.ok?
+ assert_equal expected, body
+ end
+
+ it "should parse code blocks" do
+ mock_app do
+ get('/') { erb :blocks }
+ end
+ expected = "<p><code>puts &quot;Hello, world!&quot;</code></p>"
+ get('/')
+ assert last_response.ok?
+ assert_equal expected, body
+ end
+
+ it "should parse ruby blocks" do
+ flunk "NotImplementedError"
+ end
+end
29 spec/spec_helper.rb
View
@@ -0,0 +1,29 @@
+ENV['RACK_ENV'] = 'test'
+require 'minitest/spec'
+require 'minitest/autorun'
+require 'rack'
+
+require 'glorify'
+require 'rack/test'
+require 'sinatra/base'
+require 'erb'
+
+Sinatra::Base.set :environment, :test
+Sinatra::Base.set :views, File.expand_path('../glorify', __FILE__)
+Sinatra::Base.register Sinatra::Glorify
+
+class MiniTest::Spec
+ include Rack::Test::Methods
+
+ def mock_app(base=Sinatra::Base, &block)
+ @app = Sinatra.new(base, &block)
+ end
+
+ def app
+ Rack::Lint.new(@app)
+ end
+
+ def body
+ last_response.body.gsub(/\n/,'')
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.