like_im_five 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d893513f8b9b91d64442372148cfb0cf59257b867527c17b61db544e44aa385
4
- data.tar.gz: 3b015d58ad82f7d5dcadc6267e2a84404932a9d94871746ed937fe05886b2146
3
+ metadata.gz: ed2ffa3e58863c117969f75b5787e1b107efd0a679e915feb637b3090b1fefe7
4
+ data.tar.gz: f7e4d23fdf26c78fefb7fe4db7883f42e7ecdf0fafa8872c1525a59166036b40
5
5
  SHA512:
6
- metadata.gz: 92a3f3ca4a75412b0f224af0483770893e85a09243aa4af8171e1662b24df14407870920a079a7925b921978090595d1fbc54616efe8fe0b15866de3a417e107
7
- data.tar.gz: 547abee73e761a66fce0b944c165f1e12ed4dcda481ae5719083bd5f8f205abd5e80a92ca8b22aeaf93da1fd50c4403ce1fffacf55f1b7ae6ecf02edbca3d9ce
6
+ metadata.gz: 5da26eabf4ff59a841bcddedec2588fa435da89d924b71019e129a8594a279982b2c77eef1d372e09cbacd59a06936e0d1d3f5d5a5892de4ec2076bb5b45e25f
7
+ data.tar.gz: f2eceab488770ad342bf9b9760eae04edb8d60e5dd4ac216a04d5b710f3552559b83da7f7e2990c0e3cfbeb990d717bf7d69b5af2ba65f7ff61dfa81e55dfa36
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/like_im_five.svg)](https://badge.fury.io/rb/like_im_five)
2
+ ![Build Status](https://img.shields.io/circleci/build/github/morissetcl/like_im_five/master)
1
3
  # like_im_five
2
4
 
3
5
  Do you use the awesome [factory_bot gem](https://github.com/thoughtbot/factory_bot) to create your contexts ?
@@ -109,6 +111,12 @@ create_table "dummy_app_articles", force: :cascade do |t|
109
111
 
110
112
  Connect `website_id` with `dummy_app_websites` can be messy but that's fine.
111
113
 
114
+ ## Testing
115
+
116
+ To run the test suite please type in your cli:
117
+
118
+ `bundle exec rspec dummy_app/spec/dummy/spec`
119
+
112
120
  ## Contributing
113
121
 
114
122
  Bug reports and pull requests are welcome on GitHub at https://github.com/morissetcl/like_im_five. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/morissetcl/like_im_five/blob/master/CODE_OF_CONDUCT.md).
@@ -3,7 +3,7 @@ require 'rails'
3
3
  class CreateFactory
4
4
  class << self
5
5
  def call(objects)
6
- File.open("spec/data.txt", "w+") do |f|
6
+ File.open(path, "w+") do |f|
7
7
  objects.each do |object|
8
8
  f.puts(formatte_factory(object))
9
9
  f.puts("\n")
@@ -13,6 +13,10 @@ class CreateFactory
13
13
 
14
14
  private
15
15
 
16
+ def path
17
+ Rails.env.test? ? "./dummy_app/spec/data.txt" : "spec/data.txt"
18
+ end
19
+
16
20
  def formatte_factory(object)
17
21
  atttributes_symbolized = object[:attributes][0].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
18
22
  formatted_attributes = atttributes_symbolized.to_s.delete(':').delete('{').delete('}').gsub("=>", ": ")
@@ -14,7 +14,6 @@ class ExtractSpecificObject < GeneralConfiguration
14
14
  return not_found(table, id) if result.blank?
15
15
 
16
16
  remove_timestamps(result)
17
-
18
17
  associated_object = [{ table: table, attributes: result }]
19
18
  ExtractAssociatedObject.new(result, associated_object).call
20
19
  end
@@ -1,6 +1,18 @@
1
1
  class GeneralConfiguration
2
- def self.initialize_configuration
3
- db_config = YAML.load(ERB.new(File.read('./config/database.yml')).result)
4
- ActiveRecord::Base.establish_connection(db_config['development'])
2
+ class << self
3
+ def initialize_configuration
4
+ if Rails.env.test?
5
+ connect_database('test', "/dummy_app")
6
+ else
7
+ connect_database('development', "")
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def connect_database(env, path)
14
+ db_config = YAML.load(ERB.new(File.read(".#{path}/config/database.yml")).result)
15
+ ActiveRecord::Base.establish_connection(db_config[env])
16
+ end
5
17
  end
6
18
  end
@@ -1,3 +1,3 @@
1
1
  module LikeImFive
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: like_im_five
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clément Morisset
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-11 00:00:00.000000000 Z
11
+ date: 2020-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pg
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: Like Im Five generate a file with factories you need to test a specific
42
56
  object. It use your development database to retrieve the object you want and all
43
57
  associations you will have need to setup the test.