diff --git a/README.md b/README.md index fd9e375..2ead1dd 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ Tested against ruby-head, ruby 2.0.0, ruby 1.9.3, jruby-19mode, jruby-head, and (https://gemnasium.com/jtescher/factory_girl-remote_api) [![Coverage Status](https://coveralls.io/repos/jtescher/factory_girl-remote_api/badge.png)] (https://coveralls.io/r/jtescher/factory_girl-remote_api) +[![Gem Version](https://badge.fury.io/rb/factory_girl-remote_api.png) +](http://badge.fury.io/rb/factory_girl-remote_api) ##Installation diff --git a/factory_girl-remote_api.gemspec b/factory_girl-remote_api.gemspec index 6e9a20a..55dafe8 100644 --- a/factory_girl-remote_api.gemspec +++ b/factory_girl-remote_api.gemspec @@ -14,6 +14,7 @@ Gem::Specification.new do |s| s.description = 'Simply creates an HTTP API for your FactoryGirl factories to be used by client tests.' s.signing_key = File.expand_path('~/.ssh/gem-private_key.pem') if $0 =~ /gem\z/ s.cert_chain = ['gem-public_cert.pem'] + s.license = 'MIT' s.files = Dir['{app,config,db,lib}/**/*'] + ['MIT-LICENSE', 'Rakefile', 'README.md'] diff --git a/lib/factory_girl/remote_api.rb b/lib/factory_girl/remote_api.rb index e9285eb..811185c 100644 --- a/lib/factory_girl/remote_api.rb +++ b/lib/factory_girl/remote_api.rb @@ -31,5 +31,9 @@ def self.attributes_for(factory, attributes = {}) FactoryGirl::RemoteApi::Request.new.get_response_for(:attributes_for, factory, attributes) end + def self.created_attributes_for(factory, attributes = {}) + FactoryGirl::RemoteApi::Request.new.get_response_for(:create, factory, attributes) + end + end end diff --git a/lib/factory_girl/remote_api/engine.rb b/lib/factory_girl/remote_api/engine.rb index 7facbad..1eedcc6 100644 --- a/lib/factory_girl/remote_api/engine.rb +++ b/lib/factory_girl/remote_api/engine.rb @@ -2,13 +2,6 @@ module FactoryGirl module RemoteApi class Engine < ::Rails::Engine isolate_namespace FactoryGirl::RemoteApi - - config.generators do |g| - g.test_framework :rspec, fixture: false - g.fixture_replacement :factory_girl, dir: 'spec/factories' - g.assets false - g.helper false - end end end end diff --git a/spec/features/client_factory_requests_spec.rb b/spec/features/client_factory_requests_spec.rb index e054332..f4ae4e2 100644 --- a/spec/features/client_factory_requests_spec.rb +++ b/spec/features/client_factory_requests_spec.rb @@ -56,4 +56,20 @@ expect(user_attributes['first_name']).to eq('James') expect(user_attributes[:first_name]).to eq('James') end + + scenario 'attributes for a created user model from a remote factory' do + stub_with_real_response('/user?') + created_user_attributes = FactoryGirl::RemoteApi.created_attributes_for(:user) + expect(User.count).to eq(1) + expect(created_user_attributes[:id]).to_not be_nil + end + + scenario 'attributes for a created user model from a remote factory with specific attributes' do + stub_with_real_response('/user?user%5Bfirst_name%5D=James') + created_user_attributes = FactoryGirl::RemoteApi.created_attributes_for(:user, first_name: 'James') + expect(User.count).to eq(1) + expect(created_user_attributes[:id]).to_not be_nil + expect(created_user_attributes['first_name']).to eq('James') + expect(created_user_attributes[:first_name]).to eq('James') + end end