Permalink
Browse files

bump 0.4.0: keeping only riot macros

  • Loading branch information...
1 parent b157778 commit a587ad8329df758f6d65732b439734ba6a16d48c @gus gus committed Sep 17, 2012
View
@@ -1,2 +1,4 @@
*.gem
*.tmproj
+.rvmrc
+
View
@@ -0,0 +1,4 @@
+source :rubygems
+
+gemspec
+
View
@@ -0,0 +1,22 @@
+PATH
+ remote: .
+ specs:
+ chicago (0.3.13)
+ rack-test
+ riot
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ rack (1.4.1)
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ riot (0.12.5)
+ rr
+ rr (1.0.4)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ chicago!
View
@@ -5,52 +5,29 @@
Yeah, we're real clever. We're also from ["The city in mid-west best city in the whole wide wide world"](http://www.azlyrics.com/lyrics/lupefiasco/gogogadgetflow.html) ... which makes us double the clever.
-Chicago is a collection of runtime and test extensions and helpers that makes some common tasks a little bit easier.
+Chicago is a collection of test extensions and helpers that makes some common tasks in Sinatra a little bit easier.
## Installation
-First, make sure GemCutter is added to your list of sources. If not, install it like so or just follow the instructions for installing the gemcutter gem:
+Installing chicago is a quick gem install:
- sudo gem sources -a http://gemcutter.org
-
-Then, installing chicago is a quick gem install:
-
- sudo gem install chicago
+ gem install chicago
## Usage
-### Sinatra runtime app
-
-In your Sinatra app, do this:
-
- require 'chicago'
-
-And you'll get some helpful Sinatra extensions and helpers.
-
-If you're Sinatra app is considered modular - as in, you are not using the `Sinatra::Default` app - you will want to add the following in your app:
-
- YourApp < Sinatra::Base
- register Sinatra::Chicago # for some DSL helpers
- helpers Sinatra::Chicago::Helpers # for standard helpers
- helpers Sinatra::Chicago::Responders # for JSON assistance
- end
-
-You don't necessarily need all of them. You just need to "include" the statements that mix-in the functionality you want.
-
### Sinatra testing
-Assuming you have required 'rack/test', like so:
-
- require 'rack/test'
-
-This is because these macros use last_request defined by the Rack/Test library. If you're using [Riot](http://github.com/thumblemonks/riot) in your tests of your Sinatra app, do this:
+If you're using [Riot](http://github.com/thumblemonks/riot) in your tests of your Sinatra app, do this:
require 'chicago/riot'
-... and you'll get a bunch of cool Protest macros for testing specific Sinatra stuff.
-
-If you're using Shoulda in your tests of your Sinatra app, do this:
+... and you'll get a bunch of cool Riot macros for testing specific Sinatra stuff:
- require 'chicago/shoulda'
+* asserts_response
+* asserts_response_status
+* asserts_content_type
+* asserts_response_body
+* asserts_location
+* asserts_json_response
+* asserts_redirected_to
-... and you'll get a bunch of cool Shoulda macros for testing specific Sinatra stuff.
View
@@ -1,40 +0,0 @@
-require 'rubygems'
-require 'rake'
-require 'rake/testtask'
-
-desc 'Default task: run all tests'
-task :default => [:test]
-
-task(:set_test_env) { ENV['RACK_ENV'] ||= 'test' }
-
-desc "Run all tests"
-Rake::TestTask.new("test") do |t|
- t.libs.concat ['./lib', './test']
- t.test_files = FileList['test/*_test.rb']
- t.verbose = true
-end
-
-desc "Open an irb session preloaded with this library"
-task :console do
- exec "irb -rubygems"
-end
-
-#
-# Some monks like diamonds. I like gems.
-
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gem|
- gem.name = "chicago"
- gem.summary = "Sinatra runtime and testing extensions used commonly by Thumblemonks"
- gem.description = "Sinatra runtime and testing extensions used commonly by Thumblemonks. For example, :json_response, which turns an object into JSON and sets the content-type appropriately."
- gem.email = "gus@gusg.us"
- gem.homepage = "http://github.com/thumblemonks/chicago"
- gem.authors = ["Justin 'Gus' Knowlden"]
- gem.add_development_dependency "riot"
- gem.add_development_dependency "rack-test"
- end
- Jeweler::GemcutterTasks.new
-rescue LoadError
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
-end
View
@@ -1 +0,0 @@
-0.3.13
View
@@ -1,66 +1,21 @@
-# Generated by jeweler
-# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
-# -*- encoding: utf-8 -*-
+require "./lib/chicago/version"
Gem::Specification.new do |s|
- s.name = %q{chicago}
- s.version = "0.3.13"
+ s.name = %q{chicago}
+ s.version = Chicago::VERSION
+ s.platform = Gem::Platform::RUBY
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Justin 'Gus' Knowlden"]
- s.date = %q{2010-05-17}
- s.description = %q{Sinatra runtime and testing extensions used commonly by Thumblemonks. For example, :json_response, which turns an object into JSON and sets the content-type appropriately.}
- s.email = %q{gus@gusg.us}
- s.extra_rdoc_files = [
- "README.markdown"
- ]
- s.files = [
- ".gitignore",
- "MIT-LICENSE",
- "README.markdown",
- "Rakefile",
- "VERSION",
- "chicago.gemspec",
- "lib/chicago.rb",
- "lib/chicago/application.rb",
- "lib/chicago/helpers.rb",
- "lib/chicago/responders.rb",
- "lib/chicago/riot.rb",
- "lib/chicago/riot/macros.rb",
- "test/application_test.rb",
- "test/helpers_test.rb",
- "test/responders_test.rb",
- "test/riot_macros_test.rb",
- "test/teststrap.rb"
- ]
- s.homepage = %q{http://github.com/thumblemonks/chicago}
- s.rdoc_options = ["--charset=UTF-8"]
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.6}
- s.summary = %q{Sinatra runtime and testing extensions used commonly by Thumblemonks}
- s.test_files = [
- "test/application_test.rb",
- "test/helpers_test.rb",
- "test/responders_test.rb",
- "test/riot_macros_test.rb",
- "test/teststrap.rb"
- ]
+ s.authors = ["Justin 'Gus' Knowlden"]
+ s.summary = %q{Sinatra testing extensions used commonly by Thumblemonks}
+ s.description = %q{Sinatra testing extensions used commonly by Thumblemonks.}
+ s.email = %q{gus@gusg.us}
+ s.homepage = %q{http://github.com/thumblemonks/chicago}
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test}/*`.split("\n")
+ s.require_paths = ["lib"]
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<riot>, [">= 0"])
- s.add_development_dependency(%q<rack-test>, [">= 0"])
- else
- s.add_dependency(%q<riot>, [">= 0"])
- s.add_dependency(%q<rack-test>, [">= 0"])
- end
- else
- s.add_dependency(%q<riot>, [">= 0"])
- s.add_dependency(%q<rack-test>, [">= 0"])
- end
+ s.add_dependency(%q<riot>, [">= 0"])
+ s.add_dependency(%q<rack-test>, [">= 0"])
end
View
@@ -1,4 +0,0 @@
-require 'sinatra/base'
-require 'chicago/application'
-require 'chicago/responders'
-require 'chicago/helpers'
@@ -1,28 +0,0 @@
-module Sinatra
- module Chicago
-
- # Assumes all CSS is SASS and is referenced as being in a directory named stylesheets
- # If SASS file is not defined, the route will passed on to - theoretically - the real
- # CSS in the public directory.
- def catch_all_css(path='/stylesheets')
- get("#{path}/*.css") do
- begin
- content_type 'text/css'
- sass params["splat"].first.to_sym
- rescue Errno::ENOENT
- pass
- end
- end
- end
-
- # When you don't want anything special, but to load a named view as HAML.
- def get_obvious(name)
- get "/#{name}" do
- haml name.to_sym
- end
- end
-
- end # Chicago
-
- register Chicago
-end # Sinatra
@@ -1,77 +0,0 @@
-module Sinatra
- module Chicago
- module Helpers
- # A basic anchor (link_to) tag
- #
- # Exmaples:
- #
- # anchor('GusGus', 'http://gusg.us')
- # => <a href="http://gusg.us">GusG.us</a>
- #
- # anchor('GusGus', 'http://gusg.us', :title => 'You know who!')
- # => <a href="http://gusg.us" title="You know who!">GusG.us</a>
- def anchor(name, url, options={})
- defaults = {:href => url}
- options_str = hash_to_attributes(defaults.merge(options))
- %Q[<a #{options_str}>#{name}</a>]
- end
-
- # A helper to include stylesheet links. Currently defaults everything to
- # load from a /stylesheets directory.
- #
- # Exmaples:
- #
- # stylesheet_include('foo')
- # => <link href="/stylsheets/foo.css" media="screen" rel="stylesheet" type="text/css" />
- #
- # stylesheet_include('foo/bar')
- # => <link href="/stylsheets/foo/bar.css" media="screen" rel="stylesheet" type="text/css" />
- #
- # stylesheet_include('foo', :media => "print")
- # => <link href="/stylsheets/foo.css" media="print" rel="stylesheet" type="text/css" />
- #
- # stylesheet_include('http://example.com/foo.css')
- # => <link href="http://example.com/foo.css" media="print" rel="stylesheet" type="text/css" />
- def stylesheet_include(name, options={})
- name = "/stylesheets/#{name}.css" unless remote_asset?(name)
- defaults = {:href => name, :media => "screen",
- :rel => "stylesheet", :type => "text/css"}
- options_str = hash_to_attributes(defaults.merge(options))
- %Q[<link #{options_str}/>]
- end
-
- # A helper to include javascript source tags. Currently defaults everything
- # to load from a /javascripts directory.
- #
- # Exmaples:
- #
- # javascript_include('foo')
- # => <javascript src="/javascripts/foo.js" type="text/javascript"></script>
- #
- # javascript_include('foo/bar')
- # => <javascript src="/javascripts/foo/bar.js" type="text/javascript"></script>
- #
- # javascript_include('foo', :something => "great")
- # => <javascript src="/javascripts/foo.js" type="text/javascript" something="great"></script>
- #
- # javascript_include('http://example.com/foo.js')
- # => <javascript src="http://example.com/foo.js" type="text/javascript"></script>
- def javascript_include(name, options={})
- name = "/javascripts/#{name}.js" unless remote_asset?(name)
- defaults = {:src => name, :type => "text/javascript"}
- options_str = hash_to_attributes(defaults.merge(options))
- %Q[<script #{options_str}></script>]
- end
- private
- def remote_asset?(uri)
- uri =~ %r[^\w+://.+]
- end
-
- def hash_to_attributes(options)
- options.map {|k,v| "#{k}=\"#{v}\""}.join(' ')
- end
- end # Helpers
- end # Chicago
-
- helpers Chicago::Helpers
-end # Sinatra
@@ -1,15 +0,0 @@
-module Sinatra
- module Chicago
- module Responders
-
- # Returns a JSON response for an object. Will return an empty string if the provided object is nil.
- def json_response(object)
- content_type 'application/json'
- object ? object.to_json : ""
- end
-
- end # Responders
- end # Chicago
-
- helpers Chicago::Responders
-end # Sinatra
@@ -46,7 +46,7 @@ def asserts_json_response(*args, &block)
end
asserts("response body has JSON") { last_response.body }.equals(&(block || lambda {json}))
- asserts_content_type(args.empty? ? 'application/json' : args.shift)
+ asserts_content_type(args.empty? ? 'application/json;charset=utf-8' : args.shift)
end
# Usage:
@@ -0,0 +1,4 @@
+module Chicago
+ VERSION = "0.4.0"
+end
+
Oops, something went wrong.

0 comments on commit a587ad8

Please sign in to comment.