small medium large xlarge

28 Feb 2012, 06:10
Xavier John (21 posts)

I am not able to get the unit test “test_product_is_not_valid_without_a_unique_title(ProductTest)” to pass

I copied the products.yml and product_test.rb from this site so it should be correct

Test db does have the correct fixtures.

C:\Sites\depot\db>sqlite3 test.sqlite3 “select * from products”; 207281424|Programming Ruby 1.9|Ruby is the fastest growing and most exciting dyn amic language out there. If you need to get working programs delivered fast, yo u should add Ruby to your toolbox.|ruby.png|49.5|2012-02-28 05:57:07|2012-02-28 05:57:07 298486374|MyString|MyText|MyString|9.99|2012-02-28 05:57:07|2012-02-28 05:57:07 980190962|MyString|MyText|MyString|9.99|2012-02-28 05:57:07|2012-02-28 05:57:07

But I get the following error

C:\Sites\depot>rake test:units Loaded suite C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rake- ib/rake/rake_test_loader Started ..FF. Finished in 0.109200 seconds.

1) Failure: test_product_is_not_valid_without_a_unique_title(ProductTest) [C:/Sites/depot/te st/unit/product_test.rb:66]: Failed assertion, no message given.

2) Failure: test_product_is_not_valid_without_a_unique_title_-_i18n(ProductTest) [C:/Sites/d epot/test/unit/product_test.rb:76]: Failed assertion, no message given.

5 tests, 21 assertions, 2 failures, 0 errors, 0 skips

Test run options: –seed 55034

Installed items C:\Sites\depot\db>bundle Using rake ( Using i18n (0.6.0) Using multi_json (1.1.0) Using activesupport (3.2.1) Using builder (3.0.0) Using activemodel (3.2.1) Using erubis (2.7.0) Using journey (1.0.3) Using rack (1.4.1) Using rack-cache (1.1) Using rack-test (0.6.1) Using hike (1.2.1) Using tilt (1.3.3) Using sprockets (2.1.2) Using actionpack (3.2.1) Using mime-types (1.17.2) Using polyglot (0.3.3) Using treetop (1.4.10) Using mail (2.4.1) Using actionmailer (3.2.1) Using arel (3.0.2) Using tzinfo (0.3.31) Using activerecord (3.2.1) Using activeresource (3.2.1) Using bundler (1.0.22) Using coffee-script-source (1.2.0) Using execjs (1.3.0) Using coffee-script (2.2.0) Using rack-ssl (1.3.2) Using json (1.6.5) Using rdoc (3.12) Using thor (0.14.6) Using railties (3.2.1) Using coffee-rails (3.2.2) Using jquery-rails (2.0.0) Using rails (3.2.1) Using sass (3.1.15) Using sass-rails (3.2.4) Using sqlite3 (1.3.5) Using uglifier (1.2.3) —————————- Microsoft Windows [Version 6.1.7601] (Win 7)

If only there was a way to step through the test to see what is going on.

28 Feb 2012, 10:38
Xavier John (21 posts)

doh… unique validation was missing! validates :title, uniqueness: true

Problem solved… The thread delete button does not work!.

02 Oct 2012, 10:20
Jed Cannon (1 post)

Leave this up. I wasted hours looking for the solution to the same problem.
As per my usual issue, I was reading through the book too fast and missed a line! Slow and steady :)

01 Feb 2013, 19:49
Krista Brashear (1 post)

so it should be

validates :title, :uniqueness => true

That fixed my problem!

You must be logged in to comment