relevance_rails 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/.gitignore +2 -0
  2. data/.rvmrc +1 -0
  3. data/.travis.yml +7 -0
  4. data/CHANGELOG.md +24 -0
  5. data/README.md +101 -4
  6. data/Rakefile +10 -0
  7. data/aws_config.example.yml +15 -0
  8. data/bin/relevance_rails +2 -19
  9. data/lib/generators/deployment/deployment_generator.rb +31 -0
  10. data/lib/generators/fixtures/fixtures_generator.rb +44 -0
  11. data/lib/generators/provision_config/provision_config_generator.rb +56 -0
  12. data/lib/generators/provision_config/templates/authorized_keys.json.erb +6 -0
  13. data/lib/generators/relevance_file/relevance_file_generator.rb +14 -76
  14. data/lib/generators/relevance_file/templates/{Gemfile → Gemfile.erb} +11 -5
  15. data/lib/generators/relevance_file/templates/README.markdown.erb +36 -0
  16. data/lib/generators/relevance_file/templates/application.html.haml.erb +9 -0
  17. data/lib/generators/relevance_file/templates/database.example.yml.mysql.erb +17 -0
  18. data/lib/generators/relevance_file/templates/database.example.yml.postgresql.erb +15 -0
  19. data/lib/generators/relevance_file/templates/deploy.rb.erb +22 -0
  20. data/lib/relevance_rails.rb +26 -1
  21. data/lib/relevance_rails/chef_dna.rb +32 -0
  22. data/lib/relevance_rails/provision.rb +69 -0
  23. data/lib/relevance_rails/railtie.rb +9 -0
  24. data/lib/relevance_rails/relevance_rails_template.rb +18 -26
  25. data/lib/relevance_rails/runner.rb +24 -0
  26. data/lib/relevance_rails/version.rb +1 -1
  27. data/lib/tasks/provision.rake +8 -0
  28. data/relevance_rails.gemspec +7 -2
  29. data/script/ci +57 -0
  30. data/spec/acceptance_spec.rb +25 -0
  31. data/spec/lib/provision_config_generator_spec.rb +27 -0
  32. data/spec/lib/relevance_rails_spec.rb +15 -0
  33. data/spec/lib/runner_spec.rb +22 -0
  34. data/spec/spec_helper.rb +59 -0
  35. data/techdebt.md +15 -0
  36. metadata +115 -12
  37. data/lib/relevance_rails/template_injector.rb +0 -5
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'App is alive', :js => true, :acceptance => true do
4
+ it 'verifies coffeescript served up as js' do
5
+ visit '/assets/relevance_rails.js'
6
+ page.should have_content "console.log('Hello from Relevance, Inc!');"
7
+ end
8
+
9
+ it "verifies haml is served up" do
10
+ visit '/relevance_rails'
11
+ page.should have_content 'WELCOME HOME'
12
+ end
13
+
14
+ it "verifies scss is served up as css" do
15
+ visit '/assets/relevance_rails.css'
16
+ page.should have_content "background-color: blue;"
17
+ end
18
+
19
+ it "verifies a working database connection" do
20
+ visit '/relevance_rails/db'
21
+ within ('h1.database') do
22
+ page.should have_content '_development'
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+ require 'generators/provision_config/provision_config_generator'
3
+
4
+ describe ProvisionConfigGenerator do
5
+ context '#create_authorized_key_data_bag' do
6
+ subject { ProvisionConfigGenerator.new(['name']) }
7
+
8
+ it "aborts if no ssh-keys are found" do
9
+ subject.should_receive(:`).and_return do
10
+ system('exit 1')
11
+ # Actual message that comes back from failed call
12
+ 'The agent has no entities'
13
+ end
14
+ RelevanceRails::PublicKeyFetcher.should_receive(:public_keys).and_return([])
15
+
16
+ should_abort_with(/^No ssh keys were found!/) do
17
+ subject.create_authorized_key_data_bag
18
+ end
19
+ end
20
+
21
+ it "doesn't abort if ssh-keys are found" do
22
+ subject.should_receive(:fetch_keys).and_return(['ssh-rsa ZZZZ'])
23
+ subject.should_receive(:template)
24
+ expect { subject.create_authorized_key_data_bag }.to_not raise_error
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe RelevanceRails do
4
+ context '.rvm_run' do
5
+ it 'aborts when the command fails' do
6
+ should_abort_with(/Command '.+' failed with/) do
7
+ subject.rvm_run('-e "exit 1"')
8
+ end
9
+ end
10
+
11
+ it 'succeeds when the command passes' do
12
+ expect { subject.rvm_run('-e "exit 0"') }.to_not raise_error
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ require 'relevance_rails/runner'
2
+ require 'spec_helper'
3
+
4
+ describe RelevanceRails::Runner do
5
+ context ".start" do
6
+ def start(*args)
7
+ RelevanceRails::Runner.start(args)
8
+ end
9
+
10
+ it "with --version prints version" do
11
+ capture_stdout { start('--version') }.chomp.should ==
12
+ "RelevanceRails #{RelevanceRails::VERSION}"
13
+ end
14
+
15
+ it "new calls exec" do
16
+ RelevanceRails::Runner.should_receive(:exec).with('rails', 'new', 'the_app', '-m',
17
+ File.expand_path(File.dirname(__FILE__) +
18
+ "/../../lib/relevance_rails/relevance_rails_template.rb"))
19
+ start('new', 'the_app')
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,59 @@
1
+ require 'capybara/rspec'
2
+ require 'capybara/dsl'
3
+ require 'relevance_rails'
4
+
5
+ module TestHelpers
6
+ def capture_stderr(&block)
7
+ original_stderr = $stderr
8
+ $stderr = fake = StringIO.new
9
+ begin
10
+ yield
11
+ ensure
12
+ $stderr = original_stderr
13
+ end
14
+ fake.string
15
+ end
16
+
17
+ def capture_stdout(&block)
18
+ original_stdout = $stdout
19
+ $stdout = fake = StringIO.new
20
+ begin
21
+ yield
22
+ ensure
23
+ $stdout = original_stdout
24
+ end
25
+ fake.string
26
+ end
27
+
28
+ # wrapper around raise_error that captures stderr
29
+ def should_abort_with(msg)
30
+ capture_stderr do
31
+ expect do
32
+ yield
33
+ end.to raise_error SystemExit, msg
34
+ end
35
+ end
36
+ end
37
+
38
+ RSpec.configure do |config|
39
+ if ENV['ACCEPTANCE']
40
+ config.include Capybara::DSL
41
+ config.filter_run :acceptance => true
42
+ config.run_all_when_everything_filtered = false
43
+ else
44
+ config.include TestHelpers
45
+ config.filter_run :focused => true
46
+ config.filter_run_excluding :acceptance => true
47
+ config.filter_run_excluding :disabled => true
48
+ config.run_all_when_everything_filtered = true
49
+ end
50
+
51
+ config.alias_example_to :fit, :focused => true
52
+ config.alias_example_to :xit, :disabled => true
53
+ config.alias_example_to :they
54
+ end
55
+
56
+ Capybara.current_driver = :selenium
57
+ Capybara.run_server = false
58
+ #Capybara.app_host = 'http://' + (ENV["ACCEPTANCE_HOST"] || 'localhost:3000')
59
+ Capybara.app_host = ENV["ACCEPTANCE_HOST"] || 'http://localhost:3000'
data/techdebt.md ADDED
@@ -0,0 +1,15 @@
1
+ * TECHDEBT BY COMPONENT *
2
+
3
+ * GENERAL
4
+ ** remove heredocs, replace by erb templates
5
+ ** move all general configuration to a ~/.relevance_rails.yml file (AWS stuff, keys git repo stuff)
6
+ ** cleaner rvm version detection - intermittenly picks up no version
7
+ ** intermittent mysql::server failures (mysql server not up yet) on `vagrant up`. Attempt fix in site_cookbooks
8
+ ** intermittent setup failure - apt-get update fails with 404s or ruby not found
9
+
10
+ * deployment generator
11
+ ** Don't hardcode path to chef binstub, caused by ubuntu installing weirdness
12
+ ** Make the deployment generator idempotent
13
+ ** Better error handling when the aws.yml is not present
14
+ ** On an uncaught exception, destroy the ec2 instances (?)
15
+ ** RelevanceRails::Provision.wait_for_ssh intermittently hangs
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relevance_rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 3
10
- version: 0.0.3
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Redington
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-26 00:00:00 Z
18
+ date: 2012-04-06 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails
@@ -25,13 +25,88 @@ dependencies:
25
25
  requirements:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
- hash: 5
28
+ hash: 3
29
29
  segments:
30
30
  - 3
31
- - 1
32
- version: "3.1"
31
+ - 2
32
+ version: "3.2"
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: fog
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 27
44
+ segments:
45
+ - 1
46
+ - 3
47
+ - 0
48
+ version: 1.3.0
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: pry
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :development
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: capybara
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ type: :development
78
+ version_requirements: *id004
79
+ - !ruby/object:Gem::Dependency
80
+ name: rspec
81
+ prerelease: false
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ type: :development
92
+ version_requirements: *id005
93
+ - !ruby/object:Gem::Dependency
94
+ name: rake
95
+ prerelease: false
96
+ requirement: &id006 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ hash: 11
102
+ segments:
103
+ - 0
104
+ - 9
105
+ - 2
106
+ - 2
107
+ version: 0.9.2.2
108
+ type: :development
109
+ version_requirements: *id006
35
110
  description: A Rails 3 wrapper which forces template use and includes a plethora of generators for standard Relevance bits.
36
111
  email:
37
112
  - alex.redington@thinkrelevance.com
@@ -43,22 +118,46 @@ extra_rdoc_files: []
43
118
 
44
119
  files:
45
120
  - .gitignore
121
+ - .rvmrc
122
+ - .travis.yml
123
+ - CHANGELOG.md
46
124
  - Gemfile
47
125
  - README.md
48
126
  - Rakefile
127
+ - aws_config.example.yml
49
128
  - bin/relevance_rails
129
+ - lib/generators/deployment/deployment_generator.rb
130
+ - lib/generators/fixtures/fixtures_generator.rb
131
+ - lib/generators/provision_config/provision_config_generator.rb
132
+ - lib/generators/provision_config/templates/authorized_keys.json.erb
50
133
  - lib/generators/relevance_file/relevance_file_generator.rb
51
134
  - lib/generators/relevance_file/templates/Capfile
52
- - lib/generators/relevance_file/templates/Gemfile
135
+ - lib/generators/relevance_file/templates/Gemfile.erb
136
+ - lib/generators/relevance_file/templates/README.markdown.erb
137
+ - lib/generators/relevance_file/templates/application.html.haml.erb
138
+ - lib/generators/relevance_file/templates/database.example.yml.mysql.erb
139
+ - lib/generators/relevance_file/templates/database.example.yml.postgresql.erb
140
+ - lib/generators/relevance_file/templates/deploy.rb.erb
53
141
  - lib/generators/relevance_file/templates/recipes_deploy.rb
54
142
  - lib/generators/relevance_file/templates/spec_helper.rb
55
143
  - lib/generators/relevance_file/templates/vagrant.rb
56
144
  - lib/relevance_rails.rb
145
+ - lib/relevance_rails/chef_dna.rb
146
+ - lib/relevance_rails/provision.rb
57
147
  - lib/relevance_rails/public_key_fetcher.rb
148
+ - lib/relevance_rails/railtie.rb
58
149
  - lib/relevance_rails/relevance_rails_template.rb
59
- - lib/relevance_rails/template_injector.rb
150
+ - lib/relevance_rails/runner.rb
60
151
  - lib/relevance_rails/version.rb
152
+ - lib/tasks/provision.rake
61
153
  - relevance_rails.gemspec
154
+ - script/ci
155
+ - spec/acceptance_spec.rb
156
+ - spec/lib/provision_config_generator_spec.rb
157
+ - spec/lib/relevance_rails_spec.rb
158
+ - spec/lib/runner_spec.rb
159
+ - spec/spec_helper.rb
160
+ - techdebt.md
62
161
  homepage: ""
63
162
  licenses: []
64
163
 
@@ -88,9 +187,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
187
  requirements: []
89
188
 
90
189
  rubyforge_project: relevance_rails
91
- rubygems_version: 1.8.15
190
+ rubygems_version: 1.8.21
92
191
  signing_key:
93
192
  specification_version: 3
94
193
  summary: Rails 3 Relevance style, with all infrastructure bits automated away.
95
- test_files: []
96
-
194
+ test_files:
195
+ - spec/acceptance_spec.rb
196
+ - spec/lib/provision_config_generator_spec.rb
197
+ - spec/lib/relevance_rails_spec.rb
198
+ - spec/lib/runner_spec.rb
199
+ - spec/spec_helper.rb
@@ -1,5 +0,0 @@
1
- template = File.join(File.dirname(__FILE__), "relevance_rails_template.rb")
2
- unless ARGV.any? =~ /^-d$/ then
3
- ARGV << '-m'
4
- ARGV << template
5
- end