rails-dummy 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: c0fb8f2cebc54687ef61f29acc601aba8eb826b8
4
- data.tar.gz: 2e7c7850e76f6a41af4428f54c5215ae625e0476
3
+ metadata.gz: 4b462b504bb1379c4809cf1251c6925605cb9eef
4
+ data.tar.gz: 1f240225d247ac487eabc6594759f9258435586c
5
5
  SHA512:
6
- metadata.gz: 9ceb7125df75fd1a881321a344d1517f7c0f92b4a21d585c21c8c001fd64ca89c68b92f634c21bd06871780b8e28416f2de182c74dd3791f9e8b7a5604e605e3
7
- data.tar.gz: 631a8ef5c136154cbe0ec2ae2bc16c35d978145d8f4421a2f3d490075f0059f0fcee5a0a6f8ec692cc45eada2532d0f5d90ccc2cd81721ad7e59747dffdd5d02
6
+ metadata.gz: d6c3a8dee80c999163902205638e4218a5c84ba47e7c2289c690e35c133b46fed4ccaff7d7760a0e0f0835d72a1b2455a64fda4975c35d4f3f4ffe1e72961a26
7
+ data.tar.gz: 46281ac6d40467023083c64af04c504ea21a8478a3f92f0d519ff892de7db301a146a1e94790a3c484cc1a3cb3bd20189000daf459803f99fb1577c4d12858ea
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Rails::Dummy
2
2
 
3
+ [![Build Status](https://travis-ci.org/Courseware/rails-dummy.png?branch=master)](https://travis-ci.org/Courseware/rails-dummy)
4
+
3
5
  A simple task to generate a dummy app for engines using RSpec or Test::Unit.
4
6
 
5
7
  ## Installation
@@ -26,8 +28,7 @@ Now you should be able to run:
26
28
 
27
29
  rake dummy:app
28
30
 
29
-
30
- ## Customization by environment variables:
31
+ ## Customization by environment variables:
31
32
 
32
33
  `DUMMY_APP_PATH` - Specify path where dummy app will be located. Defaults to `spec/dummy`.
33
34
 
@@ -39,8 +40,6 @@ Now you should be able to run:
39
40
 
40
41
  `DISABLE_MIGRATE` - Don't run `db:migrate db:test:prepare` after creating database.
41
42
 
42
-
43
-
44
43
  ## Projects using this gem
45
44
 
46
45
  * [Coursewa.re](http://coursewa.re/about)
@@ -51,7 +50,7 @@ Now you should be able to run:
51
50
 
52
51
  1. Fork it
53
52
  2. Create your feature branch (`git checkout -b my-new-feature`)
54
- 3. Commit your changes (`git commit -am 'Add some feature'`)
53
+ 3. Commit your changes. Write some tests. (`git commit -am 'Add some feature'`)
55
54
  4. Push to the branch (`git push origin my-new-feature`)
56
55
  5. Create new Pull Request
57
56
 
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -1,6 +1,6 @@
1
1
  require 'rails/generators'
2
2
  require 'rails/generators/rails/plugin_new/plugin_new_generator'
3
- require "rails/dummy/version"
3
+ require 'rails/dummy/version'
4
4
 
5
5
  module Rails
6
6
  module Dummy
@@ -24,6 +24,7 @@ module Rails
24
24
  alias :update_gemfile :do_nothing
25
25
  alias :create_test_files :do_nothing
26
26
  alias :finish_template :do_nothing
27
+ alias :create_bin_files :do_nothing
27
28
 
28
29
  end
29
30
  end
@@ -1,5 +1,5 @@
1
1
  module Rails
2
2
  module Dummy
3
- VERSION = "0.0.2"
3
+ VERSION = '0.0.3'
4
4
  end
5
5
  end
@@ -1,52 +1,62 @@
1
1
  namespace :dummy do
2
- desc 'Generates a dummy app for testing. Use options: `DUMMY_PATH` and `ENGINE`'
2
+ desc 'Generates a dummy app for testing. Use options: `DUMMY_APP_PATH` and `ENGINE`'
3
3
  task :app => [:setup, :template, :install_migrations, :create, :migrate]
4
4
 
5
- @original_dir = File.expand_path('.')
6
-
7
5
  task :setup do
8
6
  dummy = File.expand_path(dummy_path)
9
- sh("rm -rf #{dummy}")
10
- Rails::Dummy::Generator.start(
11
- %W(. -q -f --skip-bundle -T -G --dummy-path=#{dummy})
12
- )
7
+ FileUtils.rm_rf(dummy)
8
+ params = %W{. -q -f --skip-bundle -T -G}
9
+ params << '--dummy-path=%s' % dummy
10
+ Rails::Dummy::Generator.start(params)
13
11
  end
14
12
 
15
13
  task :template do
16
14
  unless ENV['TEMPLATE']
17
- puts 'No `TEMPLATE` environment variable was set, no template to apply.'
15
+ Kernel.puts 'No `TEMPLATE` environment variable was set, no template to apply.'
18
16
  else
19
17
  # File.expand_path is executed directory of generated Rails app
20
- rakefile = File.expand_path('Rakefile')
21
- template = File.expand_path(ENV['TEMPLATE'], @original_dir)
22
- sh("rake -f #{rakefile} rails:template LOCATION=#{template}")
18
+ rakefile = File.expand_path('Rakefile', dummy_path)
19
+ template = File.expand_path(
20
+ ENV['TEMPLATE'], File.expand_path('../../', dummy_path))
21
+ command = "rake -f '%s' rails:template LOCATION='%s'" % [
22
+ rakefile, template]
23
+ sh(command)
23
24
  end
24
25
  end
25
26
 
26
27
  task :install_migrations do
27
28
  engine = ENV['ENGINE']
28
29
  unless engine
29
- puts 'No `ENGINE` environment variable was set, no migrations to install.'
30
+ Kernel.puts 'No `ENGINE` environment variable was set, no migrations to install.'
30
31
  else
31
32
  # File.expand_path is executed directory of generated Rails app
32
- rakefile = File.expand_path('Rakefile')
33
- sh("rake -f #{rakefile} #{engine.downcase}:install:migrations")
33
+ rakefile = File.expand_path('Rakefile', dummy_path)
34
+ command = "rake -f '%s' %s:install:migrations" % [
35
+ rakefile, engine.downcase]
36
+ sh(command)
34
37
  end
35
38
  end
36
-
37
- task :create do
39
+
40
+ task :create do
38
41
  # File.expand_path is executed directory of generated Rails app
39
- rakefile = File.expand_path('Rakefile')
40
- sh("rake -f #{rakefile} db:create") unless ENV["DISABLE_CREATE"]
42
+ rakefile = File.expand_path('Rakefile', dummy_path)
43
+ command = "rake -f '%s' db:create" % rakefile
44
+ sh(command) unless ENV["DISABLE_CREATE"]
41
45
  end
42
-
46
+
43
47
  task :migrate do
44
48
  # File.expand_path is executed directory of generated Rails app
45
- rakefile = File.expand_path('Rakefile')
46
- sh("rake -f #{rakefile} db:migrate db:test:prepare") unless ENV["DISABLE_MIGRATE"]
49
+ rakefile = File.expand_path('Rakefile', dummy_path)
50
+ command = "rake -f '%s' db:migrate db:test:prepare" % rakefile
51
+ sh(command) unless ENV["DISABLE_MIGRATE"]
47
52
  end
48
-
53
+
49
54
  def dummy_path
50
- ENV['DUMMY_APP_PATH'] || 'spec/dummy'
55
+ rel_path = ENV['DUMMY_APP_PATH'] || 'spec/dummy'
56
+ if @current_path.to_s.include?(rel_path)
57
+ @current_path
58
+ else
59
+ @current_path = File.expand_path(rel_path)
60
+ end
51
61
  end
52
62
  end
@@ -22,4 +22,6 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "rspec-rake"
25
27
  end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rails::Dummy::Generator do
4
+ let(:dummy_path) { './dummy_app_path' }
5
+ let(:full_dummy_path) do
6
+ spec_folder_path = File.expand_path('../../../', __FILE__)
7
+ File.expand_path(dummy_path, spec_folder_path)
8
+ end
9
+
10
+ before do
11
+ params = %W{. -q -f --skip-bundle -T -G}
12
+ params << '--dummy-path=%s' % dummy_path
13
+ Rails::Dummy::Generator.start(params)
14
+ end
15
+
16
+ after do
17
+ FileUtils.rm_rf(full_dummy_path) if File.exist?(full_dummy_path)
18
+ end
19
+
20
+ it 'creates a dummy app' do
21
+ File.exist?(full_dummy_path).should be_true
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ require 'rails/dummy/generator'
2
+ require 'rspec/rake'
3
+
4
+ # This file was generated by the `rspec --init` command. Conventionally, all
5
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
+ # Require this file using `require "spec_helper"` to ensure that it is only
7
+ # loaded once.
8
+ #
9
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+
15
+ # Run specs in random order to surface order dependencies. If you find an
16
+ # order dependency and want to debug it, you can fix the order by providing
17
+ # the seed, which is printed after each run.
18
+ # --seed 1234
19
+ config.order = 'random'
20
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'dummy:app' do
4
+ its(:prerequisites) { should include('setup') }
5
+ its(:prerequisites) { should include('template') }
6
+ its(:prerequisites) { should include('install_migrations') }
7
+ its(:prerequisites) { should include('create') }
8
+ its(:prerequisites) { should include('migrate') }
9
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'dummy:create' do
4
+
5
+ context 'when DISABLE_CREATE variable is set' do
6
+ before do
7
+ ENV['DISABLE_CREATE'] = '1'
8
+ # An equivalent of mocking `sh` method
9
+ Rake::AltSystem.should_not_receive(:system)
10
+ end
11
+
12
+ after do
13
+ ENV.delete('DISABLE_CREATE')
14
+ end
15
+
16
+ it 'does not call rake with db:create task' do
17
+ task.invoke
18
+ end
19
+ end
20
+
21
+ context 'when DISABLE_CREATE variable is not set' do
22
+ before do
23
+ rakefile = File.expand_path('../../dummy/Rakefile', __FILE__)
24
+ command = "rake -f '%s' db:create" % [rakefile]
25
+ # An equivalent of mocking `sh` method
26
+ Rake::AltSystem.should_receive(:system).with(command).and_return(true)
27
+ end
28
+
29
+ it 'calls rake with db:create task' do
30
+ task.invoke
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'dummy:install_migrations' do
4
+
5
+ context 'when ENGINE variable was not set' do
6
+ before { Kernel.should_receive(:puts) }
7
+
8
+ it 'calls puts with a notice message' do
9
+ task.invoke
10
+ end
11
+ end
12
+
13
+ context 'when ENGINE variable is set' do
14
+ let(:engine_name) { 'TEST_ENGINE' }
15
+
16
+ before do
17
+ ENV['ENGINE'] = engine_name
18
+ rakefile = File.expand_path('../../dummy/Rakefile', __FILE__)
19
+ command = "rake -f '%s' %s:install:migrations" % [
20
+ rakefile, engine_name.downcase ]
21
+ # An equivalent of mocking `sh` method
22
+ Rake::AltSystem.should_receive(:system).with(command).and_return(true)
23
+ end
24
+
25
+ after do
26
+ ENV.delete('ENGINE')
27
+ end
28
+
29
+ it 'calls rake with $ENGINE:install:migrations task' do
30
+ task.invoke
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'dummy:migrate' do
4
+
5
+ context 'when DISABLE_MIGRATE variable is set' do
6
+ before do
7
+ ENV['DISABLE_MIGRATE'] = '1'
8
+ # An equivalent of mocking `sh` method
9
+ Rake::AltSystem.should_not_receive(:system)
10
+ end
11
+
12
+ after do
13
+ ENV.delete('DISABLE_MIGRATE')
14
+ end
15
+
16
+ it 'does not call rake with db:migrate and db:test:prepare task' do
17
+ task.invoke
18
+ end
19
+ end
20
+
21
+ context 'when DISABLE_MIGRATE variable is not set' do
22
+ before do
23
+ rakefile = File.expand_path('../../dummy/Rakefile', __FILE__)
24
+ command = "rake -f '%s' db:migrate db:test:prepare" % rakefile
25
+ # An equivalent of mocking `sh` method
26
+ Rake::AltSystem.should_receive(:system).with(command).and_return(true)
27
+ end
28
+
29
+ it 'calls rake with db:migrate db:test:prepare task' do
30
+ task.invoke
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'dummy:setup' do
4
+ let(:dummy_path) { 'spec/dummy' }
5
+
6
+ before do
7
+ full_dummy_path = File.expand_path("../../../#{dummy_path}", __FILE__)
8
+ FileUtils.should_receive(:rm_rf).with(full_dummy_path)
9
+ Rails::Dummy::Generator.should_receive(:start).with(
10
+ %W(. -q -f --skip-bundle -T -G --dummy-path=#{full_dummy_path})
11
+ )
12
+ end
13
+
14
+ it 'removes and generates a new dummy app' do
15
+ task.invoke
16
+ end
17
+
18
+ context 'using DUMMY_APP_PATH environment variable' do
19
+ let(:dummy_path) { 'test_path' }
20
+
21
+ it 'removes and generates a new dummy app' do
22
+ ENV['DUMMY_APP_PATH'] = dummy_path
23
+ task.invoke
24
+ ENV.delete('DUMMY_APP_PATH')
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'dummy:template' do
4
+
5
+ context 'when TEMPLATE variable was not set' do
6
+ before { Kernel.should_receive(:puts) }
7
+
8
+ it 'calls puts with a notice message' do
9
+ task.invoke
10
+ end
11
+ end
12
+
13
+ context 'when TEMPLATE variable is set' do
14
+ let(:template) { 'test/TMPL' }
15
+
16
+ before do
17
+ ENV['TEMPLATE'] = template
18
+ rakefile = File.expand_path('../../dummy/Rakefile', __FILE__)
19
+ template_path = File.expand_path(
20
+ template, File.expand_path('../../../', __FILE__))
21
+
22
+ command = "rake -f '%s' rails:template LOCATION='%s'" % [
23
+ rakefile, template_path ]
24
+ # An equivalent of mocking `sh` method
25
+ Rake::AltSystem.should_receive(:system).with(command).and_return(true)
26
+ end
27
+
28
+ after do
29
+ ENV.delete('TEMPLATE')
30
+ end
31
+
32
+ it 'calls rake with rails:template task' do
33
+ task.invoke
34
+ end
35
+ end
36
+ end
metadata CHANGED
@@ -1,55 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-dummy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stas SUȘCOV
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-28 00:00:00.000000000 Z
11
+ date: 2014-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
53
81
  - !ruby/object:Gem::Version
54
82
  version: '0'
55
83
  description: Rake task to generate a dummy Rails app.
@@ -59,7 +87,8 @@ executables: []
59
87
  extensions: []
60
88
  extra_rdoc_files: []
61
89
  files:
62
- - .gitignore
90
+ - ".gitignore"
91
+ - ".rspec"
63
92
  - Gemfile
64
93
  - LICENSE.txt
65
94
  - README.md
@@ -70,6 +99,14 @@ files:
70
99
  - lib/rails/dummy/version.rb
71
100
  - lib/tasks/dummy.rake
72
101
  - rails-dummy.gemspec
102
+ - spec/integration/generator_spec.rb
103
+ - spec/spec_helper.rb
104
+ - spec/tasks/dummy_app_spec.rb
105
+ - spec/tasks/dummy_create_spec.rb
106
+ - spec/tasks/dummy_install_migrations_spec.rb
107
+ - spec/tasks/dummy_migrate_spec.rb
108
+ - spec/tasks/dummy_setup_spec.rb
109
+ - spec/tasks/dummy_template_spec.rb
73
110
  homepage: https://github.com/courseware/rails-dummy
74
111
  licenses:
75
112
  - MIT
@@ -80,18 +117,26 @@ require_paths:
80
117
  - lib
81
118
  required_ruby_version: !ruby/object:Gem::Requirement
82
119
  requirements:
83
- - - '>='
120
+ - - ">="
84
121
  - !ruby/object:Gem::Version
85
122
  version: '0'
86
123
  required_rubygems_version: !ruby/object:Gem::Requirement
87
124
  requirements:
88
- - - '>='
125
+ - - ">="
89
126
  - !ruby/object:Gem::Version
90
127
  version: '0'
91
128
  requirements: []
92
129
  rubyforge_project:
93
- rubygems_version: 2.0.3
130
+ rubygems_version: 2.2.0
94
131
  signing_key:
95
132
  specification_version: 4
96
133
  summary: Use it to generate a dummy app for RSpec
97
- test_files: []
134
+ test_files:
135
+ - spec/integration/generator_spec.rb
136
+ - spec/spec_helper.rb
137
+ - spec/tasks/dummy_app_spec.rb
138
+ - spec/tasks/dummy_create_spec.rb
139
+ - spec/tasks/dummy_install_migrations_spec.rb
140
+ - spec/tasks/dummy_migrate_spec.rb
141
+ - spec/tasks/dummy_setup_spec.rb
142
+ - spec/tasks/dummy_template_spec.rb