souls 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/exe/souls +1 -1
- data/lib/souls/init.rb +120 -4
- data/lib/souls/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae7581dc9bdd5395bcf08caaa70221c6a16dadf92260f983b6322e69210f4ef2
|
4
|
+
data.tar.gz: 9b6948571a0324e31ce4189a0c304e33ddf0d4a60cdd4f122b9a4e84ed5f8c6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df7192f836e9696628dcdd22d81de018cf6f9f6e5cb746f5e9cdd44d5d959e757fcbf89c57d8d7e34207f9b1180db2cac2104d79aea1198af3030d47522326c1
|
7
|
+
data.tar.gz: f1a56524a566aee14ed3bd61598d839c3f495cc0d3f29db529b33a505ade6323d0fb04800df0f5622dca1aab5568d2212edd0356a6678551d70e32ca6d3a734d
|
data/Gemfile.lock
CHANGED
data/exe/souls
CHANGED
data/lib/souls/init.rb
CHANGED
@@ -628,8 +628,8 @@ module Souls
|
|
628
628
|
File.open(file_path, "w") do |f|
|
629
629
|
f.write <<~EOS
|
630
630
|
RSpec.describe \"#{class_name.camelize} Mutation テスト\" do
|
631
|
-
describe "#{class_name.camelize}
|
632
|
-
let!(:#{class_name.singularize.
|
631
|
+
describe "#{class_name.camelize} データを登録する" do
|
632
|
+
let!(:#{class_name.singularize.underscore}) { FactoryBot.create(:#{class_name.singularize.underscore}) }
|
633
633
|
|
634
634
|
let(:mutation) do
|
635
635
|
%(mutation {
|
@@ -647,7 +647,7 @@ module Souls
|
|
647
647
|
f.each_line.with_index do |line, i|
|
648
648
|
if @on
|
649
649
|
if line.include?("end") || line.include?("t.index")
|
650
|
-
new_line.write " }) {\n
|
650
|
+
new_line.write " }) {\n #{class_name.singularize.camelize} {\n id\n"
|
651
651
|
break
|
652
652
|
end
|
653
653
|
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
@@ -759,6 +759,7 @@ end
|
|
759
759
|
end
|
760
760
|
end
|
761
761
|
end
|
762
|
+
[file_path]
|
762
763
|
end
|
763
764
|
|
764
765
|
def rspec_mutation class_name: "souls"
|
@@ -769,8 +770,115 @@ end
|
|
769
770
|
rspec_mutation_end class_name: singularized_class_name
|
770
771
|
end
|
771
772
|
|
773
|
+
def rspec_query_head class_name: "souls"
|
774
|
+
file_path = "./spec/queries/#{class_name.pluralize}.rb"
|
775
|
+
File.open(file_path, "w") do |f|
|
776
|
+
f.write <<~EOS
|
777
|
+
RSpec.describe \"#{class_name.camelize} Query テスト\" do
|
778
|
+
describe "#{class_name.camelize} データを取得する" do
|
779
|
+
let!(:#{class_name.singularize.underscore}) { FactoryBot.create(:#{class_name.singularize.underscore}) }
|
780
|
+
|
781
|
+
let(:query) do
|
782
|
+
%(query {
|
783
|
+
#{class_name.camelize}(id: 1) {
|
784
|
+
id
|
785
|
+
EOS
|
786
|
+
end
|
787
|
+
end
|
788
|
+
|
789
|
+
def rspec_query_params class_name: "souls"
|
790
|
+
file_path = "./spec/queries/#{class_name.pluralize}.rb"
|
791
|
+
path = "./db/schema.rb"
|
792
|
+
@on = false
|
793
|
+
File.open(file_path, "a") do |new_line|
|
794
|
+
File.open(path, "r") do |f|
|
795
|
+
f.each_line.with_index do |line, i|
|
796
|
+
if @on
|
797
|
+
if line.include?("end") || line.include?("t.index")
|
798
|
+
new_line.write <<-EOS
|
799
|
+
}
|
800
|
+
}
|
801
|
+
)
|
802
|
+
end
|
803
|
+
|
804
|
+
subject(:result) do
|
805
|
+
SoulsApiSchema.execute(query).as_json
|
806
|
+
end
|
807
|
+
|
808
|
+
it "return #{class_name.camelize} Data" do
|
809
|
+
a1 = result.dig("data", "#{class_name.singularize.underscore}")
|
810
|
+
expect(a1).to include(
|
811
|
+
"id" => be_a(String),
|
812
|
+
EOS
|
813
|
+
break
|
814
|
+
end
|
815
|
+
_, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
816
|
+
case name
|
817
|
+
when "created_at", "updated_at"
|
818
|
+
next
|
819
|
+
else
|
820
|
+
new_line.write " #{name.singularize.camelize(:lower)}\n"
|
821
|
+
end
|
822
|
+
end
|
823
|
+
if table_check(line: line, class_name: class_name)
|
824
|
+
@on = true
|
825
|
+
end
|
826
|
+
end
|
827
|
+
end
|
828
|
+
end
|
829
|
+
end
|
830
|
+
|
831
|
+
def rspec_query_end class_name: "souls"
|
832
|
+
file_path = "./spec/queries/#{class_name.pluralize}.rb"
|
833
|
+
path = "./db/schema.rb"
|
834
|
+
@on = false
|
835
|
+
File.open(file_path, "a") do |new_line|
|
836
|
+
File.open(path, "r") do |f|
|
837
|
+
f.each_line.with_index do |line, i|
|
838
|
+
if @on
|
839
|
+
if line.include?("end") || line.include?("t.index")
|
840
|
+
new_line.write <<-EOS
|
841
|
+
)
|
842
|
+
end
|
843
|
+
end
|
844
|
+
end
|
845
|
+
EOS
|
846
|
+
break
|
847
|
+
end
|
848
|
+
type, name = line.split(",")[0].gsub("\"", "").scan(/((?<=t\.).+(?=\s)) (.+)/)[0]
|
849
|
+
field ||= type_check type
|
850
|
+
array_true = line.include?("array: true")
|
851
|
+
case name
|
852
|
+
when "created_at", "updated_at"
|
853
|
+
next
|
854
|
+
else
|
855
|
+
case type
|
856
|
+
when "text"
|
857
|
+
if array_true
|
858
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_all(String),\n"
|
859
|
+
end
|
860
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
|
861
|
+
when "string", "bigint", "integer", "float", "boolean"
|
862
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(#{field}),\n"
|
863
|
+
when "date", "datetime"
|
864
|
+
new_line.write " \"#{name.singularize.camelize(:lower)}\" => be_a(DateTime),\n"
|
865
|
+
end
|
866
|
+
end
|
867
|
+
end
|
868
|
+
if table_check(line: line, class_name: class_name)
|
869
|
+
@on = true
|
870
|
+
end
|
871
|
+
end
|
872
|
+
end
|
873
|
+
end
|
874
|
+
[file_path]
|
875
|
+
end
|
876
|
+
|
772
877
|
def rspec_query class_name: "souls"
|
773
|
-
|
878
|
+
singularized_class_name = class_name.singularize
|
879
|
+
rspec_query_head class_name: singularized_class_name
|
880
|
+
rspec_query_params class_name: singularized_class_name
|
881
|
+
rspec_query_end class_name: singularized_class_name
|
774
882
|
end
|
775
883
|
|
776
884
|
def get_end_point
|
@@ -807,6 +915,7 @@ end
|
|
807
915
|
type_paths = type class_name: singularized_class_name
|
808
916
|
rspec_factory_paths = rspec_factory class_name: singularized_class_name
|
809
917
|
rspec_model_paths = rspec_model class_name: singularized_class_name
|
918
|
+
rspec_mutation_paths = rspec_mutation class_name: singularized_class_name
|
810
919
|
query_path = query class_name: singularized_class_name
|
811
920
|
mutation_path = mutation class_name: singularized_class_name
|
812
921
|
[
|
@@ -814,6 +923,7 @@ end
|
|
814
923
|
type: type_paths,
|
815
924
|
rspec_factory: rspec_factory_paths,
|
816
925
|
rspec_model: rspec_model_paths,
|
926
|
+
rspec_mutation: rspec_mutation_paths,
|
817
927
|
query: query_path,
|
818
928
|
mutation: mutation_path,
|
819
929
|
add_query_type: [
|
@@ -858,6 +968,12 @@ end
|
|
858
968
|
path[:rspec_model].each { |line| puts line }
|
859
969
|
end
|
860
970
|
end
|
971
|
+
puts "\n============== RspecMutation =================\n\n"
|
972
|
+
paths.each do |class_name|
|
973
|
+
class_name.each do |path|
|
974
|
+
path[:rspec_mutation].each { |line| puts line }
|
975
|
+
end
|
976
|
+
end
|
861
977
|
puts "\n============== Query ======================\n\n"
|
862
978
|
paths.each do |class_name|
|
863
979
|
class_name.each do |path|
|
data/lib/souls/version.rb
CHANGED