File: simple_fixtures.rb

package info (click to toggle)
ruby-acts-as-api 1.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 624 kB
  • sloc: ruby: 2,366; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 1,342 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module SimpleFixtures
  def setup_models
    @luke = User.create(first_name: 'Luke',     last_name: 'Skywalker', age: 25, active: true)
    @han  = User.create(first_name: 'Han',      last_name: 'Solo',      age: 35, active: true)
    @leia = User.create(first_name: 'Princess', last_name: 'Leia',      age: 25, active: false)

    @luke.profile = Profile.new(avatar: 'picard.jpg', homepage: 'lukasarts.com')
    @luke.profile.save!

    @destroy_deathstar = @luke.tasks.create(heading: 'Destroy Deathstar', description: 'XWing, Shoot, BlowUp', time_spent: 30,  done: true)
    @study_with_yoda   = @luke.tasks.create(heading: 'Study with Yoda',   description: 'Jedi Stuff, ya know',  time_spent: 60,  done: true)
    @win_rebellion     = @luke.tasks.create(heading: 'Win Rebellion',     description: 'no idea yet...',       time_spent: 180, done: false)

    @luke.save!
    @han.save!
    @leia.save!
  end

  def clean_up_models
    User.delete_all
  end

  def setup_objects
    @luke = PlainObject.new(first_name: 'Luke',     last_name: 'Skywalker', age: 25, active: true)
    @han  = PlainObject.new(first_name: 'Han',      last_name: 'Solo',      age: 35, active: true)
    @leia = PlainObject.new(first_name: 'Princess', last_name: 'Leia',      age: 25, active: false)
  end
end

RSpec.configure do |c|
  c.include SimpleFixtures
end