Created
June 20, 2013 19:50
-
-
Save whereisciao/5826030 to your computer and use it in GitHub Desktop.
I was able to reproduce your issue. By the time the test example loads, the Sinatra Application has already loaded and is configured. It was only when I moved the application loading to after the environment is setup then did the intended configuration is loaded. An alternative is to set the ENV before the test is ran for example `RACK_ENV=produ…
This file contains 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 characters
require "rubygems" | |
require "icalendar" | |
require "date" | |
require "sinatra" | |
require 'erb' | |
configure :test do | |
puts "Calling test" | |
end | |
configure :development do | |
puts "Calling development" | |
end | |
configure :production do | |
puts "Calling production" | |
end | |
get "/" do | |
puts settings.environment | |
erb :index | |
end | |
get "/event.ics" do | |
cal = Icalendar::Calendar.new | |
cal.event do | |
dtstart Date.new(2010, 02, 25) | |
dtend Date.new(2010, 02, 26) | |
location "Steven's House" | |
organizer "Steven Chau" | |
summary "Meeting with the man." | |
description "Have a long lunch meeting and decide nothing..." | |
klass "PRIVATE" | |
end | |
content_type "text/calendar" | |
cal.to_ical | |
end |
This file contains 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 characters
require 'sinatra' | |
require 'rack/test' | |
# setup test environment | |
set :environment, :test | |
set :run, false | |
set :raise_errors, true | |
set :logging, false | |
require File.join(File.dirname(__FILE__), 'itsadate.rb') # Order matters | |
puts settings.environment | |
def app | |
Sinatra::Application | |
end | |
RSpec.configure do |config| | |
config.include Rack::Test::Methods | |
end | |
describe "Sinatra App" do | |
it "should respond to GET" do | |
get '/' | |
last_response.should be_ok | |
last_response.body.should match(/Make iCal Dates/) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment