Sha256: 3df838eb1bc76867adfb9d6331c1e29a4019edf4f467143abf96f87671aab1e3

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

module HelperMethods

  def set_fos_db(models)
    set_db(models,DB_FOS)
  end

  def set_demo_db(models)
    set_db(models,DB_DEMO)
  end

  def set_db(models,db)
    models.each{ |model| model.db=db }
  end

  # delete other rows, and create new one
  def add_test_table_data(hash)
    DB_DEMO[:test_table].delete
    DB_DEMO[:test_table] << hash
  end

  def get_fos_fixture(file_name)
    YAML.load_file(File.join(RAILS_ROOT,'spec','fos_fixtures',"#{file_name}.yml"))
  end

  def get_ipc_fixture(file_name)
    YAML.load_file(File.join(RAILS_ROOT,'spec','ipc_fixtures',"#{file_name}.yml"))
  end

  # controller helpers
  def should_render_json_for(obj,path)
    mock(obj).to_fos_json(is_a(Hash)) {"json"}
    call_controller path
    response.body.should == "json"
  end

  def should_render_xml_for(obj,path)
    request.env["HTTP_ACCEPT"] = "application/xml"
    mock(obj).to_fos_xml(is_a(Hash)) {"xml"}
    call_controller path
    response.body.should == "xml"
  end

  def equal_xml(other)
    simple_matcher("xml #{other} not equal") do |actual|
      actual.gsub(/\s/,'').should == other.gsub(/\s/,'')
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fossil-0.2.8 spec/helper_methods.rb
fossil-0.2.7 spec/helper_methods.rb
fossil-0.2.6 spec/helper_methods.rb
fossil-0.2.5 spec/helper_methods.rb
fossil-0.2.4 spec/helper_methods.rb
fossil-0.2.3 spec/helper_methods.rb
fossil-0.2.2 spec/helper_methods.rb