summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2013-11-02 07:29:19 -0600
committermo khan <mo@mokhan.ca>2013-11-02 07:29:19 -0600
commit44069c0d56167fec1475119b812a453958243429 (patch)
tree35b992b7b49afe1d5543d9ee1a50ec3e5160f02d
parentaeafaf9cc84b458b70f73107eba01333e58e9527 (diff)
parent81963859b5f322b8f8baea44d15c665dc6013bd6 (diff)
Merge branch 'master' of github.com:mokhan/bootcamp
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock31
-rw-r--r--Guardfile6
-rw-r--r--spec/movie_library_spec.rb19
4 files changed, 54 insertions, 3 deletions
diff --git a/Gemfile b/Gemfile
index 110ec52..621c1aa 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,2 +1,3 @@
source "https://rubygems.org"
gem 'rspec'
+gem 'guard-rspec', require: false
diff --git a/Gemfile.lock b/Gemfile.lock
index b3bf052..cdcc303 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,7 +1,34 @@
GEM
remote: https://rubygems.org/
specs:
+ celluloid (0.15.2)
+ timers (~> 1.1.0)
+ coderay (1.0.9)
diff-lcs (1.2.4)
+ ffi (1.9.3)
+ formatador (0.2.4)
+ guard (2.2.2)
+ formatador (>= 0.2.4)
+ listen (~> 2.1)
+ lumberjack (~> 1.0)
+ pry (>= 0.9.12)
+ thor (>= 0.18.1)
+ guard-rspec (4.0.3)
+ guard (>= 2.1.1)
+ rspec (~> 2.14)
+ listen (2.2.0)
+ celluloid (>= 0.15.2)
+ rb-fsevent (>= 0.9.3)
+ rb-inotify (>= 0.9)
+ lumberjack (1.0.4)
+ method_source (0.8.2)
+ pry (0.9.12.2)
+ coderay (~> 1.0.5)
+ method_source (~> 0.8)
+ slop (~> 3.4)
+ rb-fsevent (0.9.3)
+ rb-inotify (0.9.2)
+ ffi (>= 0.5.0)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
@@ -10,9 +37,13 @@ GEM
rspec-expectations (2.14.2)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.3)
+ slop (3.4.6)
+ thor (0.18.1)
+ timers (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
+ guard-rspec
rspec
diff --git a/Guardfile b/Guardfile
new file mode 100644
index 0000000..455fe9f
--- /dev/null
+++ b/Guardfile
@@ -0,0 +1,6 @@
+guard :rspec do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+end
+
diff --git a/spec/movie_library_spec.rb b/spec/movie_library_spec.rb
index 8580f8a..5859216 100644
--- a/spec/movie_library_spec.rb
+++ b/spec/movie_library_spec.rb
@@ -13,7 +13,7 @@ describe MovieLibrary do
let(:fantasia) { create_movie(title: "Fantasia", studio: Studio::Disney, year_published: 1940) }
let(:dumbo) { create_movie(title: "Dumbo", studio: Studio::Disney, year_published: 1941) }
- let(:pinocchio) { create_movie(title: "Pinoccio", studio: Studio::Disney, year_published: 1940) }
+ let(:pinocchio) { create_movie(title: "Pinocchio", studio: Studio::Disney, year_published: 1940) }
let(:all_movies) { [shawshank_redemption, chasing_amy, man_on_fire, toy_story, up, cars, monsters_inc, fantasia, dumbo, pinocchio] }
@@ -87,8 +87,7 @@ describe MovieLibrary do
it 'Can find all movies released between 1982 and 2003 - Inclusive' do
results = library.find_all_movies_between_1982_and_2003
- results.length.should == 5
- results.should include(up)
+ results.length.should == 4
results.should include(shawshank_redemption)
results.should include(chasing_amy)
results.should include(toy_story)
@@ -97,6 +96,10 @@ describe MovieLibrary do
end
context 'Sorting movies' do
+ before :each do
+ all_movies.each { |x| library.add(x) }
+ end
+
it 'Sorts all movies by descending title' do
expected_order = [ cars, chasing_amy, dumbo, fantasia, man_on_fire, monsters_inc, pinocchio, shawshank_redemption, toy_story, up]
results = library.sort_movies_by_title_descending
@@ -110,12 +113,22 @@ describe MovieLibrary do
end
it 'Sorts all movies by descending release date' do
+ expected_order = [cars, up, man_on_fire, monsters_inc, chasing_amy, toy_story, shawshank_redemption, dumbo, fantasia, pinocchio ]
+ results = library.sort_movies_by_descending_release_date
+ results.should == expected_order
end
it 'Sorts all movies by ascending release date' do
+ expected_order = [pinocchio, fantasia, dumbo, shawshank_redemption, toy_story, chasing_amy, monsters_inc, man_on_fire, up, cars]
+ results = library.sort_movies_by_ascending_release_date
+ results.should == expected_order
end
it 'Sorts all movies by preferred studios and release date ascending' do
+ #rankings: Pixar, Disney, CastleRock, MiramaxFilms, RegenceyEnterprises
+ expected_order = [ toy_story, monsters_inc, up, cars, fantasia, pinocchio, dumbo, shawshank_redemption, chasing_amy, man_on_fire]
+ results = library.sort_movies_by_preferred_studios_and_release_date_ascending
+ results.should == expected_order
end
end