This repository has been archived by the owner on Jan 31, 2024. It is now read-only.
forked from learn-co-students/playlister-sinatra-v-000
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
deniznida
committed
Jun 25, 2015
1 parent
db0ed53
commit 196a21c
Showing
10 changed files
with
151 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ tags: | |
- activerecord | ||
languages: | ||
- ruby | ||
resources: 2 | ||
resources: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
# Add seed data here. Seed your database with `rake db:seed` | ||
# Add seed data here. Seed your database with `rake db:seed` | ||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'spec_helper' | ||
|
||
describe "Song" do | ||
let!(:artist) { Artist.create(:name => "Taylor Swift") } | ||
|
||
let!(:song) { Song.create(:name => "Blank Space", :artist => artist) } | ||
|
||
let!(:pop) { Genre.create(:name => "Pop") } | ||
let!(:funk) { Genre.create(:name => "Funk") } | ||
|
||
let!(:song_genres_pop) { SongGenre.create(:song_id => song.id, :genre_id => pop.id) } | ||
let!(:song_genres_funk) { SongGenre.create(:song_id => song.id, :genre_id => funk.id) } | ||
|
||
it "can initialize a song" do | ||
expect(Song.new).to be_an_instance_of(Song) | ||
end | ||
|
||
it "can have a name" do | ||
expect(song.name).to eq("Blank Space") | ||
end | ||
|
||
it "can have many genres" do | ||
expect(SongGenre.count).to eq(2) | ||
end | ||
|
||
it "has an artist" do | ||
expect(song.artist).to eq(artist) | ||
end | ||
|
||
it "can slugify it's name" do | ||
song.slug | ||
|
||
expect(song.slug).to eq("blank-space") | ||
end | ||
|
||
describe "Class methods" do | ||
it "given the slug can find a song" do | ||
Song.find_by_slug(song.slug) | ||
|
||
expect((Song.find_by_slug(song.slug)).name).to eq("Blank Space") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require 'spec_helper' | ||
|
||
describe "Genre" do | ||
let(:genre) { Genre.create(:name => "Pop") } | ||
|
||
let!(:taylor_swift) { Artist.create(:name => "Taylor Swift") } | ||
let!(:mark_ronson) { Artist.create(:name => "Mark Ronson") } | ||
|
||
let!(:blank_space) { Song.create(:name => "Blank Space", :artist => taylor_swift) } | ||
let!(:uptown_funk) { Song.create(:name => "Uptown Funk!", :artist => mark_ronson) } | ||
|
||
let!(:blank_pop) { SongGenre.create(:song_id => blank_space.id, :genre_id => genre.id) } | ||
let!(:uptown_pop) { SongGenre.create(:song_id => uptown_funk.id, :genre_id => genre.id) } | ||
|
||
|
||
it "can initialize a genre" do | ||
expect(Genre.new).to be_an_instance_of(Genre) | ||
end | ||
|
||
it "has a name" do | ||
expect(genre.name).to eq("Pop") | ||
end | ||
|
||
it "has many songs" do | ||
expect(genre.songs.count).to eq(2) | ||
end | ||
|
||
it "has many artists" do | ||
expect(genre.artists.count).to eq(2) | ||
end | ||
|
||
it "can slugify it's name" do | ||
genre = Genre.create(:name => "Alternative Rock") | ||
genre.slug | ||
|
||
expect(genre.slug).to eq("alternative-rock") | ||
end | ||
|
||
describe "Class methods" do | ||
it "given the slug can find a genre" do | ||
genre = Genre.create(:name => "Alternative Rock") | ||
Genre.find_by_slug(genre.slug) | ||
|
||
expect((Genre.find_by_slug(genre.slug)).name).to eq("Alternative Rock") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'spec_helper' | ||
|
||
describe "Artist" do | ||
let(:artist) { Artist.create(:name => "Taylor Swift") } | ||
|
||
let!(:blank_space) { Song.create(:name => "Blank Space", :artist => artist) } | ||
let!(:shake_it_off) { Song.create(:name => "Shake It Off", :artist => artist) } | ||
|
||
let!(:pop) { Genre.create(:name => "Pop") } | ||
let!(:funk) { Genre.create(:name => "Funk") } | ||
|
||
let!(:blank_pop) { SongGenre.create(:song_id => blank_space.id, :genre_id => pop.id) } | ||
let!(:blank_funk) { SongGenre.create(:song_id => blank_space.id, :genre_id => funk.id) } | ||
|
||
|
||
it "can be initialized" do | ||
expect(artist).to be_an_instance_of(Artist) | ||
end | ||
|
||
it "can have a name" do | ||
expect(artist.name).to eq("Taylor Swift") | ||
end | ||
|
||
it "has many songs" do | ||
expect(artist.songs.count).to eq(2) | ||
end | ||
|
||
it "can have many genres" do | ||
expect(artist.genres.count).to eq(2) | ||
end | ||
|
||
it "can slugify it's name" do | ||
artist.slug | ||
|
||
expect(artist.slug).to eq("taylor-swift") | ||
end | ||
|
||
describe "Class methods" do | ||
it "given the slug can find a Artist" do | ||
Artist.find_by_slug(artist.slug) | ||
|
||
expect((Artist.find_by_slug(artist.slug)).name).to eq("Taylor Swift") | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters