Sha256: ef4bc0ea1e50bde67a6e70308c95844a7bcf46804201b2def85517271fc603f4

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 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, :json
    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, :xml
    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
#
  def stub_save_for_model(model)
    stub.instance_of(model)._refresh(anything) {}
    stub.instance_of(model)._update(anything) {}
    stub.instance_of(model)._insert {}
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fossil-0.5.18 spec/helper_methods.rb
fossil-0.5.17 spec/helper_methods.rb
fossil-0.5.16 spec/helper_methods.rb
fossil-0.5.15 spec/helper_methods.rb