Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tests updated and bug report added to readme

  • Loading branch information...
commit 58de78785fe8aed966087616e050c1f97794afcd 1 parent 2104bd0
@jeroeningen authored
Showing with 22 additions and 14 deletions.
  1. +3 −0  README.rdoc
  2. +11 −8 spec/car_spec.rb
  3. +8 −6 spec/fueltype_spec.rb
View
3  README.rdoc
@@ -49,6 +49,9 @@ Now you may add the following code to your spec-files for your models:
=TESTING
To test the plugin use the command 'rake test' or 'rspec spec/*_spec.rb' inside the dir '~/vendor/plugins/acts_as_price'
+=KNOWN BUGS
+The acts_as_price plugin does not accept comma-seperated prices at the moment.
+
=NOTES
This plugin comes with Rspec tests.
However this plugin assumes that you have a database configuration, it actually don't use the database for the Rspec tests.
View
19 spec/car_spec.rb
@@ -24,7 +24,7 @@
end
end
- context "return the fueltype price" do
+ context "return the price" do
it "should return the price in cents" do
columns_in_cents.each do |column|
@acts_as_price_model.send(column).should == 2399599
@@ -37,16 +37,19 @@
end
end
- context "set the price per liter" do
- it "should set the price per liter in cents and return it correctly" do
- test_setter_in_cents "2209998"
- end
- it "should set the price per liter and return it correctly" do
- test_setter_in_doubles "25499.97"
+ context "set the price for hundred different prices" do
+ 2200000.upto(2200100) do |i|
+ it "should set the price in cents and return it correctly" do
+ test_setter_in_cents i.to_s
+ end
+ it "should set the price and return it correctly" do
+ test_setter_in_doubles sprintf("%.2f", i.to_f / 100)
+ end
end
+
end
- context "given a float as price per liter" do
+ context "given a float as price" do
it "should convert it to the right price in cents" do
test_setter_in_doubles "25500.5"
test_setter_in_doubles "21599.05"
View
14 spec/fueltype_spec.rb
@@ -37,12 +37,14 @@
end
end
- context "set the price per liter" do
- it "should set the price per liter in cents and return it correctly" do
- test_setter_in_cents "144"
- end
- it "should set the price per liter and return it correctly" do
- test_setter_in_doubles "1.41"
+ context "set the price per liter for hundred different prices" do
+ 1.upto(100).each do |i|
+ it "should set the price per liter in cents and return it correctly" do
+ test_setter_in_cents i.to_s
+ end
+ it "should set the price per liter and return it correctly" do
+ test_setter_in_doubles sprintf("%.2f", i.to_f / 100)
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.