Cucumber Testing Rails Application on a Webrick Server - ruby-on-rails-3

How to cucumber testing create in rails application which running on webrick server?

Cucumber is pretty easy to work with. I would highly suggest that you watch these 2 railscasts:
http://railscasts.com/episodes/155-beginning-with-cucumber
http://railscasts.com/episodes/159-more-on-cucumber
If you already know a bit about regular expressions as well, cucumber will be a breeze to work with.

Related

Rails 4 and Locomotive cms workarounds?

I want to try Locomotive CMS, while I was installing it, I realised that only runs with rails 3+ version no 4.
As I am currently working in a couple of other apps in rails and I am pretty new to it, I was wondering if is there any way to run one version of rails for locomotive and another one(rails 4) for my other apps. If so how could it be done?
Thanks in advance.
C
You definetely want to start using rvm. It will help you not only separate your gems for different projects, but also separate and manage your Ruby versions. Definetely a great tool.

Libraries classes in Ruby on rails

I'm going to develop an application on Ruby on Rails which has many library classes. But I have no such idea. Is it possible or not in Rails? If possible, how can I develop my own library class in rails application? Please suggest me.
since i do not understand your question very well, i can only guess what you mean.
there are several ways of abstracting logic in ruby and ruby on rails.
the most general approach is creating ruby gems. this is a package of ruby code that can be used in every ruby project. it's possible to hook into rails through gems via railties.
there are two things that are specific to rails. the first one are plugins, that work very similar to gems and are considered a legacy way of providing functionality, but there are still some plugins around, especially for rails apps prior version 3.
the other thing is engines. these are micro-applications that can be mounted into any rails app. they are self-contained and can provide a lot of functionality based on their namespaced routes.
since rails is based on rack, it's also possible to hook any rack-conform ruby application into the rails router. through this approach it's possible to connect rails apps with ie. sinatra applications.

Using cucumber to test an API not written in rails

I'm writing an API using a non-rails framework. I normally use Cucumber for BDD and testing of API's when I'm writing them in RAILS.
Is there a strong reason not to use Cucumber when I'm testing an API written on top of node.js (or any other framework, really)?
Strong technical reasons to not do this might include:
Dependency of Cucumber on Rails
The existence of a better framework for node.js
Some other technical reason I don't know about.
First of all, Cucumber doesn't depend on Rails.
I have been trying out some different javascript testing frameworks to try to work out what I want to use. So far I like mocha with expect.js for unit testing but I haven't found anything for integration testing a node app that I'm happy with. It's possible to do with mocha and supertest, and I've also tried cucumber.js which is getting there but it's not as mature as the Ruby version - so that's what I intend to use.
I can't think of a good reason not to do this, apart from it may be harder to do things like set up fixtures - but that may well be a good thing as it would force your tests to deal only with the public interface of your API - as it was intended to be used.
As said cucumber has nothing to do with rails.
You could perfectly use it to test API's written in any languages.
In case you want to use node.js full stack cucumber.js is a good option.

What continuous integration servers work well with ruby on rails 3 and mac?

I am using a mac as the server. I need something that works well.
I wanted to use atlassian's bamboo but my attempts have failed. The latest doc I can find on the topic is an old blog post. http://blogs.atlassian.com/news/2009/05/bamboo_customer_8.html which helps very little and results in the error:
...rvm/rubies/ruby-1.8.7-p334/lib/ruby/site_ruby/1.8/rubygems.rb:900:in `report_activate_error': Could not find RubyGem bundler (>= 0) (Gem::LoadError)
I looked at http://rubyforge.org/frs/?group_id=2918 which also appears to be years out of date.
So the question is, which Continuous integration server should I use for my rails 3 project, which I can run on a mac and use .rvm (today in 2011)?
Jenkins is always worked for me, you even have a OSX installer:
http://ingorichter.blogspot.com/2011/04/jenkins-osx-installer.html
CI Joe works fine for me with rails 3 and mac.
Jenkins also seems nice, though, as Ed_ mentioned. Especially the part about the OSX installer.
CruiseControl.rb is a CI written in Ruby and can be used for Rails projects.

Can't get a basic Selenium + Capybara + Cucumber to work on Rails 3

Ok, I've been using selenium, etc for rails 2 projects, I've been working on for a while. Deciding to refactor AS I move the app to Rails 3, I've been trying to set up a very basic Rails 3 project with cucumber and capybara, and then run a test with selenium. (I'm using selenium because I know for a fact that some of my feature tests required me to use selenium to get the proper javascript interactions to work.)
I set things up plain jane, have all the gems installed, ran the cucumber installer with the --capybara - the whole nine yards. Yet when I include #selenium in a test I get:
When I go to the home page # features/step_definitions/web_steps.rb:23
Selenium is not a module (TypeError)
./features/step_definitions/web_steps.rb:24:in `/^(?:|I )go to (.+)$/'
features/access.feature:10:in `When I go to the home page'
Why am I getting this Selenium is not a module error? I know it means it's not loaded, but I've gone back over my steps three times and can't figure out why this is coming up. Anyone have leads on what I should be checking?
Again, this is rails 3. I'm on ruby 1.9.2 with this project.
Thanks
Welp, found the answer. I had neglected to install selenium-client gem and require selenium/client in the env.rb.
All better now. Just needed a day off to think it through.