Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

described load error silencing, but fixture scenario isn't quite righ…

…t yet
  • Loading branch information...
commit dbd3c2d0e4365ec13616080c0314a3e46d45c80b 1 parent 6d4c556
Nicholas Rutherford nruth authored committed
Showing with 97 additions and 4 deletions.
  1. +97 −4 features/load/raise_load_errors.feature
101 features/load/raise_load_errors.feature
View
@@ -1,6 +1,99 @@
Feature: Raise load errors
RAISE_ERROR=false|0 silence runtime errors (default true)
-
- Scenario: silencing runtime errors to prevent the rake task returning an error code
-
-
+
+ Background:
+ Given I am in an empty app
+ Given a Rakefile exists which has an environment task and loads git_friendly_dumper tasks
+ And an empty database
+
+
+
+ Scenario Outline: if a schema isn't found it always blows up, ignoring RAISE_ERROR
+ When I run "rake db:load FORCE=1 TABLES=doesnotexist RAISE_ERROR=<RAISE_ERROR>"
+ Then the exit status should be <EXIT_STATUS>
+ And the output should contain "No such file or directory"
+
+ Scenarios: always raises
+ | RAISE_ERROR | EXIT_STATUS |
+ | | 1 |
+ | false | 1 |
+ | 0 | 1 |
+ | true | 1 |
+ | 1 | 1 |
+
+
+
+ Scenario Outline: using RAISE_ERROR to toggle raising ActiveRecord insertion errors
+ Given a file named "db/dump/users/schema.rb" with:
+ """
+ create_table "users", :force => true do |t|
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ # t.string "name"
+ t.string "surname"
+ end
+ """
+ And a file named "db/dump/users/0000/0001.yml" with:
+ """
+ ---
+ name: Jane
+ created_at: 2003-07-26 12:38:10
+ updated_at: 2007-07-26 12:48:10
+ id: 1
+ surname: Heidie
+ """
+
+ When I run "rake db:load FORCE=1 TABLES=users RAISE_ERROR=<RAISE_ERROR>"
+ Then the exit status should be <EXIT_STATUS>
+ And the output <SEE_MESSAGE> contain "SQLite3::SQLException: table users has no column named name:"
+
+ Scenarios: don't raise
+ | RAISE_ERROR | EXIT_STATUS | SEE_MESSAGE |
+ | false | 0 | should not |
+ | 0 | 0 | should not |
+
+ Scenarios: raise
+ | RAISE_ERROR | EXIT_STATUS | SEE_MESSAGE |
+ | | 1 | should |
+ | true | 1 | should |
+ | 1 | 1 | should |
+
+
+ @wip @announce
+ Scenario Outline: can also silence errors loading a fixture
+ Given a file named "db/dump/users/schema.rb" with:
+ """
+ create_table "users", :force => true do |t|
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.string "name"
+ t.string "surname"
+ end
+ """
+ And I successfully run "rake db:load FORCE=1"
+
+ When I write to "db/dump/users/0000/0001.yml" with:
+ """
+ ---
+ forename: Jane
+ created_at: 2003-07-26 12:38:10
+ updated_at: 2007-07-26 12:48:10
+ id: 1
+ surname: Heidie
+ """
+ And I run "rake db:data:load FORCE=1 FIXTURES='users/0000/0001.yml' RAISE_ERROR=<RAISE_ERROR>"
+ Then the exit status should be <EXIT_STATUS>
+ And the output <SEE_MESSAGE> contain "SQLite3::SQLException: table users has no column named forename:"
+
+ Scenarios: don't raise
+ | RAISE_ERROR | EXIT_STATUS | SEE_MESSAGE |
+ | false | 0 | should not |
+ | 0 | 0 | should not |
+
+ Scenarios: raise
+ | RAISE_ERROR | EXIT_STATUS | SEE_MESSAGE |
+ | | 1 | should |
+ | true | 1 | should |
+ | 1 | 1 | should |
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.