rspec

ruby on rails tutorial section 3.2 rspec testing error

故事扮演 提交于 2020-01-01 06:12:03
问题 recently started the RoRTute by Michael Hartl, getting stuck trying my first rspec test in section 3.2, at this point the test is meant to fail but all i get are errors which I'm having a hard time interpreting. I've had a look around but not getting much luck finding a similar error and/or solution. I am brand new to programming and ruby/rails. Any help would be greatly appreciated, thank you! terminal error output Macintosh:sample_app rails$ bundle exec rspec spec/requests/static_pages_spec

ruby on rails tutorial section 3.2 rspec testing error

坚强是说给别人听的谎言 提交于 2020-01-01 06:11:20
问题 recently started the RoRTute by Michael Hartl, getting stuck trying my first rspec test in section 3.2, at this point the test is meant to fail but all i get are errors which I'm having a hard time interpreting. I've had a look around but not getting much luck finding a similar error and/or solution. I am brand new to programming and ruby/rails. Any help would be greatly appreciated, thank you! terminal error output Macintosh:sample_app rails$ bundle exec rspec spec/requests/static_pages_spec

Comprehensive guide on testing rails app

一笑奈何 提交于 2020-01-01 05:52:26
问题 Is there any comprehensive guides on testing rails apps. Im searching for guide that will tell me what should I test and how should I test it especially with Rspec. Lots of examples will be appreciated. 回答1: Check out Everyday Rails Testing with RSpec. Sumner does a great job of walking you through writing tests for an entire app. The Hartl book is also a great resource. 回答2: The RSpec Book Testing the rails app is part of development so I'd sugest to read Ruby on Rails Tutorial, Learn Rails

Why are my cucumber scenarios failing when steps are run together, but pass when run singularly?

那年仲夏 提交于 2020-01-01 05:46:13
问题 When I run my cucumber scenarios as a whole, or with the command: cucumber I get 7 failing steps. When I run them individually with the work in progress tag they pass fine. I don't think it's a database state issue.. I'm running with transactions and I also tried running without and cleaning the database with database cleaner.... still does not help. I tried to run the debugger but it does not seem to work when I run the command cucumber. It only works when I run with the work in progress tag

Testing password length validation with RSpec

孤者浪人 提交于 2020-01-01 04:49:04
问题 I'm writing some unit tests to ensure a User model cannot have a password < 8 characters long. I started with a User model: class User < ActiveRecord::Base ... validates :password, :length =>{ :minimum => 90, :too_short => "password is too short, must be at least %{count} characters" }, :on => :create end And a user_spec.rb test: describe User do subject { FactoryGirl.build :user } its(:password) { should have_at_least(8).items } end However I realised that this doesn't actually test my

Spork and cache_classes problem with rspec, factory_girl and datamapper

邮差的信 提交于 2020-01-01 02:33:07
问题 I've got a problem with Spork test server. If I set config.cache_classes = false in config/environments/test.rb then specs start to rasie errors. Failure/Error: task = Factory(:something, :foo => @foo, :bar => @bar) DataMapper::ImmutableError: Immutable resource cannot be modified This is my spec_helper.rb: require 'spork' Spork.prefork do if ENV['CODE_COVERAGE'] == '1' require 'simplecov' SimpleCov.start 'rails' end ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../../config

Getting the full RSpec test name from within a before(:each) block

白昼怎懂夜的黑 提交于 2020-01-01 01:11:34
问题 RSpec allows you to get the current running test method name in a before(:each) block, by doing the following: Spec::Runner.configure do |config| config.before :each do |x| x.method_name # returns 'should be cool' end end This is for a test like: require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe 'Hello world' do it 'should be cool' do # test code end end Would it be possible to get the whole test name with what it's describing, (a.k.a. 'Hello World should be cool')

rspec returns “PG::Error: ERROR: relation ”table_name“ does not exist”

血红的双手。 提交于 2019-12-31 21:42:34
问题 Environment is REE(2011.12) on rvm, rspec 2.8.0, rails 3.0.6, and pg 0.13.2. Using PostgreSQL 8.3.17 on CentOS 5.6. The db:migrate have work correctly. But rspec have got following error. 1) ApiController articles OK Failure/Error: Unable to find matching line from backtrace ActiveRecord::StatementInvalid: PG::Error: ERROR: relation "table_name" does not exist : DELETE FROM "table_name" I'm updating my project from rails 2.3.5 with rspec 1.x series to rails 3.0 with rspec2. Copied all rspec

require lib in RSpec with Ruby 1.9.2 brings “no such file to load”

删除回忆录丶 提交于 2019-12-31 20:17:51
问题 I am trying to upgrade one of my Rails projects to Ruby 1.9.2 . All went pretty well, but one RSpec test broke. In this test I require a Ruby lib : # file spec/models/my_lib_spec.rb require 'spec_helper' require 'lib/services/my_lib' describe "MyLib" do it "should do something" do ... The lib looks like this: # file lib/services/my_lib.rb class MyLib def self.do_something ... In Ruby 1.8.7 (REE) the test worked well: $ ruby -v ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin11.1.0], MBARI

RSpec: how do I write a test that expects certain output but doesn't care about the method?

早过忘川 提交于 2019-12-31 20:14:29
问题 I'm trying to get my head around test-driven design, specifically RSpec. But I'm having trouble with some of the examples from The RSpec Book. In the book, we test for output on $STDOUT like this: output = double('output') game = Game.new output.should_receive(:puts).with('Welcome to Codebreaker!') game.start() Well, that works after a fashion. But why on earth should I care if the Game object uses the puts() method? If I change it to print(), should it really break the test? And, more