Sha256: 981b48296df8251b39bcfe660d85a5703870685d70358efad33ca322c554c5c3

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'


describe "Taza::Fixtures" do

  Taza::Fixture.stubs(:base_path).returns('./spec/sandbox/fixtures/')
  Taza.load_fixtures
  include Taza::Fixtures

  it "should be able to look up a fixture entity off fixture_methods module" do
    expect(examples(:first_example).name).to eql 'first'
  end

  it "should still raise method missing error" do
    expect(lambda{zomgwtf(:first_example)}).to raise_error(NoMethodError)
  end

  #TODO: this test tests what is in entity's instance eval not happy with it being here
  it "should be able to look up a fixture entity off fixture_methods module" do
    expect(examples(:first_example).user.name).to eql users(:shatner).name
  end

  it "should be able to resolve one to many relationships" do
    expect(foos(:gap).examples.length).to eql 2
  end

  it "should be able to get one to many entities" do
    expect(foos(:gap).examples['first_example'].name).to eql 'first'
    expect(foos(:gap).examples['second_example'].name).to eql 'second'
  end

  it "should not be able to access fixtures in sub-folders if not included" do
    expect(lambda{bars(:foo)}).to raise_error(NoMethodError)
  end

  it "should template fixture files" do
    expect(users(:shatner).age).to eql 66
  end

  it "should be able to get one to many entities for hash[key] style" do
    expect(foos(:gap)['examples']['first_example']['name']).to eql 'first'
  end

  it "should be able to access multiple levels inside fixtures" do
    expect(examples(:forth_example).something.user.name).to eql 'William Shatner'
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
taza-3.0.0 spec/taza/fixtures_spec.rb
taza-2.1.0 spec/taza/fixtures_spec.rb
taza-2.0 spec/taza/fixtures_spec.rb
taza-1.0 spec/taza/fixtures_spec.rb