Skip to content

Commit

Permalink
models and validations for sound and sound pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenaweiss committed Mar 21, 2014
1 parent 3f68e8f commit 10b495a
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 25 deletions.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--color
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ group :test do
gem 'jasmine'

# acceptance testing
gem 'capybara-rails'
# gem 'capybara-rails'
# gem 'launchy'

# test helper libraries
Expand Down
24 changes: 0 additions & 24 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,6 @@ GEM
multi_json (~> 1.0)
multi_xml (~> 0.5)
builder (3.1.4)
capybara (2.2.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
capybara-console (0.0.4)
capybara
rails (>= 3.0)
capybara-rails (0.0.2)
capybara
capybara-console
database_cleaner
exception_notification
coderay (1.1.0)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
Expand All @@ -55,13 +41,9 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.7.0)
database_cleaner (1.2.0)
diff-lcs (1.2.5)
docile (1.1.3)
erubis (2.7.0)
exception_notification (4.0.1)
actionmailer (>= 3.0.4)
activesupport (>= 3.0.4)
execjs (2.0.2)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -90,12 +72,9 @@ GEM
treetop (~> 1.4.8)
method_source (0.8.2)
mime-types (1.25.1)
mini_portile (0.5.2)
minitest (4.7.5)
multi_json (1.9.0)
multi_xml (0.5.5)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
pg (0.17.1)
phantomjs (1.9.7.0)
polyglot (0.3.4)
Expand Down Expand Up @@ -175,15 +154,12 @@ GEM
uglifier (2.5.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
xpath (2.0.0)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
aws-sdk-core
capybara-rails
coffee-rails (~> 4.0.0)
factory_girl_rails
ffaker (~> 1.2.0)
Expand Down
4 changes: 4 additions & 0 deletions app/models/sound.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
class Sound < ActiveRecord::Base
validates_presence_of :name
validates_presence_of :url
has_many :sound_patterns

end
4 changes: 4 additions & 0 deletions app/models/sound_pattern.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class SoundPattern < ActiveRecord::Base
belongs_to :sound
validates_presence_of :pattern
end
10 changes: 10 additions & 0 deletions db/migrate/20140321145137_create_sound_patterns.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class CreateSoundPatterns < ActiveRecord::Migration
def change
create_table :sound_patterns do |t|
t.string :pattern
t.references :sound, index: true

t.timestamps
end
end
end
Empty file.
112 changes: 112 additions & 0 deletions spec/javascripts/support/jasmine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# src_files
#
# Return an array of filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# src_files:
# - lib/source1.js
# - lib/source2.js
# - dist/**/*.js
#
src_files:
- assets/application.js

# stylesheets
#
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
# Default: []
#
# EXAMPLE:
#
# stylesheets:
# - css/style.css
# - stylesheets/*.css
#
stylesheets:
- stylesheets/**/*.css

# helpers
#
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
# Default: ["helpers/**/*.js"]
#
# EXAMPLE:
#
# helpers:
# - helpers/**/*.js
#
helpers:
- 'helpers/**/*.js'

# spec_files
#
# Return an array of filepaths relative to spec_dir to include.
# Default: ["**/*[sS]pec.js"]
#
# EXAMPLE:
#
# spec_files:
# - **/*[sS]pec.js
#
spec_files:
- '**/*[sS]pec.js'

# src_dir
#
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
# Default: project root
#
# EXAMPLE:
#
# src_dir: public
#
src_dir:

# spec_dir
#
# Spec directory path. Your spec_files must be returned relative to this path.
# Default: spec/javascripts
#
# EXAMPLE:
#
# spec_dir: spec/javascripts
#
spec_dir:

# spec_helper
#
# Ruby file that Jasmine server will require before starting.
# Returned relative to your root path
# Default spec/javascripts/support/jasmine_helper.rb
#
# EXAMPLE:
#
# spec_helper: spec/javascripts/support/jasmine_helper.rb
#
spec_helper: spec/javascripts/support/jasmine_helper.rb

# boot_dir
#
# Boot directory path. Your boot_files must be returned relative to this path.
# Default: Built in boot file
#
# EXAMPLE:
#
# boot_dir: spec/javascripts/support/boot
#
boot_dir:

# boot_files
#
# Return an array of filepaths relative to boot_dir to include in order to boot Jasmine
# Default: Built in boot file
#
# EXAMPLE
#
# boot_files:
# - '**/*.js'
#
boot_files:

11 changes: 11 additions & 0 deletions spec/javascripts/support/jasmine_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#Use this file to set/override Jasmine configuration options
#You can remove it if you don't need it.
#This file is loaded *after* jasmine.yml is interpreted.
#
#Example: using a different boot file.
#Jasmine.configure do |config|
# config.boot_dir = '/absolute/path/to/boot_dir'
# config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
#end
#

6 changes: 6 additions & 0 deletions spec/models/sound_pattern_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require 'spec_helper'

describe SoundPattern do
it { should validate_presence_of :pattern }
it { should belong_to :sound }
end
7 changes: 7 additions & 0 deletions spec/models/sound_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'spec_helper'

describe Sound do
it { should validate_presence_of :name }
it { should validate_presence_of :url }
it { should have_many :sound_patterns }
end
45 changes: 45 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)

require 'simplecov'
require 'rspec/rails'
require 'rspec/autorun'
# require 'capybara/rails'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }

# Checks for pending migrations before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)

RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr

# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true

# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
end
9 changes: 9 additions & 0 deletions test/fixtures/sound_patterns.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
pattern: MyString
sound_id:

two:
pattern: MyString
sound_id:
7 changes: 7 additions & 0 deletions test/models/sound_pattern_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class SoundPatternTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit 10b495a

Please sign in to comment.