Skip to content

Commit

Permalink
WIP: Rails 3.0.7 just freeze in the middle of the test, and keep requ…
Browse files Browse the repository at this point in the history
…esting to http://localhost:3002/api/v2/projects/abc123/draft_blurbs ... This is taking too long, I should spend some time on something else first.
  • Loading branch information
sikachu committed Jun 28, 2011
1 parent b1fbe52 commit 6bd26a3
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Appraisals
Expand Up @@ -8,7 +8,7 @@ end

appraise "3.1" do
gem "rails", "~> 3.1.0.beta1"
gem 'sass'
gem 'sass-rails'
gem 'coffee-script'
gem 'uglifier'
gem 'jquery-rails'
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -16,4 +16,5 @@ gem "json"
gem "thin"
gem "i18n", "~> 0.6.0.beta1"
gem "appraisal", "~> 0.3.5", :require => false
gem "rdoc"

2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -93,6 +93,7 @@ GEM
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.9.2)
rdoc (3.6.1)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
Expand Down Expand Up @@ -148,6 +149,7 @@ DEPENDENCIES
json
rails (~> 3.0.3)
rake
rdoc
rspec (~> 2.3)
ruby-debug
ruby-debug19
Expand Down
14 changes: 10 additions & 4 deletions Rakefile
Expand Up @@ -3,17 +3,23 @@ require 'bundler/setup'
require 'appraisal'
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'rdoc/task'
require 'rubygems/package_task'
require 'cucumber/rake/task'
require 'rspec/core/rake_task'
require 'yard'

desc 'Default: run the specs and features.'
task :default do
task :default => [:cleanup, 'appraisal:install'] do
system("rake -s appraisal spec cucumber;")
end

desc 'cleanup temporary files in tmp/ directory'
task :cleanup do
FileUtils.rm_rf('tmp')
FileUtils.mkdir('tmp')
end

desc 'Test the copycopter_client plugin.'
RSpec::Core::RakeTask.new do |t|
t.rspec_opts = ['--color', "--format progress"]
Expand All @@ -31,7 +37,7 @@ YARD::Rake::YardocTask.new do |t|
end

eval("$specification = begin; #{IO.read('copycopter_client.gemspec')}; end")
Rake::GemPackageTask.new($specification) do |package|
Gem::PackageTask.new($specification) do |package|
package.need_zip = true
package.need_tar = true
end
Expand Down
3 changes: 2 additions & 1 deletion features/step_definitions/rails_steps.rb
Expand Up @@ -17,7 +17,8 @@
GEMS
end

When "I reset Bundler environment variable"
reset_bundler_variables
run_simple("bundle install --local") if Rails::VERSION::MAJOR == 3
end

When /^I configure the copycopter client with api key "([^"]*)"$/ do |api_key|
Expand Down
34 changes: 25 additions & 9 deletions features/support/appraisal.rb
@@ -1,18 +1,34 @@
BUNDLE_ENV_VARS = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE)
ORIGINAL_BUNDLE_VARS = Hash[ENV.select{ |key,value| BUNDLE_ENV_VARS.include?(key) }]
module AppraisalHelper
BUNDLE_ENV_VARS = %w(RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE)
ORIGINAL_BUNDLE_VARS = Hash[ENV.select{ |key,value| BUNDLE_ENV_VARS.include?(key) }]

def setup_appriasal_gemfile
ENV['BUNDLE_GEMFILE'] = File.join(Dir.pwd, ENV['BUNDLE_GEMFILE'])
end

def reset_original_bundler_variables
ORIGINAL_BUNDLE_VARS.each_pair do |key, value|
ENV[key] = value
end
end

def reset_bundler_variables
BUNDLE_ENV_VARS.each do |key|
ENV[key] = nil
end
end
end

World(AppraisalHelper)

Before do
ENV['BUNDLE_GEMFILE'] = File.join(Dir.pwd, ENV['BUNDLE_GEMFILE'])
setup_appriasal_gemfile
end

After do
ORIGINAL_BUNDLE_VARS.each_pair do |key, value|
ENV[key] = value
end
reset_original_bundler_variables
end

When /^I reset Bundler environment variable$/ do
BUNDLE_ENV_VARS.each do |key|
ENV[key] = nil
end
reset_bundler_variables
end
3 changes: 2 additions & 1 deletion features/support/rails_server.rb
Expand Up @@ -85,13 +85,14 @@ def post(path, data)
end

def wait_until_responsive
60.times do
20.times do
if responsive?
return true
else
sleep(0.5)
end
end
stop
raise "Couldn't connect to Rails application server at #{HOST}:#{@port}"
end

Expand Down
3 changes: 3 additions & 0 deletions features/support/reset_projects.rb
@@ -0,0 +1,3 @@
Before do
File.open("tmp/projects.json", "w"){ |f| f.write('{}') }
end
17 changes: 9 additions & 8 deletions gemfiles/2.3.gemfile
Expand Up @@ -2,20 +2,21 @@

source "http://rubygems.org"

gem "ruby-debug", :platforms=>:mri_18
gem "rails", "~> 2.3"
gem "ruby-debug19", :platforms=>:mri_19
gem "sqlite3-ruby", :require=>false
gem "rspec", "~> 2.3"
gem "bourne"
gem "webmock"
gem "rake"
gem "bourne"
gem "sham_rack"
gem "cucumber", "~> 0.10.0"
gem "sinatra", :require=>false
gem "rspec", "~> 2.3"
gem "yard", :require=>false
gem "ruby-debug", :platforms=>:mri_18
gem "ruby-debug19", :platforms=>:mri_19
gem "json"
gem "thin"
gem "sinatra", :require=>false
gem "json"
gem "cucumber", "~> 0.10.0"
gem "i18n", "~> 0.6.0.beta1"
gem "appraisal", "~> 0.3.5", :require=>false
gem "webmock"
gem "rdoc"

2 changes: 2 additions & 0 deletions gemfiles/2.3.gemfile.lock
Expand Up @@ -58,6 +58,7 @@ GEM
rake (>= 0.8.3)
rake (0.9.2)
rbx-require-relative (0.0.5)
rdoc (3.6.1)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
Expand Down Expand Up @@ -111,6 +112,7 @@ DEPENDENCIES
json
rails (~> 2.3)
rake
rdoc
rspec (~> 2.3)
ruby-debug
ruby-debug19
Expand Down
17 changes: 9 additions & 8 deletions gemfiles/3.0.gemfile
Expand Up @@ -2,20 +2,21 @@

source "http://rubygems.org"

gem "ruby-debug", :platforms=>:mri_18
gem "rails", "~> 3.0.3"
gem "ruby-debug19", :platforms=>:mri_19
gem "sqlite3-ruby", :require=>false
gem "rspec", "~> 2.3"
gem "bourne"
gem "webmock"
gem "rake"
gem "bourne"
gem "sham_rack"
gem "cucumber", "~> 0.10.0"
gem "sinatra", :require=>false
gem "rspec", "~> 2.3"
gem "yard", :require=>false
gem "ruby-debug", :platforms=>:mri_18
gem "ruby-debug19", :platforms=>:mri_19
gem "json"
gem "thin"
gem "sinatra", :require=>false
gem "json"
gem "cucumber", "~> 0.10.0"
gem "i18n", "~> 0.6.0.beta1"
gem "appraisal", "~> 0.3.5", :require=>false
gem "webmock"
gem "rdoc"

2 changes: 2 additions & 0 deletions gemfiles/3.0.gemfile.lock
Expand Up @@ -95,6 +95,7 @@ GEM
thor (~> 0.14.4)
rake (0.9.2)
rbx-require-relative (0.0.5)
rdoc (3.6.1)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
Expand Down Expand Up @@ -152,6 +153,7 @@ DEPENDENCIES
json
rails (~> 3.0.3)
rake
rdoc
rspec (~> 2.3)
ruby-debug
ruby-debug19
Expand Down
25 changes: 13 additions & 12 deletions gemfiles/3.1.gemfile
Expand Up @@ -2,24 +2,25 @@

source "http://rubygems.org"

gem "jquery-rails"
gem "uglifier"
gem "ruby-debug", :platforms=>:mri_18
gem "rails", "~> 3.1.0.beta1"
gem "ruby-debug19", :platforms=>:mri_19
gem "sass-rails"
gem "sqlite3-ruby", :require=>false
gem "rspec", "~> 2.3"
gem "bourne"
gem "webmock"
gem "rake"
gem "coffee-script"
gem "bourne"
gem "sham_rack"
gem "cucumber", "~> 0.10.0"
gem "sinatra", :require=>false
gem "rspec", "~> 2.3"
gem "yard", :require=>false
gem "ruby-debug", :platforms=>:mri_18
gem "ruby-debug19", :platforms=>:mri_19
gem "json"
gem "thin"
gem "sinatra", :require=>false
gem "json"
gem "cucumber", "~> 0.10.0"
gem "i18n", "~> 0.6.0.beta1"
gem "appraisal", "~> 0.3.5", :require=>false
gem "sass"
gem "coffee-script"
gem "uglifier"
gem "jquery-rails"
gem "webmock"
gem "rdoc"

8 changes: 7 additions & 1 deletion gemfiles/3.1.gemfile.lock
Expand Up @@ -139,6 +139,11 @@ GEM
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
sass (3.1.3)
sass-rails (3.1.0.rc.3)
actionpack (~> 3.1.0.rc1)
railties (~> 3.1.0.rc1)
sass (>= 3.1.3)
sprockets (>= 2.0.0.beta.9)
sham_rack (1.3.3)
rack
sinatra (1.2.6)
Expand Down Expand Up @@ -182,10 +187,11 @@ DEPENDENCIES
json
rails (~> 3.1.0.beta1)
rake
rdoc
rspec (~> 2.3)
ruby-debug
ruby-debug19
sass
sass-rails
sham_rack
sinatra
sqlite3-ruby
Expand Down
2 changes: 1 addition & 1 deletion lib/copycopter_client/client.rb
Expand Up @@ -61,7 +61,7 @@ def download
# @raise [ConnectionError] if the connection fails
def upload(data)
connect do |http|
response = http.post(uri("draft_blurbs"), data.to_json)
response = http.post(uri("draft_blurbs"), data.to_json, "Content-Type" => "application/json")
check(response)
log("Uploaded missing translations")
end
Expand Down
4 changes: 2 additions & 2 deletions spec/copycopter_client/client_spec.rb
Expand Up @@ -44,7 +44,7 @@ def build_client_with_project(config = {})
project = add_project
client = build_client(:api_key => project.api_key, :secure => true)
client.download { |ignore| }
http.use_ssl.should == true
http.should be_use_ssl
http.verify_mode.should == OpenSSL::SSL::VERIFY_PEER
http.ca_file.should == CopycopterClient::Configuration::CA_FILE
end
Expand All @@ -53,7 +53,7 @@ def build_client_with_project(config = {})
project = add_project
client = build_client(:api_key => project.api_key, :secure => false)
client.download { |ignore| }
http.use_ssl.should == false
http.should_not be_use_ssl
end

it "wraps HTTP errors with ConnectionError" do
Expand Down
5 changes: 4 additions & 1 deletion spec/support/fake_copycopter_app.rb
Expand Up @@ -3,9 +3,12 @@
require 'thin'

class FakeCopycopterApp < Sinatra::Base
set :show_exceptions, false

def self.start
fake_copycopter_pid = fork do
Thin::Logging.silent = true
Thin::Logging.trace = true
Thin::Logging.debug = true
Rack::Handler::Thin.run(self, :Port => port)
end

Expand Down

0 comments on commit 6bd26a3

Please sign in to comment.