Sha256: 751357b036ec0cc9eed0dadc2e5082d6edf89d65e4af12dce49b2ac54af1170b

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

Given(/^a database table called "([^"]*)" with the following fields:$/) do |table_name, fields|
  database_table(table_name).create(fields.data)
end


Given (/^only the following rows in the "([^"]*)" database table:$/) do |table_name, rows|
  database_table(table_name).clear
  step %Q(the following new rows in the "#{table_name}" database table:), rows
end


Given (/^the following new rows in the "([^"]*)" database table:$/) do |table_name, rows|
  database_table(table_name).insert rows.data
end


Given(/^the current value in sequence "([^"]*)" is (\d+)$/) do |sequence_name, current_value|
  Cranium::Database.connection.run "SELECT setval('#{sequence_name}', #{current_value})"
end


Given(/^a sequence called "([^"]*)" starting from (\d+)$/) do |sequence_name, start_value|
  database_sequence(sequence_name).create

  step %Q[the current value in sequence "#{sequence_name}" is #{start_value}]
end


Then(/^the "([^"]*)" table should contain:$/) do |table_name, data|
  expected_data, hashes = [], data.data
  hashes.map do |hash|
    new_row = {}
    hash.each_key do |key|
      new_row[key.to_sym] = hash[key]
    end
    expected_data << new_row
  end

  expect(database_table(table_name).content(data.fields)).to match_array expected_data
end


Then(/^the "([^"]*)" table should contain ([\d_]+) .+$/) do |table_name, count|
  expect(database_table(table_name).count).to eq count.to_i
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cranium-0.5 features/step_definitions/database_table_steps.rb
cranium-0.4.3 features/step_definitions/database_table_steps.rb
cranium-0.4.2 features/step_definitions/database_table_steps.rb
cranium-0.4.1 features/step_definitions/database_table_steps.rb
cranium-0.4 features/step_definitions/database_table_steps.rb
cranium-0.3.1 features/step_definitions/database_table_steps.rb
cranium-0.3.0 features/step_definitions/database_table_steps.rb