Skip to content

Instantly share code, notes, and snippets.

@dohoonk
Created February 6, 2016 00:37
Show Gist options
  • Select an option

  • Save dohoonk/5a1e9ca800e3af944043 to your computer and use it in GitHub Desktop.

Select an option

Save dohoonk/5a1e9ca800e3af944043 to your computer and use it in GitHub Desktop.
codecore
  describe "#show" do
    it "finds the object by its id and sets to to @campaign variable" do
      # GIVEN:
      campaign = Campaign.create({name: "valid name",
                                  description: "valid description",
                                  goal: 100000})
      # WHEN:
      get :show, id: campaign.id

      # THEN:
      expect(assigns(:campaign)).to eq(campaign)
    end
    it "renders the show template"
  end

end

gem "factory_girl_rails"

bin/rails g factory_girl:model campaign

gem 'hirb' gem 'interactive_editor' gem 'awesome_print'

FactoryGirl.create(:campaign)

FactoryGirl.define do
  factory :campaign do
    # if you dont put the block, its going to be the same for all.
    # block forces it to excute the code each time
    # add "sequence" if you want to be 100% sure
    # {Faker::Lorem.paragraph}

    sequence(:name)            {|n| "Faker::Company.bs-#{n}"}
    description                {Faker::Lorem.paragraph}
    goal                        10000000
    end_date                    60.days.from_now
  end
end

FactoryGirld.attributes_for(:campaign)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment