TDD with Test::Unit on Rails? View/Integration - ruby-on-rails

I'm wondering how views, integration gets tested using the vanilla rails test stack.
I already know Cucumber/RSpec but want a simpler, faster, more productive testing solution and I think Test::Unit offers that.

For views: http://guides.rubyonrails.org/testing.html#testing-views
For integration: http://guides.rubyonrails.org/testing.html#integration-testing
The official guides are your best bet for the latest version of Test::Unit.
Also note the "Guides Index" link on the top of that page, which gives you all the links to the latest, official online guides.

Related

Is Feature/Scenerio a replacement for Describe/It?

I've been following the Ruby on Rails Tutorial. The author uses Rspec/Capybara's Describe/It for the whole tutorial. But recently I've seen people using Feature/Scenerio instead. I wonder if Feature/Scenerio is a replacement of Describe/It or something that is used together? If it is a replacement, is there any reason of prefer it over Describe/It?
The same question came up to me lately too. And I went to Capybara's github page to read more about it (search for scenario). Apparently feature, scenario and background are just aliases to make acceptance tests more readable. And I guess that's for legacy reasons -- cucumber uses those keywords. Therefore by aliasing them, capybara acceptance specs read more like traditional cucumber specs.
So no, feature/scenario/background are not a replacement of describe/it/before. As a group of methods, it is only an alternative for acceptance specs. It's up to you and your team to decide which ones to go with.

Ruby on Rails 3.1 Blog Engines

I see a lot of people asking about Blog Engines, but most of the questions & answers are rather old. Or if they aren't old most of the projects are old. I'm wondering if anyone knows of any Blog Engines that currently support Rails 3.1 or are at least being actively developed to support Rails 3.1.
I would also be interested in seeing any sample applications or blog posts written for Rails 3.1 Blogs. I am going to be adding a blog to one of my websites, and would prefer to simply use a Rails Engine or sample code if there are any good ones out there. I hate reinventing the wheel. Looking for something simple, and not too opinionated so I can modify easily to suit my own needs.
you might want to check out Refinery http://refinerycms.com/engines
doesn't look like they are 3.1 yet, but probably soon
https://github.com/resolve/refinerycms-blog
Your best bet would probably be to use Typo.
Typo is currently using rails 3.0.9. Rails 3.1.0 is still a release candidate so I don't know of any blogging apps using it right now. If you must use rails 3.1.0 then you may have luck grabbing the gem for 3.1.0.rc4 (the newest version) and using typo anyway. Chances are everything will still work.
Hope this helps.
Perhaps Enki is a good fit, currently at Rails 3.0 but there is a github branch with Rails 3.1 support.
http://www.enkiblog.com/
Interestingly BrowserCMS was recently made to be a mountable engine: https://github.com/browsermedia/browsercms/commit/6098699fed2e3dbd65815ac3a5ce0dd6acc103d2
Seem to have a bit of time and experience behind them. More akin to Concrete5 with an inline front end / in context editing facility for users, which can be a real plus.
Im looking into this now and Im getting to conclusion that the best way to do this would be mounting a rack-app(like sinatra) into your rails app, there's various basic sinatra blogs in github to start or copy, not to mention this is fully customizable and I guess very light-weight.. engines will likely have dependencies and may also break when updating gems, a rack app won`t
I wasn't able to find any satisfying solution with engines
other stuff I found:
mounting a rails app inside a rails app: http://blog.dynamic50.com/2010/02/22/rails-3-0-mount-multiple-apps-as-engines/ feels a bit weird(heavy?), but you could mount a fully featured app like enki...
http://planscope.io/blog/2012/03/08/mounting-a-blog-within-a-rails-3-application/ this blogpost talks about using Toto, it seems pretty nice, easy and simple... but the project is not being maintained and it doesn't seem to be able to support a lot of features...
I dunno about using git to post, it makes it really simple but I dunno if I'd like having non-code stuff in my commits
Monologue https://github.com/jipiboily/monologue . From their web:
It is a barebone blog engine for Rails. It is built as a Rails engine and with a focus on keeping very few dependencies to ease it's use in your project. You can also use monologue-markdown which will replace the default editor with a simple Markdown editor.
Seems like pretty active development also.

How to create Rails App using cucumber

I am new for cucumber. I want to create on sample application using cucumber.
I am working on Windows 7 OS. Can any one guide me?
Thanks.
I think these are two separate problems:
Building a Rails application on Windows
Building a Rails application with Cucumber (using principles promoted by Cucumber like BDD, Specification by Example and an outside-in workflow)
Building a Rails application on Windows
There are a lot of tutorials, best starting point is probably: Getting Started with Rails on Rails Guides.
However the official advice there is using a virtual machine with Linux :-)
Here is a good thread with advice for running Rails under Windows.
Building a Rails application with Cucumber
An extraordinary example for this is the Book Rails 3 in Action by Manning.
This book really excels at showing how to create an application outside-in with Specification by Example using Cucumber.
In each chapter of the book a new feature is implemented. There are almost no screenshots explaining those features. Instead the authors are using Cucumber scenarios at the beginning of each chapter to exactly specify the desired new behavior that is the topic of given chapter. Then they are showing and explaining the necessary steps and the code that is needed to implement the functionality.
This is the best example I have found for using Cucumber with Rails so far.
This is also a really great example how Specfication by Example can be used for building a shared understanding - since teaching is all about sharing understanding.
However the scenarios in the book are quite focusing of specifying behavior on the UI level ... which is not commonly agreed on being best practice. But for teaching Rails it is great.
Rails 3 in Action is still in the early access program. I don't know where the official sources are.
But when you search on GitHub you already find different implementations of the example application (Tiketee):
https://github.com/rubykr/ticketee
https://github.com/oMartell/ticketee-rails-3-in-action
https://github.com/rails3book/ticketee
Here is the guide how to do it.
I found an interesting webcast video that does just this.
The basic procedure is define a couple features in cucumber. (actually the gherkin language)
Run cucumber
Fix errors
Repeat the
2 steps until you have a
working app.
It makes use of a few RoR gems like webrat and rspec.
http://railscasts.com/episodes/155-beginning-with-cucumber

Concept of, Framework for , How to Test View of MVC (Ruby on Rails)

I am now doing the UI from fresh so I want to make it fully test.
Could anyone suggest the correct way to do this and where should be the good place to start?
such as Concept, Framework.
(I already know some concept of testing)
Maybe Selenium can help you with frontend testing.
Take a look at The RSpec Book. The book goes over much more than just using RSpec (the testing framework). It also delves into the methodology of BDD (Behavior-Driven Development) starting from testing the UI using a tool like Cucumber all the way down through the rest of the Rails stack. It's probably the best book on the entire subject for practical testing in Rails right now. Most of the concepts in the book will apply to other languages and technologies as well
Try the Cucumber site. The site has a bunch of documentation and videos to get you started.
Watir may be useful as a tool and there are various tutorials out there for it.

What is the Path to Learn BDD on Ruby On Rails?

I want to start BDD on Ruby On Rails what should I learn?
I don't know anything about BDD, RSpec or Cucumber. What is the best way to learn? Tutorials? Something that cover things like 'What behavior I should test?' etc.
thanks!
RSpec specific; I keep these links for reference (might be advance for beginners). But just wanna share it with you. (Some of it probably already outdated but I think still worth a read)
Rspec Link Fest - links to other references
RSpec in Controllers:
Testing your Application Controller with rSpec
Testing Controllers with rspec
Using Rspec on Controllers
RSpec in Models:
stub_model by Dave Chelimsky
Do we really need Controller and View tests? - some discussion
RSpec in Views:
RSpec testing views for escaped HTML
Rspec Stories (now Cucumber):
Understanding RSpec Stories - a Tutorial
Rspec on Windows:
RSpec, autotest and Snarl on Windows - dunno if this still relevant
p/s: Some are from 2007, I'm not sure if the stuffs are outdated or not, but these are the some of my references used to learn RSpec. Hope it helps
Start with two articles by Dan North: Introducing BDD, followed closely What's in a Story?
Start at the top, RSpec home page:
http://rspec.info/

Resources