Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upgrade active_record/resource to 3.2; fix corresponding issues

  • Loading branch information...
commit 835361335f535bf603a4ba0bc07b0af05638a17c 1 parent c066434
@artemave artemave authored
View
30 Gemfile.lock
@@ -2,33 +2,33 @@ PATH
remote: .
specs:
rest-assured (1.1.1)
- activerecord (~> 3.1.0)
- activeresource (~> 3.1.0)
+ activerecord (~> 3.2.0)
+ activeresource (~> 3.2.0)
childprocess (~> 0.3.0)
haml (>= 3.1.3)
- sinatra (>= 1.3.2)
+ sinatra (~> 1.3.2)
sinatra-flash
GEM
remote: http://rubygems.org/
specs:
- activemodel (3.1.3)
- activesupport (= 3.1.3)
+ activemodel (3.2.1)
+ activesupport (= 3.2.1)
builder (~> 3.0.0)
- i18n (~> 0.6)
- activerecord (3.1.3)
- activemodel (= 3.1.3)
- activesupport (= 3.1.3)
- arel (~> 2.2.1)
+ activerecord (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
+ arel (~> 3.0.0)
tzinfo (~> 0.3.29)
- activeresource (3.1.3)
- activemodel (= 3.1.3)
- activesupport (= 3.1.3)
- activesupport (3.1.3)
+ activeresource (3.2.1)
+ activemodel (= 3.2.1)
+ activesupport (= 3.2.1)
+ activesupport (3.2.1)
+ i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.2.7)
archive-tar-minitar (0.5.2)
- arel (2.2.1)
+ arel (3.0.0)
awesome_print (1.0.2)
builder (3.0.0)
capybara (1.1.2)
View
3  bin/heroku_runner
@@ -5,6 +5,9 @@ $:.push File.expand_path('../../lib', __FILE__)
require 'rest-assured/config'
require 'uri'
+# disable buffering to have log messages sent straight to Heroku’s logging infrastructure
+$stdout.sync = true
+
db = URI.parse(ENV['DATABASE_URL'])
opts = {
View
6 features/ruby_api/create_double.feature
@@ -23,14 +23,14 @@ Feature: create double
Scenario: specify response headers
When I create a double:
"""
- @double = RestAssured::Double.create(:fullpath => '/some/api', :response_headers => { 'Content-Type' => 'text/html' })
+ @double = RestAssured::Double.create(:fullpath => '/some/api', :response_headers => { 'Content-Type2' => 'text/html' })
"""
Then the following should be true:
"""
- @double.response_headers.should == { 'Content-Type' => 'text/html' }
+ @double.response_headers.should == { 'Content-Type2' => 'text/html' }
get @double.fullpath
- last_response.headers['Content-Type'].should == 'text/html'
+ last_response.headers['Content-Type2'].should == 'text/html'
"""
Scenario: specify content
View
2  features/step_definitions/command_line_options_steps.rb
@@ -24,7 +24,7 @@
@app_config[:db_config][:adapter].should == res['adapter']
@app_config[:db_config][:database].should == res['dbname']
- @app_config[:db_config][:user].should == res['dbuser']
+ @app_config[:db_config][:username].should == res['dbuser']
@app_config[:db_config][:password].should == empty_to_nil[res['dbpass']]
@app_config[:db_config][:host].should == empty_to_nil[res['dbhost']]
@app_config[:db_config][:port].should == empty_to_nil[res['dbport']].try(:to_i)
View
2  lib/rest-assured/config.rb
@@ -149,7 +149,7 @@ def self.build_db_config
opts = {
:adapter => 'postgresql',
- :user => AppConfig.user || 'root',
+ :username => AppConfig.user || 'root',
:database => AppConfig.database || default_database
}
View
5 lib/rest-assured/models/double.rb
@@ -17,6 +17,7 @@ class Double < ActiveRecord::Base
before_save :toggle_active
before_validation :set_verb
before_validation :set_status
+ before_validation :set_response_headers
after_destroy :set_active
has_many :requests, :dependent => :destroy
@@ -31,6 +32,10 @@ def toggle_active
end
end
+ def set_response_headers
+ self.response_headers = {} unless response_headers.present?
+ end
+
def set_verb
self.verb = 'GET' unless verb.present?
end
View
16 lib/rest-assured/routes/double.rb
@@ -1,4 +1,5 @@
require 'json'
+require 'active_support/core_ext/hash/slice'
module RestAssured
module DoubleRoutes
@@ -36,15 +37,14 @@ def verbs
begin
data = request.body.read
d = JSON.parse(data)['double']
+
+ # fix acitve resource dumbness
+ if d['response_headers'] and d['response_headers']['response_headers']
+ d['response_headers'] = d['response_headers']['response_headers']
+ end
rescue
- d = params['double'] || {
- :fullpath => params['fullpath'],
- :content => params['content'],
- :description => params['description'],
- :verb => params['verb'],
- :status => params['status']
- }
- d.merge!(:response_headers => params['response_headers']) if params['response_headers']
+ d = params['double'] ||
+ params.slice(*%w[fullpath content description verb status response_headers])
end
@double = Models::Double.create(d)
View
6 rest-assured.gemspec
@@ -20,11 +20,11 @@ Gem::Specification.new do |s|
s.executables = ['rest-assured']
s.require_paths = ['lib']
- s.add_dependency 'sinatra', '>= 1.3.2'
+ s.add_dependency 'sinatra', '~> 1.3.2'
s.add_dependency 'childprocess', '~> 0.3.0'
s.add_dependency 'sinatra-flash'
s.add_dependency 'haml', '>= 3.1.3'
- s.add_dependency 'activerecord', '~> 3.1.0'
- s.add_dependency 'activeresource', '~> 3.1.0'
+ s.add_dependency 'activerecord', '~> 3.2.0'
+ s.add_dependency 'activeresource', '~> 3.2.0'
end
View
12 spec/functional/response_spec.rb
@@ -14,12 +14,12 @@ module RestAssured
let(:env) { stub(:to_json => 'env').as_null_object }
let(:request) {
double('Request',
- :request_method => 'GET',
- :fullpath => '/api',
- :env => env,
- :body => stub(:read => 'body').as_null_object,
- :params => stub(:to_json => 'params')
- )
+ :request_method => 'GET',
+ :fullpath => '/api',
+ :env => env,
+ :body => stub(:read => 'body').as_null_object,
+ :params => stub(:to_json => 'params')
+ )
}
let(:rest_assured_app) { double('App', :request => request).as_null_object }
Please sign in to comment.
Something went wrong with that request. Please try again.