Sha256: 8e595ac2650e1d4b5b30add2d22024a663b4525579972d686d0ab0f110ea1b28

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

Given /^I delete all migrations$/ do
  steps %{
    When I successfully run `bash -c 'rm db/migrate/*.rb'`
  }
end

Given /^I update my new user model to be tablefree$/ do
  in_current_dir do
    file_name = 'app/models/user.rb'
    content = File.read(file_name)
    if framework_version < "3.0"
      content = "require 'activerecord-tablefree'\n" + content
    end

    content.gsub!(/^(class .* < ActiveRecord::Base)$/, "\\1\n" + <<-TABLELESS)
  has_no_table
  column :id, :integer
  column :name, :string

TABLELESS
    File.open(file_name, 'w') { |f| f << content }
  end
end

Given /^I update my users controller to render instead of redirect$/ do
  in_current_dir do
    transform_file('app/controllers/users_controller.rb') do |content|
      ##Changes in #create method
      content.gsub!(/@user = User.new\((.*?)\)/,
                    '@user = User.new(\1); @user.id = 1')
      content.gsub!("if @user.save",
                    "if @user.valid?")
      content.gsub!(/redirect_to([\( ])@user, .*?([\)]| \}|$)/,
                    "render\\1:action => 'show'\\2")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-tablefree-3.0.1 features/step_definitions/tablefree.rb
activerecord-tablefree-3.0.0 features/step_definitions/tablefree.rb