musicbrainz_ruby 0.0.5 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. data/.document +5 -0
  2. data/.gitignore +47 -15
  3. data/.idea/.name +1 -0
  4. data/.idea/.rakeTasks +7 -0
  5. data/.idea/codeStyleSettings.xml +13 -0
  6. data/.idea/dictionaries/j4k4x.xml +3 -0
  7. data/.idea/encodings.xml +5 -0
  8. data/.idea/inspectionProfiles/Project_Default.xml +11 -0
  9. data/.idea/inspectionProfiles/profiles_settings.xml +7 -0
  10. data/.idea/misc.xml +8 -0
  11. data/.idea/modules.xml +9 -0
  12. data/.idea/musicbrainz_ruby.iml +67 -0
  13. data/.idea/scopes/scope_settings.xml +5 -0
  14. data/.idea/vcs.xml +8 -0
  15. data/.idea/workspace.xml +675 -0
  16. data/.rspec +1 -0
  17. data/Gemfile +26 -6
  18. data/Gemfile.lock +173 -0
  19. data/{LICENSE → LICENSE.txt} +1 -3
  20. data/README.rdoc +19 -0
  21. data/Rakefile +58 -2
  22. data/VERSION +1 -0
  23. data/database.yml +20 -0
  24. data/features/musicbrainz_ruby.feature +16 -0
  25. data/features/releases/release_query.feature +19 -0
  26. data/features/step_definitions/MB/rails_steps.rb +121 -0
  27. data/features/step_definitions/MB/release_steps.rb/release_steps.rb +0 -0
  28. data/features/support/cukigem.rb +26 -0
  29. data/features/support/env.rb +19 -0
  30. data/lib/generators/music_brainz/install/initializer_generator.rb +5 -0
  31. data/lib/generators/music_brainz/install/install_generator.rb +14 -0
  32. data/lib/generators/music_brainz/install/templates/config/initializers/musicbrainz.rb.erb +47 -0
  33. data/lib/musicbrainz/artist.rb +59 -0
  34. data/lib/musicbrainz/base.rb +30 -3
  35. data/lib/musicbrainz/label.rb +4 -0
  36. data/lib/musicbrainz/query.rb +83 -0
  37. data/lib/musicbrainz/recording.rb +4 -0
  38. data/lib/musicbrainz/release.rb +77 -8
  39. data/lib/musicbrainz/release_group.rb +4 -0
  40. data/lib/musicbrainz/string.rb +47 -0
  41. data/lib/musicbrainz/work.rb +4 -0
  42. data/lib/musicbrainz_ruby.rb +19 -0
  43. data/log/test.log +0 -0
  44. data/musicbrainz_ruby.gemspec +194 -0
  45. data/report.html +478 -0
  46. data/spec/factories.rb +9 -0
  47. data/spec/musicbrainz_ruby_spec.rb +7 -0
  48. data/spec/spec_helper.rb +12 -0
  49. data/tmp/rails_app/.gitignore +15 -0
  50. data/tmp/rails_app/Gemfile +21 -0
  51. data/tmp/rails_app/Gemfile.lock +183 -0
  52. data/tmp/rails_app/README.rdoc +261 -0
  53. data/tmp/rails_app/Rakefile +7 -0
  54. data/tmp/rails_app/app/assets/images/rails.png +0 -0
  55. data/tmp/rails_app/app/assets/javascripts/application.js +15 -0
  56. data/tmp/rails_app/app/assets/javascripts/mmbrains.js.coffee +3 -0
  57. data/tmp/rails_app/app/assets/stylesheets/application.css +13 -0
  58. data/tmp/rails_app/app/assets/stylesheets/mmbrains.css.scss +3 -0
  59. data/tmp/rails_app/app/assets/stylesheets/scaffolds.css.scss +56 -0
  60. data/tmp/rails_app/app/controllers/application_controller.rb +2 -0
  61. data/tmp/rails_app/app/controllers/mmbrains_controller.rb +7 -0
  62. data/tmp/rails_app/app/controllers/models_controller.rb +10 -0
  63. data/tmp/rails_app/app/helpers/application_helper.rb +2 -0
  64. data/tmp/rails_app/app/helpers/mmbrains_helper.rb +2 -0
  65. data/tmp/rails_app/app/mailers/.gitkeep +0 -0
  66. data/tmp/rails_app/app/models/.gitkeep +0 -0
  67. data/tmp/rails_app/app/models/mmbrain.rb +3 -0
  68. data/tmp/rails_app/app/views/layouts/application.html.erb +14 -0
  69. data/tmp/rails_app/app/views/mmbrains/_form.html.erb +21 -0
  70. data/tmp/rails_app/app/views/mmbrains/edit.html.erb +6 -0
  71. data/tmp/rails_app/app/views/mmbrains/index.html.erb +1 -0
  72. data/tmp/rails_app/app/views/mmbrains/new.html.erb +5 -0
  73. data/tmp/rails_app/app/views/mmbrains/show.html.erb +10 -0
  74. data/tmp/rails_app/app/views/models/show.html.erb +1 -0
  75. data/tmp/rails_app/config.ru +4 -0
  76. data/tmp/rails_app/config/application.rb +62 -0
  77. data/tmp/rails_app/config/boot.rb +6 -0
  78. data/tmp/rails_app/config/database.yml +28 -0
  79. data/tmp/rails_app/config/environment.rb +5 -0
  80. data/tmp/rails_app/config/environments/development.rb +37 -0
  81. data/tmp/rails_app/config/environments/production.rb +67 -0
  82. data/tmp/rails_app/config/environments/test.rb +37 -0
  83. data/tmp/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  84. data/tmp/rails_app/config/initializers/inflections.rb +15 -0
  85. data/tmp/rails_app/config/initializers/mime_types.rb +5 -0
  86. data/tmp/rails_app/config/initializers/secret_token.rb +7 -0
  87. data/tmp/rails_app/config/initializers/session_store.rb +8 -0
  88. data/tmp/rails_app/config/initializers/wrap_parameters.rb +14 -0
  89. data/tmp/rails_app/config/locales/en.yml +5 -0
  90. data/tmp/rails_app/config/routes.rb +3 -0
  91. data/tmp/rails_app/db/migrate/20120630070553_create_mmbrains.rb +9 -0
  92. data/tmp/rails_app/db/seeds.rb +7 -0
  93. data/tmp/rails_app/lib/assets/.gitkeep +0 -0
  94. data/tmp/rails_app/lib/tasks/.gitkeep +0 -0
  95. data/tmp/rails_app/log/.gitkeep +0 -0
  96. data/tmp/rails_app/public/404.html +26 -0
  97. data/tmp/rails_app/public/422.html +26 -0
  98. data/tmp/rails_app/public/500.html +25 -0
  99. data/tmp/rails_app/public/favicon.ico +0 -0
  100. data/tmp/rails_app/public/index.html +241 -0
  101. data/tmp/rails_app/public/robots.txt +5 -0
  102. data/tmp/rails_app/script/rails +6 -0
  103. data/tmp/rails_app/test/fixtures/.gitkeep +0 -0
  104. data/tmp/rails_app/test/fixtures/mmbrains.yml +7 -0
  105. data/tmp/rails_app/test/functional/.gitkeep +0 -0
  106. data/tmp/rails_app/test/functional/mmbrains_controller_test.rb +49 -0
  107. data/tmp/rails_app/test/integration/.gitkeep +0 -0
  108. data/tmp/rails_app/test/performance/browsing_test.rb +12 -0
  109. data/tmp/rails_app/test/test_helper.rb +13 -0
  110. data/tmp/rails_app/test/unit/.gitkeep +0 -0
  111. data/tmp/rails_app/test/unit/helpers/mmbrains_helper_test.rb +4 -0
  112. data/tmp/rails_app/test/unit/mmbrain_test.rb +7 -0
  113. data/tmp/rails_app/vendor/assets/javascripts/.gitkeep +0 -0
  114. data/tmp/rails_app/vendor/assets/stylesheets/.gitkeep +0 -0
  115. data/tmp/rails_app/vendor/plugins/.gitkeep +0 -0
  116. metadata +350 -11
  117. data/README.md +0 -29
  118. data/lib/music_brainz.rb +0 -17
  119. data/lib/musicbrainz/version.rb +0 -3
  120. data/musicbrainz.gemspec +0 -21
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile CHANGED
@@ -1,7 +1,27 @@
1
- source 'https://rubygems.org'
2
- gem "net/http"
3
- gem "uri"
4
- gem 'json'
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
5
 
6
- # Specify your gem's dependencies in musicbrainz.gemspec
7
- gemspec
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ gem 'rails','3.2.6'
9
+ group :development do
10
+ gem "rspec"
11
+ gem "rdoc"
12
+ gem 'sprockets'
13
+ gem 'cucumber',:require => false
14
+ gem 'factory_girl'
15
+
16
+
17
+ gem "nokogiri",'>= 1.5.0'
18
+ gem "webrat"
19
+ gem "capybara"
20
+
21
+ gem "jeweler", "~> 1.8.4"
22
+ gem "simplecov"
23
+ gem "pickle"
24
+ gem "ruby-debug19", :require=>"ruby-debug"
25
+ gem "spork-rails"
26
+
27
+ end
@@ -0,0 +1,173 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.2.6)
5
+ actionpack (= 3.2.6)
6
+ mail (~> 2.4.4)
7
+ actionpack (3.2.6)
8
+ activemodel (= 3.2.6)
9
+ activesupport (= 3.2.6)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ journey (~> 1.0.1)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.2)
15
+ rack-test (~> 0.6.1)
16
+ sprockets (~> 2.1.3)
17
+ activemodel (3.2.6)
18
+ activesupport (= 3.2.6)
19
+ builder (~> 3.0.0)
20
+ activerecord (3.2.6)
21
+ activemodel (= 3.2.6)
22
+ activesupport (= 3.2.6)
23
+ arel (~> 3.0.2)
24
+ tzinfo (~> 0.3.29)
25
+ activeresource (3.2.6)
26
+ activemodel (= 3.2.6)
27
+ activesupport (= 3.2.6)
28
+ activesupport (3.2.6)
29
+ i18n (~> 0.6)
30
+ multi_json (~> 1.0)
31
+ addressable (2.2.8)
32
+ archive-tar-minitar (0.5.2)
33
+ arel (3.0.2)
34
+ builder (3.0.0)
35
+ capybara (1.1.2)
36
+ mime-types (>= 1.16)
37
+ nokogiri (>= 1.3.3)
38
+ rack (>= 1.0.0)
39
+ rack-test (>= 0.5.4)
40
+ selenium-webdriver (~> 2.0)
41
+ xpath (~> 0.1.4)
42
+ childprocess (0.3.3)
43
+ ffi (~> 1.0.6)
44
+ columnize (0.3.6)
45
+ cucumber (1.2.1)
46
+ builder (>= 2.1.2)
47
+ diff-lcs (>= 1.1.3)
48
+ gherkin (~> 2.11.0)
49
+ json (>= 1.4.6)
50
+ diff-lcs (1.1.3)
51
+ erubis (2.7.0)
52
+ factory_girl (3.5.0)
53
+ activesupport (>= 3.0.0)
54
+ ffi (1.0.11)
55
+ gherkin (2.11.1)
56
+ json (>= 1.4.6)
57
+ git (1.2.5)
58
+ hike (1.2.1)
59
+ i18n (0.6.0)
60
+ jeweler (1.8.4)
61
+ bundler (~> 1.0)
62
+ git (>= 1.2.5)
63
+ rake
64
+ rdoc
65
+ journey (1.0.4)
66
+ json (1.7.3)
67
+ libwebsocket (0.1.3)
68
+ addressable
69
+ linecache19 (0.5.12)
70
+ ruby_core_source (>= 0.1.4)
71
+ mail (2.4.4)
72
+ i18n (>= 0.4.0)
73
+ mime-types (~> 1.16)
74
+ treetop (~> 1.4.8)
75
+ mime-types (1.19)
76
+ multi_json (1.3.6)
77
+ nokogiri (1.5.5)
78
+ pickle (0.4.10)
79
+ cucumber (>= 0.8)
80
+ rake
81
+ polyglot (0.3.3)
82
+ rack (1.4.1)
83
+ rack-cache (1.2)
84
+ rack (>= 0.4)
85
+ rack-ssl (1.3.2)
86
+ rack
87
+ rack-test (0.6.1)
88
+ rack (>= 1.0)
89
+ rails (3.2.6)
90
+ actionmailer (= 3.2.6)
91
+ actionpack (= 3.2.6)
92
+ activerecord (= 3.2.6)
93
+ activeresource (= 3.2.6)
94
+ activesupport (= 3.2.6)
95
+ bundler (~> 1.0)
96
+ railties (= 3.2.6)
97
+ railties (3.2.6)
98
+ actionpack (= 3.2.6)
99
+ activesupport (= 3.2.6)
100
+ rack-ssl (~> 1.3.2)
101
+ rake (>= 0.8.7)
102
+ rdoc (~> 3.4)
103
+ thor (>= 0.14.6, < 2.0)
104
+ rake (0.9.2.2)
105
+ rdoc (3.12)
106
+ json (~> 1.4)
107
+ rspec (2.10.0)
108
+ rspec-core (~> 2.10.0)
109
+ rspec-expectations (~> 2.10.0)
110
+ rspec-mocks (~> 2.10.0)
111
+ rspec-core (2.10.1)
112
+ rspec-expectations (2.10.0)
113
+ diff-lcs (~> 1.1.3)
114
+ rspec-mocks (2.10.1)
115
+ ruby-debug-base19 (0.11.25)
116
+ columnize (>= 0.3.1)
117
+ linecache19 (>= 0.5.11)
118
+ ruby_core_source (>= 0.1.4)
119
+ ruby-debug19 (0.11.6)
120
+ columnize (>= 0.3.1)
121
+ linecache19 (>= 0.5.11)
122
+ ruby-debug-base19 (>= 0.11.19)
123
+ ruby_core_source (0.1.5)
124
+ archive-tar-minitar (>= 0.5.2)
125
+ rubyzip (0.9.9)
126
+ selenium-webdriver (2.24.0)
127
+ childprocess (>= 0.2.5)
128
+ libwebsocket (~> 0.1.3)
129
+ multi_json (~> 1.0)
130
+ rubyzip
131
+ simplecov (0.6.4)
132
+ multi_json (~> 1.0)
133
+ simplecov-html (~> 0.5.3)
134
+ simplecov-html (0.5.3)
135
+ spork (1.0.0rc3)
136
+ spork-rails (3.2.0)
137
+ rails (>= 3.0.0, < 3.3.0)
138
+ spork (>= 1.0rc0)
139
+ sprockets (2.1.3)
140
+ hike (~> 1.2)
141
+ rack (~> 1.0)
142
+ tilt (~> 1.1, != 1.3.0)
143
+ thor (0.15.4)
144
+ tilt (1.3.3)
145
+ treetop (1.4.10)
146
+ polyglot
147
+ polyglot (>= 0.3.1)
148
+ tzinfo (0.3.33)
149
+ webrat (0.7.3)
150
+ nokogiri (>= 1.2.0)
151
+ rack (>= 1.0)
152
+ rack-test (>= 0.5.3)
153
+ xpath (0.1.4)
154
+ nokogiri (~> 1.3)
155
+
156
+ PLATFORMS
157
+ ruby
158
+
159
+ DEPENDENCIES
160
+ capybara
161
+ cucumber
162
+ factory_girl
163
+ jeweler (~> 1.8.4)
164
+ nokogiri (>= 1.5.0)
165
+ pickle
166
+ rails (= 3.2.6)
167
+ rdoc
168
+ rspec
169
+ ruby-debug19
170
+ simplecov
171
+ spork-rails
172
+ sprockets
173
+ webrat
@@ -1,7 +1,5 @@
1
1
  Copyright (c) 2012 Jack
2
2
 
3
- MIT License
4
-
5
3
  Permission is hereby granted, free of charge, to any person obtaining
6
4
  a copy of this software and associated documentation files (the
7
5
  "Software"), to deal in the Software without restriction, including
@@ -19,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
17
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = musicbrainz_ruby
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to musicbrainz_ruby
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Jack. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile CHANGED
@@ -1,2 +1,58 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "musicbrainz_ruby"
18
+ gem.homepage = "http://ror.caged-media.com"
19
+ gem.license = "MIT"
20
+ gem.summary = "Make Musicbrainz API calls within RoR"
21
+ gem.description = "Musicbrainz.org API Ruby Implementation"
22
+ gem.email = ["jack@caged-media.com"]
23
+ gem.authors = ["Jack"]
24
+ gem.files.exclude 'tmp'
25
+ gem.files = `git ls-files`.split($\)
26
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
27
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
28
+
29
+ gem.require_paths = ["lib"]
30
+ # dependencies defined in Gemfile
31
+ end
32
+ Jeweler::RubygemsDotOrgTasks.new
33
+
34
+ require 'rspec/core'
35
+ require 'rspec/core/rake_task'
36
+ RSpec::Core::RakeTask.new(:spec) do |spec|
37
+ spec.pattern = FileList['spec/**/*_spec.rb']
38
+ end
39
+
40
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
41
+ spec.pattern = 'spec/**/*_spec.rb'
42
+ spec.rcov = true
43
+ end
44
+
45
+ require 'cucumber/rake/task'
46
+ Cucumber::Rake::Task.new(:features)
47
+
48
+ task :default => :spec
49
+
50
+ require 'rdoc/task'
51
+ Rake::RDocTask.new do |rdoc|
52
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
53
+
54
+ rdoc.rdoc_dir = 'rdoc'
55
+ rdoc.title = "musicbrainz_ruby #{version}"
56
+ rdoc.rdoc_files.include('README*')
57
+ rdoc.rdoc_files.include('lib/**/*.rb')
58
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.3
@@ -0,0 +1,20 @@
1
+ The default file should look something like this:
2
+ # SQLite version 3.x
3
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
4
+ development:
5
+ adapter: sqlite3
6
+ database: db/development.sqlite3
7
+ timeout: 5000
8
+
9
+ # Warning: The database defined as 'test' will be erased and
10
+ # re-generated from your development database when you run 'rake'.
11
+ # Do not set this db to the same as development or production.
12
+ test:
13
+ adapter: sqlite3
14
+ database: db/test.sqlite3
15
+ timeout: 5000
16
+
17
+ production:
18
+ adapter: sqlite3
19
+ database: db/production.sqlite3
20
+ timeout: 5000
@@ -0,0 +1,16 @@
1
+ @MB @setup
2
+ Feature: Installing MusicBrainz
3
+ In order to install musicbrainz_ruby
4
+ A user who generates the :install
5
+ Files must be copied.
6
+
7
+ Scenario: Installing Static Files
8
+ Given I have a rails application
9
+ And I run "rails generate music_brainz:install"
10
+ Then the file "config/initializers/musicbrainz.rb" should exist
11
+
12
+
13
+ Scenario:
14
+ Given I have a rails application
15
+ And I run "rails g scaffold release title:string release_date:date mbid:string type:string"
16
+ And I setup the database
@@ -0,0 +1,19 @@
1
+ @MB @release @query
2
+ Feature: Search for information on a release, using only an mbid.
3
+
4
+
5
+ Scenario:
6
+ Given there are 0 models
7
+ And I save the following as "app/controllers/releases_controller.rb":
8
+ """
9
+ ReleasesController<ApplicationController
10
+ def index
11
+ @releases=Releases.all
12
+ end
13
+ """
14
+ When I search for a nonexistant release with mbid of "64814a3d-f11a-3ad7-9f23-41c68279e0be"
15
+ Given The query does not match a release
16
+ Then A new release should be created
17
+ And I should have 1 release
18
+
19
+
@@ -0,0 +1,121 @@
1
+ Given /^I have a rails application$/ do
2
+
3
+ step %{I ensure a rails application is generated}
4
+ step %{the Gemfile is configured for testing}
5
+ step %{the Gemfile contains this gem}
6
+ step %{I run "bundle install"}
7
+ end
8
+ Given %r{^I ensure a rails application is generated$} do
9
+ if File.exists?(Cukigem.app_root)
10
+ step "I reset the rails application"
11
+ else
12
+ step "I generate a rails application"
13
+ end
14
+ end
15
+ Given %r{^I reset the rails application$} do
16
+ if File.exists?(Cukigem.app_root)
17
+ Dir.chdir(Cukigem.app_root) do
18
+ Cukigem.paths_to_clear.map {|f| Dir[f] }.flatten.each do |dir|
19
+ FileUtils.rm_rf(dir) if File.exists?(dir)
20
+ end
21
+
22
+ step "I reset the routes file"
23
+ step "I define an application controller"
24
+ step "I reset the Gemfile"
25
+ end
26
+ end
27
+ end
28
+ Given %r{^I generate a rails application$} do
29
+
30
+ Dir.chdir(Cukigem.temp_root) do
31
+ `rails new "#{Cukigem.application_name}"`
32
+ end
33
+
34
+ step "I turn off class caching in the rails application"
35
+ end
36
+ Given %r{^I turn off class caching in the rails application} do
37
+ Dir.chdir(Cukigem.app_root) do
38
+ File.open("config/environments/test.rb", "r+") do |f|
39
+ f.write f.read.gsub!(/config.cache_classes.*$/, "config.cache_classes = false")
40
+ end
41
+ end
42
+ end
43
+
44
+ Given %r{^I reset the routes file$} do
45
+ step %{I save the following as "config/routes.rb"}, %{RailsApp::Application.routes.draw do\n resources :models\nend}
46
+ end
47
+
48
+ When %r{^I save the following as "([^"]*)"} do |path, string|
49
+ FileUtils.mkdir_p(File.join(Cukigem.app_root, File.dirname(path)))
50
+ File.open(File.join(Cukigem.app_root, path), "w") do |file|
51
+ file.write(string)
52
+ end
53
+ end
54
+
55
+
56
+ Given %r{^I define an application controller$} do
57
+ step %{I save the following as "app/controllers/application_controller.rb"}, %{class ApplicationController < ActionController::Base\nend}
58
+ end
59
+
60
+ Given %r{^I reset the Gemfile$} do
61
+ step %{I save the following as "Gemfile"}, %{
62
+ source 'https://rubygems.org'
63
+ gem 'rails', '3.2.6'
64
+ gem 'sqlite3'
65
+ group :assets do
66
+ gem 'sass-rails', '~> 3.2.3'
67
+ gem 'coffee-rails', '~> 3.2.1'
68
+ gem 'therubyracer', :platforms => :ruby
69
+ gem 'uglifier', '>= 1.0.3'
70
+ end
71
+ gem 'jquery-rails'
72
+ }
73
+ end
74
+ When %r{^the Gemfile is configured for testing$} do
75
+ step %{I append the following to "Gemfile"}, %{
76
+ group :test do
77
+ gem "guard-rspec"
78
+ gem "factory_girl_rails", ">= 1.6.0"
79
+ gem "cucumber-rails", ">= 1.2.1"
80
+ gem "capybara", ">= 1.1.2"
81
+ gem "database_cleaner"
82
+ gem "launchy"
83
+ end
84
+ }
85
+ end
86
+ When %r{^I append the following to "([^"]*)"} do |path, string|
87
+ FileUtils.mkdir_p(File.join(Cukigem.app_root, File.dirname(path)))
88
+ File.open(File.join(Cukigem.app_root, path), "a+") do |file|
89
+ file.write(string)
90
+ end
91
+ end
92
+ When %r{^the Gemfile contains this gem$} do
93
+ step %{I append the following to "Gemfile"}, %{gem "musicbrainz_ruby","0.1.2",:path=>'/home/j4k4x/musicbrainz_ruby/pkg'}
94
+ end
95
+ When %r{^I run "([^"]*)"$} do |command|
96
+ Dir.chdir(Cukigem.app_root) do
97
+ `#{command}`
98
+ end
99
+ end
100
+
101
+ Then %r{^the file "([^"]*)" should exist$} do |file|
102
+ File.should be_exist(File.join(Cukigem.app_root, file))
103
+ end
104
+ When %r{^I setup the database$} do
105
+ step %{I run "rake db:create db:migrate --trace RAILS_ENV=test"}
106
+ end
107
+ When %r{^I start the rails application$} do
108
+ Dir.chdir(Cukigem.project_root)
109
+ Dir.chdir(Cukigem.app_root) do
110
+ ENV["RAILS_ENV"] = "test"
111
+ require "config/environment.rb"
112
+
113
+ if Object.const_defined?(:Capybara)
114
+ require "capybara/rails"
115
+ elsif Object.const_defined?(:Webrat)
116
+ require "webrat/rails"
117
+ end
118
+
119
+ ActiveRecord::Base.clear_all_connections!
120
+ end
121
+ end