When writing middle - big application, tags is very useful to find method and variable definition.
Especially for RoR application, ripper-tags is useful and it would be great if update tags when git checkout.
# foo_spec.rbdescribeFoodobeforedo@__orig_bar=Foo::BAR.dupFoo.send(:remove_const,:BAR)Foo::BAR='???'endafterdo# restore to original constant.# without this, Foo::BAR remains '???'Foo.send(:remove_const,:BAR)Foo::BAR=@__orig_barendit'have constant BAR'doexpect(Foo::BAR).toeq'???'endend
The merit of this way is to change constants completely and the constant is evaluated directly.
Adding to it, this method works without any libraries.
The demerit of this way is that this is something like META programming. This may not be easy to understand for ruby beginner.
Second option is to use stub_const defined in rspec-mocks.
# foo_spec.rbdescribeFoodobeforedo# no need to restore.# It restores after Foo example finished.stub_const('Foo::BAR','???')endit'have constant BAR'doexpect(Foo::BAR).toeq'???'endend
The merit of this way is easy to setup and easy to understand.
Ths demerit of this way is that stub_const depends on rspec-mocks, so if you want to use stub_const with minitest,
you have to HACK minitest.
Chosing remove_const vs stub_const depends on your situation. I think if the constant is important for buisiness logic,
you should choose remove_const. If the constant is no so important testing and using rspec, you choose stub_const.
I think this discussion has no goal, but I think having many options is one of the the ways to be a HACKER.
To use custom domain for GitHub pages, create CNAME file and write like:
With this file, you can see domain setting on Github repository > Settings > GitHub Pages like:
Next, open your DNS configure page, setup like:
Wait 1~3 hours(depend on you DNS server or environment).
Then open teminal and type like:
$ dig www.example.com +nostats +nocomments +nocmd
;www.example.com. IN A
www.example.com. 3592 IN CNAME username.github.io.
username.github.io. 43192 IN CNAME github.map.fastly.net.
github.map.fastly.net. 22 IN A 126.96.36.199
If you publish username.github.io repository to www.yoursite.com, then GitHub redirects
username.github.io to www.yoursite.com.
However, if you publish another repository to subdomain.yoursite.com, GitHub does not redirect
www.yoursite.com/another to subdomain.yoursite.com.
If you want to redirect www.yoursite.com/another to subdomain.yoursite.com, you should write