pliny 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +14 -6
  2. data/README.md +59 -11
  3. data/bin/pliny-generate +2 -14
  4. data/bin/pliny-new +1 -1
  5. data/lib/pliny.rb +1 -2
  6. data/lib/pliny/commands/creator.rb +10 -11
  7. data/lib/pliny/commands/generator.rb +50 -199
  8. data/lib/pliny/commands/generator/base.rb +59 -0
  9. data/lib/pliny/commands/generator/endpoint.rb +44 -0
  10. data/lib/pliny/commands/generator/mediator.rb +21 -0
  11. data/lib/pliny/commands/generator/migration.rb +13 -0
  12. data/lib/pliny/commands/generator/model.rb +30 -0
  13. data/lib/pliny/commands/generator/schema.rb +24 -0
  14. data/lib/pliny/commands/generator/serializer.rb +21 -0
  15. data/lib/pliny/config_helpers.rb +52 -0
  16. data/lib/pliny/helpers/encode.rb +7 -0
  17. data/lib/pliny/log.rb +18 -1
  18. data/lib/pliny/middleware/versioning.rb +3 -3
  19. data/lib/pliny/tasks/db.rake +21 -7
  20. data/lib/pliny/tasks/schema.rake +2 -2
  21. data/lib/pliny/templates/endpoint.erb +5 -5
  22. data/lib/pliny/templates/endpoint_acceptance_test.erb +1 -1
  23. data/lib/pliny/templates/endpoint_scaffold.erb +5 -5
  24. data/lib/pliny/templates/endpoint_scaffold_acceptance_test.erb +1 -1
  25. data/lib/pliny/templates/endpoint_test.erb +1 -0
  26. data/lib/pliny/templates/migration.erb +0 -2
  27. data/lib/pliny/templates/model.erb +0 -2
  28. data/lib/pliny/templates/model_test.erb +0 -1
  29. data/lib/pliny/templates/serializer_test.erb +0 -1
  30. data/lib/pliny/version.rb +1 -1
  31. data/template/.env.sample +2 -1
  32. data/template/README.md +1 -1
  33. data/template/bin/console +1 -3
  34. data/template/bin/run +1 -3
  35. data/template/config.ru +1 -4
  36. data/template/config/config.rb +19 -25
  37. data/template/config/initializers/rollbar.rb +1 -0
  38. data/template/config/puma.rb +2 -2
  39. data/template/db/schema.sql +1 -2
  40. data/template/lib/application.rb +4 -0
  41. data/template/lib/endpoints/base.rb +1 -0
  42. data/template/lib/routes.rb +1 -1
  43. data/template/lib/serializers/base.rb +8 -1
  44. data/test/commands/creator_test.rb +1 -0
  45. data/test/commands/generator/base_test.rb +103 -0
  46. data/test/commands/generator/endpoint_test.rb +15 -0
  47. data/test/commands/generator_test.rb +95 -134
  48. data/test/log_test.rb +16 -0
  49. metadata +100 -69
@@ -6,7 +6,7 @@ module Endpoints
6
6
  end
7
7
 
8
8
  get do
9
- MultiJson.encode <%= singular_class_name %>.all.map { |x| serialize(x) }
9
+ encode serialize(<%= singular_class_name %>.all)
10
10
  end
11
11
 
12
12
  post do
@@ -14,25 +14,25 @@ module Endpoints
14
14
  <%= field_name %> = <%= singular_class_name %>.new(body_params)
15
15
  <%= field_name %>.save
16
16
  status 201
17
- MultiJson.encode serialize(<%= field_name %>)
17
+ encode serialize(<%= field_name %>)
18
18
  end
19
19
 
20
20
  get "/:id" do |id|
21
21
  <%= field_name %> = <%= singular_class_name %>.first(uuid: id) || halt(404)
22
- MultiJson.encode serialize(<%= field_name %>)
22
+ encode serialize(<%= field_name %>)
23
23
  end
24
24
 
25
25
  patch "/:id" do |id|
26
26
  <%= field_name %> = <%= singular_class_name %>.first(uuid: id) || halt(404)
27
27
  # warning: not safe
28
28
  #<%= field_name %>.update(body_params)
29
- MultiJson.encode serialize(<%= field_name %>)
29
+ encode serialize(<%= field_name %>)
30
30
  end
31
31
 
32
32
  delete "/:id" do |id|
33
33
  <%= field_name %> = <%= singular_class_name %>.first(uuid: id) || halt(404)
34
34
  <%= field_name %>.destroy
35
- MultiJson.encode serialize(<%= field_name %>)
35
+ encode serialize(<%= field_name %>)
36
36
  end
37
37
 
38
38
  private
@@ -29,7 +29,7 @@ describe Endpoints::<%= plural_class_name %> do
29
29
  end
30
30
 
31
31
  =begin
32
- describe 'POST <%= url_path %>/:id' do
32
+ describe 'POST <%= url_path %>' do
33
33
  it 'returns correct status code and conforms to schema' do
34
34
  header "Content-Type", "application/json"
35
35
  post '<%= url_path %>', MultiJson.encode({})
@@ -5,6 +5,7 @@ describe Endpoints::<%= plural_class_name %> do
5
5
 
6
6
  def app
7
7
  Endpoints::<%= plural_class_name %>
8
+
8
9
  end
9
10
 
10
11
  describe "GET <%= url_path %>" do
@@ -1,9 +1,7 @@
1
1
  Sequel.migration do
2
2
  up do
3
-
4
3
  end
5
4
 
6
5
  down do
7
-
8
6
  end
9
7
  end
@@ -1,8 +1,6 @@
1
1
  class <%= singular_class_name %> < Sequel::Model
2
-
3
2
  plugin :timestamps
4
3
  <% if paranoid %>
5
4
  plugin :paranoid
6
5
  <% end %>
7
-
8
6
  end
@@ -1,5 +1,4 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe <%= singular_class_name %> do
4
-
5
4
  end
@@ -1,5 +1,4 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Serializers::<%= singular_class_name %> do
4
-
5
4
  end
@@ -1,3 +1,3 @@
1
1
  module Pliny
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  DATABASE_URL=postgres://localhost/pliny-development
2
2
  RACK_ENV=development
3
3
  TZ=UTC
4
- RESCUE_ERRORS=false
4
+ RAISE_ERRORS=true
5
5
  FORCE_SSL=false
6
6
  TIMEOUT=false
7
+ PRETTY_JSON=true
@@ -1,5 +1,5 @@
1
1
  # Pliny Template app
2
2
 
3
- This is the template app used by the [Pliny](https://github.com/12-oz/pliny) gem.
3
+ This is the template app used by the [Pliny](https://github.com/interagent/pliny) gem.
4
4
 
5
5
  For more information please refer to the gem docs.
@@ -1,8 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler"
4
- Bundler.require
5
- require "./lib/initializer"
3
+ require_relative '../lib/application'
6
4
 
7
5
  def basic_prompt(target_self, nest_level, pry)
8
6
  # override CONSOLE_BANNER to include something like a release identifier
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler"
4
- Bundler.require
5
- require "./lib/initializer"
3
+ require_relative '../lib/application'
6
4
 
7
5
  eval ARGV.join(" ")
@@ -1,7 +1,4 @@
1
- require "bundler"
2
- Bundler.require
3
-
4
- require "./lib/initializer"
1
+ require_relative 'lib/application'
5
2
 
6
3
  $stdout.sync = true
7
4
 
@@ -6,35 +6,29 @@ require "pliny/config_helpers"
6
6
  #
7
7
  # Each accessor corresponds directly to an ENV key, which has the same name
8
8
  # except upcased, i.e. `DATABASE_URL`.
9
- #
10
- # Note that *all* keys will come out as strings even if the override was a
11
- # different type. Make sure to typecast any values that need to be something
12
- # else (i.e. `.to_i`).
13
9
  module Config
14
- extend Pliny::ConfigHelpers
10
+ extend Pliny::CastingConfigHelpers
15
11
 
16
12
  # Mandatory -- exception is raised for these variables when missing.
17
- mandatory \
18
- :database_url
13
+ mandatory :database_url, string
19
14
 
20
15
  # Optional -- value is returned or `nil` if it wasn't present.
21
- optional \
22
- :console_banner,
23
- :placeholder,
24
- :versioning_default,
25
- :versioning_app_name
16
+ optional :console_banner, string
17
+ optional :placeholder, string
18
+ optional :versioning_default, string
19
+ optional :versioning_app_name, string
26
20
 
27
- # Override -- value is returned or the set default. Remember to typecast.
28
- override \
29
- db_pool: 5,
30
- port: 5000,
31
- puma_max_threads: 16,
32
- puma_min_threads: 1,
33
- puma_workers: 3,
34
- rack_env: 'development',
35
- raise_errors: 'false',
36
- root: File.expand_path("../../", __FILE__),
37
- timeout: 45,
38
- force_ssl: 'true',
39
- versioning: 'false'
21
+ # Override -- value is returned or the set default.
22
+ override :db_pool, 5, int
23
+ override :port, 5000, int
24
+ override :puma_max_threads, 16, int
25
+ override :puma_min_threads, 1, int
26
+ override :puma_workers, 3, int
27
+ override :rack_env, 'development', string
28
+ override :raise_errors, false, bool
29
+ override :root, File.expand_path("../../", __FILE__), string
30
+ override :timeout, 45, int
31
+ override :force_ssl, true, bool
32
+ override :versioning, false, bool
33
+ override :pretty_json, false, bool
40
34
  end
@@ -1,4 +1,5 @@
1
1
  Rollbar.configure do |config|
2
+ config.enabled = ENV.has_key?('ROLLBAR_ACCESS_TOKEN')
2
3
  config.access_token = ENV["ROLLBAR_ACCESS_TOKEN"]
3
4
  config.use_sucker_punch
4
5
  end
@@ -3,8 +3,8 @@ require "./config/config"
3
3
  environment Config.rack_env
4
4
  port Config.port
5
5
  quiet
6
- threads Config.puma_min_threads.to_i, Config.puma_max_threads.to_i
7
- workers Config.puma_workers.to_i
6
+ threads Config.puma_min_threads, Config.puma_max_threads
7
+ workers Config.puma_workers
8
8
 
9
9
  on_worker_boot do
10
10
  # force Sequel's thread pool to be refreshed
@@ -3,6 +3,7 @@
3
3
  --
4
4
 
5
5
  SET statement_timeout = 0;
6
+ SET lock_timeout = 0;
6
7
  SET client_encoding = 'UTF8';
7
8
  SET standard_conforming_strings = on;
8
9
  SET check_function_bodies = false;
@@ -19,7 +20,6 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
19
20
  -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
20
21
  --
21
22
 
22
- COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
23
23
 
24
24
 
25
25
  --
@@ -33,7 +33,6 @@ CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
33
33
  -- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: -
34
34
  --
35
35
 
36
- COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';
37
36
 
38
37
 
39
38
  --
@@ -0,0 +1,4 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ require_relative 'initializer'
@@ -4,6 +4,7 @@ module Endpoints
4
4
  register Pliny::Extensions::Instruments
5
5
  register Sinatra::Namespace
6
6
 
7
+ helpers Pliny::Helpers::Encode
7
8
  helpers Pliny::Helpers::Params
8
9
 
9
10
  set :dump_errors, false
@@ -3,7 +3,7 @@ Routes = Rack::Builder.new do
3
3
  use Pliny::Middleware::CORS
4
4
  use Pliny::Middleware::RequestID
5
5
  use Pliny::Middleware::RequestStore, store: Pliny::RequestStore
6
- use Pliny::Middleware::Timeout, timeout: Config.timeout.to_i if Config.timeout.to_i > 0
6
+ use Pliny::Middleware::Timeout, timeout: Config.timeout if Config.timeout > 0
7
7
  use Pliny::Middleware::Versioning,
8
8
  default: Config.versioning_default,
9
9
  app_name: Config.versioning_app_name if Config.versioning?
@@ -11,7 +11,14 @@ class Serializers
11
11
  end
12
12
 
13
13
  def serialize(object)
14
- @@structures["#{self.class.name}::#{@type}"].call(object)
14
+ object.respond_to?(:map) ? object.map{|item| serializer.call(item)} : serializer.call(object)
15
15
  end
16
+
17
+ private
18
+
19
+ def serializer
20
+ @@structures["#{self.class.name}::#{@type}"]
21
+ end
22
+
16
23
  end
17
24
  end
@@ -1,3 +1,4 @@
1
+ require 'pliny/commands/creator'
1
2
  require "test_helper"
2
3
 
3
4
  describe Pliny::Commands::Creator do
@@ -0,0 +1,103 @@
1
+ require 'pliny/commands/generator'
2
+ require 'pliny/commands/generator/base'
3
+ require 'test_helper'
4
+
5
+ describe Pliny::Commands::Generator::Base do
6
+ subject { Pliny::Commands::Generator::Base.new(model_name, {}, StringIO.new) }
7
+
8
+ describe '#singular_class_name' do
9
+ let(:model_name) { 'resource_histories' }
10
+
11
+ it 'builds a class name for an endpoint' do
12
+ assert_equal 'ResourceHistory', subject.singular_class_name
13
+ end
14
+
15
+ describe 'when name with hypens' do
16
+ let(:model_name) { 'resource-histories' }
17
+
18
+ it 'handles hyphens as underscores' do
19
+ assert_equal 'ResourceHistory', subject.singular_class_name
20
+ end
21
+ end
22
+ end
23
+
24
+ describe '#plural_class_name' do
25
+ let(:model_name) { 'resource_histories' }
26
+
27
+ it 'builds a class name for a model' do
28
+ assert_equal 'ResourceHistories', subject.plural_class_name
29
+ end
30
+
31
+ describe 'when name with hypens' do
32
+ let(:model_name) { 'resource-histories' }
33
+
34
+ it 'handles hyphens as underscores' do
35
+ assert_equal 'ResourceHistories', subject.plural_class_name
36
+ end
37
+ end
38
+ end
39
+
40
+ describe '#field_name' do
41
+ let(:model_name) { 'resource_histories' }
42
+
43
+ it 'uses the singular form' do
44
+ assert_equal 'resource_history', subject.field_name
45
+ end
46
+
47
+ describe 'when name with hypens' do
48
+ let(:model_name) { 'resource-histories' }
49
+
50
+ it 'handles hyphens as underscores' do
51
+ assert_equal 'resource_history', subject.field_name
52
+ end
53
+ end
54
+ end
55
+
56
+ describe '#pluralized_file_name' do
57
+ let(:model_name) { 'resource_history' }
58
+
59
+ it 'uses the plural form' do
60
+ assert_equal 'resource_histories', subject.pluralized_file_name
61
+ end
62
+
63
+ describe 'when name with hypens' do
64
+ let(:model_name) { 'resource-history' }
65
+
66
+ it 'handles hyphens as underscores' do
67
+ assert_equal 'resource_histories', subject.pluralized_file_name
68
+ end
69
+ end
70
+
71
+ describe 'when name with slashs' do
72
+ let(:model_name) { 'resource/history' }
73
+
74
+ it 'handles slashs as directory' do
75
+ assert_equal 'resource/histories', subject.pluralized_file_name
76
+ end
77
+ end
78
+ end
79
+
80
+ describe '#table_name' do
81
+ let(:model_name) { 'resource_history' }
82
+
83
+ it 'uses the plural form' do
84
+ assert_equal 'resource_histories', subject.table_name
85
+ end
86
+
87
+ describe 'when name with hypens' do
88
+ let(:model_name) { 'resource-history' }
89
+
90
+ it 'handles hyphens as underscores' do
91
+ assert_equal 'resource_histories', subject.table_name
92
+ end
93
+ end
94
+
95
+ describe 'when name with slashs' do
96
+ let(:model_name) { 'resource/history' }
97
+
98
+ it 'handles slashs as underscores' do
99
+ assert_equal 'resource_histories', subject.table_name
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,15 @@
1
+ require 'pliny/commands/generator'
2
+ require 'pliny/commands/generator/endpoint'
3
+ require 'test_helper'
4
+
5
+ describe Pliny::Commands::Generator::Endpoint do
6
+ subject { Pliny::Commands::Generator::Endpoint.new(model_name, {}, StringIO.new) }
7
+
8
+ describe '#url_path' do
9
+ let(:model_name) { 'resource_history' }
10
+
11
+ it 'builds a URL path' do
12
+ assert_equal '/resource-histories', subject.url_path
13
+ end
14
+ end
15
+ end
@@ -1,197 +1,158 @@
1
- require "test_helper"
1
+ require 'pliny/commands/generator'
2
+ require 'pliny/commands/generator/base'
3
+ require 'test_helper'
2
4
 
3
5
  describe Pliny::Commands::Generator do
4
- before do
5
- @gen = Pliny::Commands::Generator.new({}, {}, StringIO.new)
6
- end
6
+ subject { Pliny::Commands::Generator.new }
7
7
 
8
- describe "#field_name" do
9
- it "uses the singular form" do
10
- @gen.args = ["model", "resource_histories"]
11
- assert_equal "resource_history", @gen.field_name
12
- end
8
+ before do
9
+ FileUtils.mkdir_p('/tmp/plinytest')
10
+ Dir.chdir('/tmp/plinytest')
11
+ Timecop.freeze(@t = Time.now)
13
12
 
14
- it "handles hyphens as underscores" do
15
- @gen.args = ["model", "resource-histories"]
16
- assert_equal "resource_history", @gen.field_name
13
+ any_instance_of(Pliny::Commands::Generator::Base) do |klass|
14
+ stub(klass).display
17
15
  end
18
16
  end
19
17
 
20
- describe "#plural_class_name" do
21
- it "builds a class name for a model" do
22
- @gen.args = ["model", "resource_histories"]
23
- assert_equal "ResourceHistories", @gen.plural_class_name
24
- end
25
-
26
- it "handles hyphens as underscores" do
27
- @gen.args = ["model", "resource-histories"]
28
- assert_equal "ResourceHistories", @gen.plural_class_name
29
- end
18
+ after do
19
+ FileUtils.rmdir('/tmp/plinytest')
20
+ Timecop.return
30
21
  end
31
22
 
32
- describe "#singular_class_name" do
33
- it "builds a class name for an endpoint" do
34
- @gen.args = ["model", "resource_histories"]
35
- assert_equal "ResourceHistory", @gen.singular_class_name
23
+ describe '#endpoint' do
24
+ before do
25
+ subject.endpoint('artists')
36
26
  end
37
27
 
38
- it "handles hyphens as underscores" do
39
- @gen.args = ["model", "resource-histories"]
40
- assert_equal "ResourceHistory", @gen.singular_class_name
28
+ it 'creates a new endpoint module' do
29
+ assert File.exist?('lib/endpoints/artists.rb')
41
30
  end
42
- end
43
31
 
44
- describe "#table_name" do
45
- it "uses the plural form" do
46
- @gen.args = ["model", "resource_history"]
47
- assert_equal "resource_histories", @gen.table_name
32
+ it 'creates an endpoint test' do
33
+ assert File.exist?('spec/endpoints/artists_spec.rb')
48
34
  end
49
35
 
50
- it "handles hyphens as underscores" do
51
- @gen.args = ["model", "resource-history"]
52
- assert_equal "resource_histories", @gen.table_name
36
+ it 'creates an endpoint acceptance test' do
37
+ assert File.exist?('spec/acceptance/artists_spec.rb')
53
38
  end
54
39
  end
55
40
 
56
- describe "#run!" do
41
+ describe '#mediator' do
57
42
  before do
58
- FileUtils.mkdir_p("/tmp/plinytest")
59
- Dir.chdir("/tmp/plinytest")
60
- Timecop.freeze(@t=Time.now)
43
+ subject.mediator('artists/creator')
61
44
  end
62
45
 
63
- after do
64
- FileUtils.rmdir("/tmp/plinytest")
65
- Timecop.return
46
+ it 'creates a new mediator module' do
47
+ assert File.exist?('lib/mediators/artists/creator.rb')
66
48
  end
67
49
 
68
- describe "generating endpoints" do
69
- before do
70
- @gen.args = ["endpoint", "artists"]
71
- @gen.run!
72
- end
73
-
74
- it "creates a new endpoint module" do
75
- assert File.exists?("lib/endpoints/artists.rb")
76
- end
77
-
78
- it "creates an endpoint test" do
79
- assert File.exists?("spec/endpoints/artists_spec.rb")
80
- end
81
-
82
- it "creates an endpoint acceptance test" do
83
- assert File.exists?("spec/acceptance/artists_spec.rb")
84
- end
50
+ it 'creates a test' do
51
+ assert File.exist?('spec/mediators/artists/creator_spec.rb')
85
52
  end
53
+ end
86
54
 
87
- describe "generating mediators" do
55
+ describe '#model' do
56
+ describe 'simple model' do
88
57
  before do
89
- @gen.args = ["mediator", "artists/creator"]
90
- @gen.run!
58
+ subject.model('artist')
91
59
  end
92
60
 
93
- it "creates a new mediator module" do
94
- assert File.exists?("lib/mediators/artists/creator.rb")
61
+ it 'creates a migration' do
62
+ assert File.exist?("db/migrate/#{@t.to_i}_create_artists.rb")
95
63
  end
96
64
 
97
- it "creates a test" do
98
- assert File.exists?("spec/mediators/artists/creator_spec.rb")
65
+ it 'creates the actual model' do
66
+ assert File.exist?('lib/models/artist.rb')
67
+ end
68
+
69
+ it 'creates a test' do
70
+ assert File.exist?('spec/models/artist_spec.rb')
99
71
  end
100
72
  end
101
73
 
102
- describe "generating models" do
74
+ describe 'model in nested class' do
103
75
  before do
104
- @gen.args = ["model", "artist"]
105
- @gen.run!
76
+ subject.model('administration/user')
106
77
  end
107
78
 
108
- it "creates a migration" do
109
- assert File.exists?("db/migrate/#{@t.to_i}_create_artists.rb")
79
+ it 'creates a migration' do
80
+ assert File.exist?("db/migrate/#{@t.to_i}_create_administration_users.rb")
110
81
  end
111
82
 
112
- it "creates the actual model" do
113
- assert File.exists?("lib/models/artist.rb")
83
+ it 'creates the actual model' do
84
+ assert File.exist?('lib/models/administration/user.rb')
114
85
  end
115
86
 
116
- it "creates a test" do
117
- assert File.exists?("spec/models/artist_spec.rb")
87
+ it 'creates a test' do
88
+ assert File.exist?('spec/models/administration/user_spec.rb')
118
89
  end
119
90
  end
91
+ end
120
92
 
121
- describe "generating scaffolds" do
122
- before do
123
- @gen.args = ["scaffold", "artist"]
124
- @gen.run!
125
- end
126
-
127
- it "creates a new endpoint module" do
128
- assert File.exists?("lib/endpoints/artists.rb")
129
- end
93
+ describe '#scaffold' do
94
+ before do
95
+ subject.scaffold('artist')
96
+ end
130
97
 
131
- it "creates an endpoint test" do
132
- assert File.exists?("spec/endpoints/artists_spec.rb")
133
- end
98
+ it 'creates a new endpoint module' do
99
+ assert File.exist?('lib/endpoints/artists.rb')
100
+ end
134
101
 
135
- it "creates an endpoint acceptance test" do
136
- assert File.exists?("spec/acceptance/artists_spec.rb")
137
- end
102
+ it 'creates an endpoint test' do
103
+ assert File.exist?('spec/endpoints/artists_spec.rb')
104
+ end
138
105
 
139
- it "creates a migration" do
140
- assert File.exists?("db/migrate/#{@t.to_i}_create_artists.rb")
141
- end
106
+ it 'creates an endpoint acceptance test' do
107
+ assert File.exist?('spec/acceptance/artists_spec.rb')
108
+ end
142
109
 
143
- it "creates the actual model" do
144
- assert File.exists?("lib/models/artist.rb")
145
- end
110
+ it 'creates a migration' do
111
+ assert File.exist?("db/migrate/#{@t.to_i}_create_artists.rb")
112
+ end
146
113
 
147
- it "creates a test" do
148
- assert File.exists?("spec/models/artist_spec.rb")
149
- end
114
+ it 'creates the actual model' do
115
+ assert File.exist?('lib/models/artist.rb')
116
+ end
150
117
 
151
- it "creates a schema" do
152
- assert File.exists?("docs/schema/schemata/artist.yaml")
153
- end
118
+ it 'creates a test' do
119
+ assert File.exist?('spec/models/artist_spec.rb')
120
+ end
154
121
 
155
- it "creates a new serializer module" do
156
- assert File.exists?("lib/serializers/artist_serializer.rb")
157
- end
122
+ it 'creates a schema' do
123
+ assert File.exist?('docs/schema/schemata/artist.yaml')
124
+ end
158
125
 
159
- it "creates a test" do
160
- assert File.exists?("spec/serializers/artist_serializer_spec.rb")
161
- end
126
+ it 'creates a new serializer module' do
127
+ assert File.exist?('lib/serializers/artist.rb')
162
128
  end
163
129
 
164
- describe "generating schemas" do
165
- before do
166
- @gen.args = ["schema", "artist"]
167
- @gen.run!
168
- end
130
+ it 'creates a test' do
131
+ assert File.exist?('spec/serializers/artist_spec.rb')
132
+ end
133
+ end
169
134
 
170
- it "creates a schema" do
171
- assert File.exists?("docs/schema/schemata/artist.yaml")
172
- end
135
+ describe '#schema' do
136
+ before do
137
+ subject.schema('artist')
173
138
  end
174
139
 
175
- describe "generating serializers" do
176
- before do
177
- @gen.args = ["serializer", "artist"]
178
- @gen.run!
179
- end
140
+ it 'creates a schema' do
141
+ assert File.exist?('docs/schema/schemata/artist.yaml')
142
+ end
143
+ end
180
144
 
181
- it "creates a new serializer module" do
182
- assert File.exists?("lib/serializers/artist_serializer.rb")
183
- end
145
+ describe '#serializer' do
146
+ before do
147
+ subject.serializer('artist')
148
+ end
184
149
 
185
- it "creates a test" do
186
- assert File.exists?("spec/serializers/artist_serializer_spec.rb")
187
- end
150
+ it 'creates a new serializer module' do
151
+ assert File.exist?('lib/serializers/artist.rb')
188
152
  end
189
- end
190
153
 
191
- describe "#url_path" do
192
- it "builds a URL path" do
193
- @gen.args = ["endpoint", "resource_history"]
194
- assert_equal "/resource-histories", @gen.url_path
154
+ it 'creates a test' do
155
+ assert File.exist?('spec/serializers/artist_spec.rb')
195
156
  end
196
157
  end
197
158
  end