Skip to content

Commit

Permalink
Update appraisal gem and fix tests for new rspec syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
jtescher committed Nov 18, 2013
1 parent 3705e96 commit b307fe8
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ appraise 'rails_3.1' do
end

appraise 'rails_3.2' do
gem 'rails', '~> 3.2.13'
gem 'rails', '~> 3.2.15'
gem 'factory_girl-remote_api', path: '../'
end

appraise 'rails_4.0' do
gem 'rails', '~> 4.0.0.rc2'
gem 'rails', '~> 4.0.1'
gem 'factory_girl-remote_api', path: '../'
end
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ end
rails_minor_version = if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
ENV['BUNDLE_GEMFILE'].split('/').last.scan(/(\d).(\d)/).join
else
'32'
'40'
end
APP_RAKEFILE = File.expand_path("../spec/dummy_#{rails_minor_version}/Rakefile", __FILE__)

Expand Down
4 changes: 2 additions & 2 deletions factory_girl-remote_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rdoc', '>= 3.4'
s.add_development_dependency 'rspec-rails', '~> 2.14.0'
s.add_development_dependency 'capybara', '~> 2.1.0'
s.add_development_dependency 'simplecov', '~> 0.7.1'
s.add_development_dependency 'simplecov', '~> 0.8.1'
s.add_development_dependency 'coveralls', '~> 0.7.0'
s.add_development_dependency 'appraisal', '~> 0.5.2'
s.add_development_dependency 'appraisal', '~> 1.0.0.beta2'
s.add_development_dependency 'database_cleaner', '~> 1.2.0'
end
4 changes: 1 addition & 3 deletions gemfiles/rails_3.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

source "http://rubygems.org"

gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.0.beta2", :platform=>:jruby
gem "sqlite3", "~> 1.3.7", :platform=>:ruby
gem "rails", "~> 3.1.12"
gem "factory_girl-remote_api", :path=>"../"

gemspec :path=>"../"
gemspec :path=>".././"
6 changes: 2 additions & 4 deletions gemfiles/rails_3.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

source "http://rubygems.org"

gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.0.beta2", :platform=>:jruby
gem "sqlite3", "~> 1.3.7", :platform=>:ruby
gem "rails", "~> 3.2.13"
gem "rails", "~> 3.2.15"
gem "factory_girl-remote_api", :path=>"../"

gemspec :path=>"../"
gemspec :path=>".././"
6 changes: 2 additions & 4 deletions gemfiles/rails_4.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

source "http://rubygems.org"

gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.0.beta2", :platform=>:jruby
gem "sqlite3", "~> 1.3.7", :platform=>:ruby
gem "rails", "~> 4.0.0.rc2"
gem "rails", "~> 4.0.1"
gem "factory_girl-remote_api", :path=>"../"

gemspec :path=>"../"
gemspec :path=>".././"
6 changes: 3 additions & 3 deletions spec/factory_girl/remote_api/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

it 'returns the parsed json if no root is set' do
uri = URI("#{config.server_url}#{config.server_mount_path}/attributes_for/user?user%5Bfirst_name%5D=James")
Net::HTTP.should_receive(:get_response).with(uri).and_return(stub(:response, body: '{ "first_name": "James"}'))
Net::HTTP.should_receive(:get_response).with(uri).and_return(double(:response, body: '{ "first_name": "James"}'))
response = FactoryGirl::RemoteApi::Request.new.get_response_for(:attributes_for, :user, first_name: "James")
expect(response).to eq("first_name" => "James")
end

it 'returns the model inside the root json element if present' do
uri = URI("#{config.server_url}#{config.server_mount_path}/attributes_for/user?user%5Bfirst_name%5D=James")
stub_response = stub(:response, body: '{ "user": {"first_name": "James"}}')
stub_response = double(:response, body: '{ "user": {"first_name": "James"}}')
Net::HTTP.should_receive(:get_response).with(uri).and_return(stub_response)
response = FactoryGirl::RemoteApi::Request.new.get_response_for(:attributes_for, :user, first_name: "James")
expect(response).to eq("first_name" => "James")
Expand All @@ -23,7 +23,7 @@
url = "#{config.server_url}#{config.server_mount_path}/authenticated_user"
params = '?authenticated_user%5Bfirst_name%5D=James&authenticated_user%5Bparent_factory%5D=user'
uri = URI(url + params)
stub_response = stub(:response, body: '{ "user": {"first_name": "James"}}')
stub_response = double(:response, body: '{ "user": {"first_name": "James"}}')
Net::HTTP.should_receive(:get_response).with(uri).and_return(stub_response)
response = FactoryGirl::RemoteApi::Request.new.get_response_for(:create,
:authenticated_user,
Expand Down
3 changes: 1 addition & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
RAILS_MINOR_VERSION = if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
ENV['BUNDLE_GEMFILE'].split('/').last.scan(/(\d).(\d)/).join
else
'32'
'40'
end

require File.expand_path("../dummy_#{RAILS_MINOR_VERSION}/config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
Expand Down
2 changes: 1 addition & 1 deletion spec/support/stub_with_real_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def stub_with_real_response(path)
FactoryGirl::RemoteApi.reset_configuration
visit [config.server_mount_path, path].join
uri = URI([config.server_url, config.server_mount_path, path].join)
Net::HTTP.should_receive(:get_response).with(uri).and_return(stub(:response, body: page.body))
Net::HTTP.should_receive(:get_response).with(uri).and_return(double(:response, body: page.body))
end
end

Expand Down

0 comments on commit b307fe8

Please sign in to comment.