Ruby on Rails Monday, September 11, 2017

On 11 September 2017 at 18:41, Ben Edwards <login@funkytwig.com> wrote:
> Thanks for that, stated looking at the testing guide but was confused as to
> how to setup the test database. It seems it is talking about unit testing
> and does all the setup/pull down in the background.

As has already been suggested, work right through the
railstutorial.org tutorial, it covers unit and integration tests
(unless it has changed since I last looked). Staging is something
different.

Colin

>
> https://www.google.com/url?q=https%3A%2F%2Frailstutorial.org&sa=D&sntz=1&usg=AFQjCNHycyJCw8I6pyES5ucJMACNfAHfrgHad
> a glance through the rails guide and it looks great. Shame I can just buy
> it, ime not a big fan of the subscription model.
>
> Thansks,
> Ben
>
> On Sunday, September 10, 2017 at 7:45:43 PM UTC+1, Walter Lee Davis wrote:
>>
>>
>> > On Sep 10, 2017, at 2:33 PM, Ben Edwards <lo...@funkytwig.com> wrote:
>> >
>> > Thanks for your reply,
>> >
>> > I think I can work out most of the stuff but its the cloning the dev
>> > (db) into test that I cant work out. Seem to remember it saying something
>> > in the ruby config about the test database being re-writern from
>> > development (not sure how/when)
>>
>> If you have written migrations as you go, then the test database can be
>> created and structured by calling the following two rake commands:
>>
>> rake db:create RAILS_ENV=test
>> rake db:migrate RAILS_ENV=test
>>
>> If you have any seeds, then follow those with:
>>
>> rake db:seed RAILS_ENV=test
>>
>> I believe there are additional rake tasks specific to test setup that may
>> condense all of the above into a one-liner, you can see the entire list of
>> rake tasks by issuing this command (from within your rails project
>> directory:
>>
>> rake -T
>>
>> Your tests should not rely on any data besides what you add using seeds or
>> fixtures, as the test database may (should) be emptied and re-initialized
>> multiple times during a single testing run. So your comment about "cloning"
>> the dev DB into test may indicate that you need some more information about
>> how Rails tests run in general than you have at present.
>>
>> A good first stop is here: http://guides.rubyonrails.org/testing.html and
>> if you haven't done so already, you should definitely take a couple of days
>> to work all the way through https://railstutorial.org which is free to use
>> online. If you haven't gone through this tutorial in the last two years, you
>> should probably do it again, too. I've been using Rails since version 1, and
>> I learned a few things the last time I went through it. Hands-down, it is
>> probably the best-written technical training material I have ever used.
>>
>> Walter
>>
>> >
>> > More comments in-line below.
>> >
>> > On Sunday, September 10, 2017 at 6:05:04 PM UTC+1, Hassan Schroeder
>> > wrote:
>> > On Sun, Sep 10, 2017 at 9:05 AM, Ben Edwards <lo...@funkytwig.com>
>> > wrote:
>> > > 've been googling for this for a while wit little joy. Maybe I'm
>> > > using the
>> > > wrong search terms but I'm very surprised there is not a howto
>> > > guide;(,
>> > >
>> > > What I am trying to work out it how to take a project from development
>> > > to
>> > > test (and test) and then to production.
>> >
>> > Putting your app into production is usually called "deployment"; you
>> > should be able to find lots of references to that, but most Rails apps
>> > use Capistrano (highly recommended).
>> >
>> > Thanks, deployment yes, in terms of Capistrano will look into it but
>> > currently only have 5 pages and a lot of the data is loaded from outside
>> > rails (the load scripts already existed). In time will look into it. I
>> > feel better knowing how things work manually before going the automated
>> > route.
>> >
>> > > Test
>> > > I've seen in a few places that I can basically clone by rails
>> > > development
>> > > environment to test (including database). I gather this means going
>> > > to git
>> > > test branch and running some type of rails command to do this (not
>> > > sure what
>> > > or what I need to setup). All I can work out is I need to setup
>> > > config/environments/test.rb/ & config/database.yml.
>> >
>> > "git test branch"? What? Running tests has nothing to do with any
>> > particular git branch. And ideally you'd be writing and running tests
>> > continually throughout development.
>> >
>> > Sorry 'git checkout test'. I have develop, test and master branches.
>> > When I am ready to test for a release I merge develop into test. Cant see
>> > how I don't want to be in test branch for testing or am I doing this all
>> > wrong.
>> >
>> > > Exporting config Data
>> > > Bit more googling and I found out about 'rails db:seed:dump'
>> > > (http://www.rubydoc.info/gems/seed_dump/0.5.3). So I guess I use
>> > > something
>> > > like
>> > >
>> > > rake db:seed:dump MODELS=User, RefValue
>> >
>> > What are you calling "config data"? It's not usually something that's
>> > associated with the DB.
>> >
>> > There are a few tables, i.e. one tells the data load scripts which XML
>> > feeds to use to load data and other data to do with music venues. I prefer
>> > doing this as data input forms as it means I can access the data easily
>> > from rails (venue name, address, phone number) and validate data. Its data
>> > feed configuration which is setup by admins. Think seeds.rb is the answer
>> > here.
>> >
>> > Ben
>> >
>> > --
>> > Hassan Schroeder ------------------------ hassan.s...@gmail.com
>> > twitter: @hassan
>> > Consulting Availability : Silicon Valley or remote
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Ruby on Rails: Talk" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an email to rubyonrails-ta...@googlegroups.com.
>> > To post to this group, send email to rubyonra...@googlegroups.com.
>> > To view this discussion on the web visit
>> > https://groups.google.com/d/msgid/rubyonrails-talk/d706c6f4-2550-4c1f-a00e-a3f0ddaf8485%40googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/548ebdfe-9b3c-4164-a27a-57fe1dcfe5d1%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtmtKFO%3DD0Es6t3rr%2B6KJWkffn%2Byk%3Dfz-BT_LZd4HF21Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment