Created
March 23, 2012 23:55
-
-
Save robotarmy/2176510 to your computer and use it in GitHub Desktop.
Revisions
-
robotarmy revised this gist
Mar 23, 2012 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,9 @@ == Installing Rspec into Sinatra with Rake === in your project directory #Open the Gist [[https://gist.github.com/2176510| GIST with complete instructions and files]] #Update the Gemfile #Update the Rakefile #Create a .rspec file -
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,35 +1,32 @@ == Installing Rspec into Sinatra with Rake === in your project directory #Update the Gemfile #Update the Rakefile #Create a .rspec file #Follow the Instructions ====Instructions {{{ # run the bundle command $ bundle }}} {{{ # .rspec file $ echo "--color" >> .rspec $ echo "--backtrace" >> .rspec }}} {{{ # .rspec file $ echo "--color" >> .rspec $ echo "--backtrace" >> .rspec }}} {{{ # spec directory $ mkdir spec $ touch spec/spec_helper.rb # Update spec/spec_helper.rb to match file in gist. # mkdir spec/sample $ touch spec/sample/instance_variable_spec.rb # update spec/sample/instance_variable_spec.rb to match file in gist }}} -
There are no files selected for viewing
File renamed without changes. -
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ gem 'sinatra' group :development,:test do gem 'rspec' gem 'rack-test' end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ <h1> Installing Rspec into Sinatra with Rake </h1> <h5>in your project directory</h5> #Update the Gemfile #Update the Rakefile #Create a .rspec file #Follow the Instructions <h2>Instructions</h2> <code> # run the bundle command $ bundle </code> <code> # .rspec file $ echo "--color" >> .rspec $ echo "--backtrace" >> .rspec </code> <code> # .rspec file $ echo "--color" >> .rspec $ echo "--backtrace" >> .rspec </code> <code> # spec directory $ mkdir spec $ touch spec/spec_helper.rb # Update spec/spec_helper.rb to match file in gist. # mkdir spec/sample $ touch spec/sample/instance_variable_spec.rb # update spec/sample/instance_variable_spec.rb to match file in gist </code> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ require 'rspec/core' require 'rspec/core/rake_task' task :default => :spec desc "Run all specs in spec directory (excluding plugin specs)" RSpec::Core::RakeTask.new(:spec) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ require 'spec_helper' describe "My Site" do def app app_instance = MySite.prepare_instance end context "before" do it "sets @title" do get "/" app.instance_variable_get("@title").should match("Thanks to the person that figured out how to get the Sinatra app instance") end end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ require 'rack/test' # Require your modules here # this is how i do it: # require_relative '../sinatra_modules' RSpec.configure do |conf| conf.include Rack::Test::Methods end #https://gist.github.com/1523353 class Sinatra::Base @@prepared = nil def self.onion_core onion = prototype loop do onion = onion.instance_variable_get('@app') return onion if onion.class == self || onion.nil? end end def self.prepare_instance @@prepared = onion_core end # Override def call(env) d = @@prepared || dup @@prepared = nil d.call!(env) end end