summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/customer_spec.rb68
-rw-r--r--spec/spec_helper.rb2
-rw-r--r--spec/unit/customer_spec.rb10
3 files changed, 69 insertions, 11 deletions
diff --git a/spec/integration/customer_spec.rb b/spec/integration/customer_spec.rb
new file mode 100644
index 0000000..4743085
--- /dev/null
+++ b/spec/integration/customer_spec.rb
@@ -0,0 +1,68 @@
+require "spec_helper"
+
+describe Customer do
+ let(:customer) { Customer.new('george') }
+
+ describe "#statement" do
+ context "when no activity has taken place" do
+ it "produces an empty statement" do
+ statement = customer.statement
+ statement.should == "Rental Record for george\nAmount owed is 0\nYou earned 0 frequent renter points"
+ end
+ end
+
+ context "when a regular movie is rented" do
+ let(:movie) { Movie.new('star wars', Movie::REGULAR) }
+
+ before { customer.add_rental(Rental.new(movie, days_rented)) }
+
+ context "for one day" do
+ let(:days_rented) { 1 }
+
+ it "produces the correct statement" do
+ customer.statement.should == "Rental Record for george\n\tstar wars\t2\nAmount owed is 2\nYou earned 1 frequent renter points"
+ end
+ end
+
+ context "for more than two days" do
+ let(:days_rented) { 3 }
+
+ it "produces the correct statement" do
+ customer.statement.should == "Rental Record for george\n\tstar wars\t3.5\nAmount owed is 3.5\nYou earned 1 frequent renter points"
+ end
+ end
+ end
+
+ context "when a new release is rented" do
+ let(:movie) { Movie.new('star wars', Movie::NEW_RELEASE) }
+
+ before { customer.add_rental(Rental.new(movie, 1)) }
+
+ it "produces the correct statement" do
+ customer.statement.should == "Rental Record for george\n\tstar wars\t3\nAmount owed is 3\nYou earned 1 frequent renter points"
+ end
+ end
+
+ context "when a childrens movie is rented" do
+ let(:movie) { Movie.new('star wars', Movie::NEW_RELEASE) }
+
+ before { customer.add_rental(Rental.new(movie, days_rented)) }
+
+ context "for one day" do
+ let(:days_rented) { 1 }
+
+ it "produces the correct statement" do
+ customer.statement.should == "Rental Record for george\n\tstar wars\t3\nAmount owed is 3\nYou earned 1 frequent renter points"
+ end
+ end
+
+ context "for more than 3 days" do
+ let(:days_rented) { 4 }
+
+ it "produces the correct statement" do
+ customer.statement.should == "Rental Record for george\n\tstar wars\t9\nAmount owed is 9\nYou earned 2 frequent renter points"
+ end
+ end
+ end
+ end
+end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 8c72aae..bc7d4ff 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -4,9 +4,9 @@
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
-require 'customer'
require 'movie'
require 'rental'
+require 'customer'
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
diff --git a/spec/unit/customer_spec.rb b/spec/unit/customer_spec.rb
deleted file mode 100644
index 703693e..0000000
--- a/spec/unit/customer_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-require "spec_helper"
-
-describe Customer do
- describe "#statement" do
- it "produces a statement" do
- customer = Customer.new('george')
- customer.statement.should_not be_nil
- end
- end
-end