How can i test app with thinking sphinx with rspec? - ruby-on-rails-3.1

I have Ruby on Rails 3.1 application and i use for Sphinx + Thinking sphinx for searching. For testing i use RSpec + autotest. I want to test my searching. Where can i read how to test my app right via rspec?

I have compiled a gem that helps with the testing process. It is working but needs some love and attention also! :D

That is not what i actually wanted but:
http://freelancing-god.github.com/ts/en/testing.html
Hope, it will be useful for someone.

Related

Documentation as tests in Ruby?

There is a great tool rustdoc (currently used by cargo) to test examples of documentation comments in Rust. Does rdoc or yard give us something similar in Ruby?
Well, there few examples of doctest tool in Ruby, and the most fresh one (for now) is yard-doctest:
Meet YARD::Doctest - simple and magical gem, which automatically parses your #example tags and turn them into tests!
Probably no so powerful as rustdoc, but it does what it needs to.

Problems creating a railtie for a rails ORM gem I'm developing

I am developing a Ruby gem, Ampere, that acts as an ORM for the Redis database. I am trying to shore up its Rails integration, and was able to tie in an initializer and console hook, but my generators do not work yet. I have a generator, ampere:config that installs a default configuration YAML file, and a replacement for the model generator as well.
When I install my gem into a testing Rails app, the ampere:config generator shows up in the list when I run rails generate on the command line, but when I type rails g ampere:config, I get:
Could not find generator ampere:config.
and nothing else. My generator lives in "lib/rails/generators/config/" within the gem, and clearly Rails knows about it since it showed up in the rails g list, but something's not right. If anyone can help or knows of some better documentation for this than the Rails Guides, which are sparse to say the least, it'd be much appreciated.
Ok so I finally got this. For the generators to work, they have to call source_root with the relative path of their templates, and they have to live in lib/rails/generators/your_gem_name/, then the directory structure in your_gem_name/ is what you'd expect from reading the documentation (or running rails g generator in a Rails project).
The documentation is not very clear about this, so it was a bit confusing, but after looking at a few examples I tried this and it worked.

What are some good example open source Ruby projects that use Cucumber and RSpec well?

What are some good example open source Ruby projects that use Cucumber and RSpec well?
Update: While the suggestions below where quite impressive, I wanted to see how others are using RSpec and Cucumber to drive product development.
From Quora:
Teng Siong Ong, Ruby, Python, etc.
https://github.com/teambox/teambox
I find it really nice that the RSpec project is tested with both Cucumber and RSpec itself:
https://github.com/rspec/rspec-core/tree/master/features
https://github.com/rspec/rspec-core/tree/master/spec
Cucumber is also self-hosted test-wise:
https://github.com/aslakhellesoy/cucumber/tree/master/features
I've also found it very useful that Aruba, a library of steps for testing CLI apps with Cucumber, is itself tested with Cucumber:
https://github.com/aslakhellesoy/aruba/tree/master/features
RubySpec is a rather ambitious effort to write specs for the Ruby language.

former php user trying to learn ruby...very tough

i write something in ruby thinking that it will work as it did in php but no!
i realized that you need to clone objects using .clone
merely associating to a variable doesn't work !
in php this worked fine!
it took 2 days until i discovered this error!
what tutorials can i read to get firm grasp on ruby ?!
Why's poignant guide to ruby
You might also want to look at the Pickaxe online.
Beginning Ruby by Peter Cooper is a good option.
I am a new Ruby user as well. What I did was build a web app first with Rails and then move into the Ruby core. This is the book I started with.
Foundation Rails 2
Check out this book: Rails for PHP Developers

Autospec / rspec not working, doing something wrong?

I wonder if this has its place on StackOverflow, but since it IS programming-related, I will shoot it away.
Here's my problem. I am new to TDD and I love Ruby, so the obvious path I'm taking is testing stuff with rspec. Why obvious? I saw it in diverse screencasts and thought it was really neat. Then I saw "autospec" somewhere, and tried to use it.
So I install the gem, using sudo gem install ZenTest (according to the instructions here)
Next, I go into my folder, containing "digit.rb" and "digit_spec.rb", and fire up autospec without any parameter. Nothing happens. Worthy of note that I have two tests in my spec file and that I can test it fine just using the spec command, but I'd be delighted to use autotest...
Any help/pointers/documentation link available? Please? :P
You need to create .autotest file containing this code:
Autotest.add_hook :reset do |at|
at.clear_mappings
at.add_mapping(/^(.*?)(_spec)?\.rb$/) { |filename, m|
if m[2]
filename
else
"#{m[1]}_spec.rb"
end
}
end
it changes the default mapping of file to spec
Maybe you can give spork + autospec a try. The spork instructions on the rspec wiki is probably the most current way to go: https://github.com/dchelimsky/rspec/wiki/spork---autospec-==-pure-bdd-joy-

Resources