rspec

Using rspec with Webrat instead of Capybara

Hello everyone, I have been using rspec with webrat and decided to add cucumber for high level tests. After installing cucumber with capybara, for some reason rspec also switched to using it. Is there a way to tell rspec to continue using webrat ? ...

RSpec: Can I retain the new Rspec (2.0.x) with the old one (1.3.x) and still run autospec on 2.3.x Rails apps?

I gave Rails3 a try and to do so I installed the new gems, like RSpec2. When I went back to my old apps though, autospec stopped working for Rails 2.3.x apps: $ AUTOFEATURE=true autospec /usr/local/lib/site_ruby/1.8/rubygems.rb:335:in `bin_path': can't find executable autospec for rspec-2.0.1 (Gem::Exception) from /usr/bin/autospec...

RSpec sends emails (not storing in ActionMailer::Base.deliveries) - dont know why?

Hey, Im using rspec and when i run rake spec, the user mailer sends email through smtp and not stores the email in the ActionMailer::Base.deliveries-array (invoked by an user-observer)... Could you give me a hint why? # Rails version rails -v => Rails 3.0.1 # Ruby version with rvm (rvm version 1.0.16) ruby -v => ruby 1.9.2p7 (2010-09...

How do I test the title of a page from an RSpec view spec?

I'm learning RSpec 2 with Rails 3. In order to set the contents of the tag in the layout for each page, I have a helper that can be used to set the title and then return it: def page_title(subtitle=nil) if @title.nil? @title = ["Site Name"] end unless subtitle.nil? @title << subtitle end @title.reverse.join " - " en...

The right way to specify genre check box for the webrat example in PragProg RSpec book?

This question is regarding the html form in RSpec book (beta version b15_0), page: 301. The best way I could figure for that problem is this: <p> <%= f.label :genres %><br /> <%- @genres.each do |genre| %> <%= check_box_tag(genre.name, genre.id) %> <%= label_tag(genre.name) %><br /> <%- end %> </p> This forces me to chec...

Rails mock_model returning TrueClass?!

Trying to test a controller in Rspec. (Rails 2.3.8, Ruby 1.8.7, Rspec 1.3.1, Rspec-Rails 1.3.3) I'm trying to post a create but I get this error message: ActiveRecord::AssociationTypeMismatch in 'ProjectsController with appropriate parameters while logged in: should create project' User(#2171994580) expected, got TrueClass(#214825...

Errors with Michael Hartl's Rails Tutorial Chapter 7 - Specifically Rspec Testing Errors

I have not gotten any errors with the tests up to this point so far, but I can't figure out these errors. Failures: 1) PagesController GET 'home' should have the right title Failure/Error: response.should have_selector("title", undefined method `has_selector?' for #<ActionController::TestResponse:0x00000100ee9ed0> #...

RSpec - unexpected invocation

I have a spec which is failing because of this: unexpected invocation: #<AnyInstance:Achievement(id: integer, name: string, created_at: datetime, updated_at: datetime)>.errors() satisfied expectations: #<AnyInstance:Achievement(id: integer, name: string, created_at: datetime, updated_at: datetime)>.errors(any_parameters) In my spec I...

Rspec: testing nested controllers

Hello. I have a nested controller that works fine, and I'd like to setup rspec to also test a nested controlled, but it doesn't test the controller unless I specify it. i.e. my rspec test controller is here: /spec/controllers/organizations/memberships_controller.rb but when I run rspec to test everything, it tests everything except th...

Increase scan rate autotest with rspec

I find the integration with RSpec, Growl and rails particularly useful. However, it takes about two to three seconds before a change (save file) is picked up by autotest. Is there a way to increase the interval by which autotest scans for filechanges? ...

Cucumber: Before hook run only once for all scenarios

I have a scenario outline with multiple scenarios. I'd like my Before hook to run only once so I can bootstrap the ActiveRecord objects I need to run against all of the scenarios. The problem is if I use Before do # my code here end This will execute before each Scenario. Is there anyway to run it once for the entire Outline? ...

How to run a rake task right after rspec initializes the database

I have a Rails 2.2 app that I'm supporting and one thing that needs to be done before the app start is a small rake task to initialize and make sure the database is properly set. How can I get this task run right after rspec initializes the database. I run rspec using the rails spec command. ...

What are spec/requests good for?

I use RSpec to test my lovely little web app. For integration tests I use Steak. When using Rails generators (yep, I know that this is not the Zen way of doing TDD) there are also some files in spec/requests generated. As stated on link text it is something similiar to integration test (but I couldn't find much more info). Are those req...

Integration vs acceptance test ... what is Cucumber / Steak ?

For integration tests of my Rails web app I use Steak (something like Cucumber). The specs of Steak are in a folder named spec/acceptance. Are Steak/Cucumber now for integration or acceptance testing? I always thought that this is something different. ...

Do Rails controllers URL unencode params for me?

If a url parameter comes in urlencoded, does rails decode it for me, or do I have to call CGI::unencode myself? (I'm asking because I'm seeing what is I think inconsistent behavior, and may be a bug in either rails or rspec, but wanted to ask here first to get a sanity check) ...

Rails/Devise - What should I test with devise and rspec ?

Hi, Many programmers use devise as their authentication solution and I would like to get their advice: Devise is already tested, but I want to know if there is something to test by myself (integration/unit/funtionnal tests?) for a standard devise integration with my knowledge (I'm not familiar with shoulda and cucumber, but I know a ...

Rspec and Infinity Test in color

I am using infinity_test gem with rspec in a rails project. How can I get the output in color? I tried setting in terminal rspec --color I then ran "rspec spec/" to make sure color output was working. Then I run infinity_test and the test output is no longer in color. How can I get it to output in color? ...

Can you use RSpec, Shoulda, RCov?

I am attempting to get RCov to work with my RSpec and Shoulda test for a rails 3 app. It seems to work fine with my RSpec after using the Rake task below but all of the shoulda tests fail and I cant seem to find any documentation on getting these to work. They all run fine under autotest(rspec and shoulda). namespace :spec do desc "...

Mocking with rspec and mocha together

For a test suite that's already using mocha for mocking, can new tests be written with rspec mocking? maybe turn that on before(:all) and turn it back to mocha after(:all) I tried changing the Spec::Runner configuration at run-time and that didn't seem to work with mocking ...

How to mock request object for rspec helper tests?

I've a view helper method which generates a url by looking at request.domain and request.port_string. module ApplicationHelper def root_with_subdomain(subdomain) subdomain += "." unless subdomain.empty? [subdomain, request.domain, request.port_string].join end end I would like to...