rspec

Remove Gem from RVM Gemset?!?

New to RVM and playing with Rails 3 & Ruby 1.9.2 betas... I've got two copies of rspec in a gemset. Was using beta.19 but need to downgrade to beta.18. changed my gemfile and then bundle install. now i have a mess... *** LOCAL GEMS *** . . . rspec (2.0.0.beta.19, 2.0.0.beta.18) rspec-core (2.0.0.beta.19, 2.0.0.beta.18) rspec-expectati...

how to use rspec to validate the ruby code?

class UbacParser def initialize(str) @str= str @valid= true base_parse end private def base_parse @protocol_code = Integer(@str[0..2]) rescue nil begin @data = @str[@str.index('<')[email protected]('>')-1] str_mod = @str[@str.index('>##')+1..-1] arr_mod=str_...

Why use Mocks in Rspec?

I dont get why I should use Mocks in Rspec. If I write Specs, shouldn't I write the actual code afterwards so that the tests would pass? So why use Mocks and replace those actual classes? ...

Rspec: Can't understand "and_raise" method

Here is my code: account_double.should_receive(:withdraw).and_raise I get the output: 1) Statement uses the customer's name in the header Failure/Error: Unable to find matching line from backtrace Exception # ./spec/codebreaker/test.rb:8:in `generate' # ./spec/codebreaker/test.rb:20 # /usr/local/lib/site_ruby/1.8/rubygems/custom_requ...

Rspec test for the existence of an action is not working

hi , i am working in Rspec of ROR.. I am trying to test my controllers using RSpec.i am having a Users controller with functions like new , tags, etc.. i created a file under spec/users_controller_spec.rb and added the test cases as. require 'spec_helper' describe UsersController do integrate_views it "should use UsersControl...

Imperative and declarative steps in Rspec

I wonder what imperative vs declarative steps in Rspec is all about. Here is an example code from the Rspec book: Scenario: transfer money (declarative) Given I have $100 in checking And I have $20 in savings When I transfer $15 from checking to savings Then I should have $85 in checking And I should have $35 in savings Scenario: tran...

how to run a spec file with ruby without spec

how to run a spec file with ruby without spec? How do i inherit the spec base class to the current ruby spec file? ...

Ruby Rspec outputs literal escape characters on windows

Hi all, I'm following the ruby on rails tutorial: http://railstutorial.org/chapters/static-pages#top I'm up to using rspec. Having installed the win32console gem, it outputs gibberish in the console, i assume it is outputting the ansi colour change codes: >rspec spec/ ?[31mF?[0m?[31mF?[0m Finished in 0.34376 seconds ?[31m2 examples, ...

What's the best way to write Resque-related specs in RSpec?

What's the best way to write Resque-related specs in RSpec without stubbing the former? We currently use the following helper: @dir = File.dirname(File.expand_path(__FILE__)) def start_redis `redis-server #{@dir}/redis-test.conf` Resque.redis = "localhost:9736" end def stop_redis `rm -f #{@dir}/dump.rdb` pid = `ps -A -o pid,c...

upgraded to rails 3, and now autospec in my rails 2 projects just exits

I've been working on a rails 2.3.8 app for a long time now. Autospec has been working like a champ. Last night, I started a new app in rails 3 and after some shenanigans got autospec working for rails 3. Now, in my rails 2 apps, when I run autospec, I get a single line of output and then it exits. loading autotest/rails_rspec I've b...

Cucumber can't find routes? This is potentially a big newb question.

Rails3 app with Rspec2 and Cucumber Cucumber Given /^that a user is logged in$/ do current_user = User.first render new_user_post_path(current_user) end Routes.rb map.resources :users do |users| users.resources :posts, :collection => {:view => :get} end posts_controller_spec describe PostsController do describe "#new" do ...

Tutorial for using cucumber and rspec with .net apps

Are there any good tutorials out there for using cucumber and rspec for testing .net applications? ...

How many use Rspec for controllers and views?

Are there strong reasons for using Rspec for controllers and views too? My views are heavily dependent on Javascript, and as far as I know, Rspec doesn't handle javascript/ajax on views. Also im using Cucumber + Selenium for that. And should I use it for controllers? Isn't it enough to just use Cucumber + Selenium for the application ...

Cucumber step definition for "Given that I'm logged in"

I've got a cucumber step: Given that I'm logged in I don't understand how I should implement it as a step definition. Could someone point me into right direction, tutorials, blogs etc. ...

Rspec problem with authentication and before_filter

Hi guys this one is puzzling me xD I'm sure its something small that my logic just doesnt compute... I got the following test in my controller spec: describe "delete 'destroy'" do before(:each) do @post1 = @user.posts.create(:wall_id => @user2, :body => "foobar") @post2 = @user.posts.create(:wall_id => @user, :bod...

Cucumber Help in Rails 3

I am very new to cucumber and rspec, but do have some rails and ruby understanding. The gems in question are: Devise, Declarative_Authorization, and role_model Rails 3 is what I am using and ruby 1.9.2-rc2 remember I do NOT know what I am doing I have written a Feature: Feature: As the administrator of the site give me quick access ...

Testing helper methods w/ RSpec

How should I go about testing this helper with RSpec? module ApplicationHelper def build_rpx_url(provider) signin_url(provider) << "?token_url=" << token_url << provider_params(provider) end private def signin_url(provider) case provider.downcase when 'facebook'; 'https://login.xyz.net/facebook/connect_start' ...

How can I test common Rails controller behavior while staying DRY?

I've been writing RSpec tests for some Rails controllers and I've discovered a strong impulse to ensure that the Authlogic authentication is working properly. I also feel like I should be verifying that each action uses the same application-wide layout. However, writing tests for this behavior in every single action seems silly. What I'...

Rspec is giving an error with my layout links from the rails tutorial: "Failure/Error: Unable to find matching line from backtrace"

Hi, I'm following the rails tutorial here: http://railstutorial.org/chapters/filling-in-the-layout#top When i run "rspec spec/", i get a bunch of errors that look like this: 1) LayoutLinks should have a Home page at '/' Failure/Error: Unable to find matching line from backtrace stack level too deep # C:/Ruby19/lib/ruby/1.9....

Installing RSpec Bundle for TextMate

I am getting started with Ruby development and bought a MAC few days ago. I am having a hardtime installing the RSpec bundle on my TextMate. When I type the following command: John-Doe-MacBook-Pro:Users johndoe$ cd ~/Library/ApplicationSupport/TextMate/Bundles/ I get the following: -bash: cd: /Users/johndoe/Library/ApplicationSuppor...