rspec2

How to use the test database with Capybara?

白昼怎懂夜的黑 提交于 2019-12-01 16:39:54
问题 I'm using RSpec, Spork, Capybara and Capybara Mechanic to write integration tests for a registration path that uses Facebook connect. It correctly navigates through registration, but the new users are created in my development database instead of the test database. RSpec is setup to use the test environment and I've confirmed that any model methods I run in my spec all hit the test database, but all of the UI actions hit development. Here's my test: it "go through registration path" do print

How to get the current test filename from RSpec?

穿精又带淫゛_ 提交于 2019-12-01 05:12:11
问题 I'm trying to speed up a large RSpec project's tests. In addition to using RSpec's --profile option I wanted to get the longest running test files [1] printed out. In my spec_helper.rb I dump the classes being tested and total time to a file, however as we have spec/model and spec/request directories I'd really like to be able to print the current test's filename and not just the class name ( described_class ), so that the user can disambiguate between model/foo_spec.rb and request/foo_spec

How to enable colors with rspec when using JRuby or bundle exec?

↘锁芯ラ 提交于 2019-11-30 23:52:48
问题 I'm trying to run my rspec's with JRuby: rake spec which results in: jruby -S bundle exec rspec --color spec/foo_spec.rb No colors show up, so I removed Jruby from the equation: bundle exec rspec --color spec/foo_spec.rb no colors. How can I get the "--color" option passed through to rspec? I've also got a .rspec file in the root directory of my project which doesn't seem to help in these cases. However, the .rspec file is picked-up or used when I just run: rspec spec/foo_spec.rb Any ideas?

What does Steak add beyond just using Capybara and RSpec in Rails testing?

99封情书 提交于 2019-11-30 18:55:48
I'm trying to understand the need for Steak. I get that its like Cucumber, except that you can use pure ruby instead of mapping your english language specs to ruby like in Cucumber, but it says that it mainly adds a wrapper around the RSpec DSL, and lets you use that taken from: http://jeffkreeftmeijer.com/2010/steak-because-cucumber-is-for-vegetarians/ module Spec::Example::ExampleGroupMethods alias scenario example alias background before end module Spec::DSL::Main alias feature describe end Is that all? I seems from the examples that you still do the heavy lifting with Capybara and RSpec

How to test with RSpec if an email is delivered

喜欢而已 提交于 2019-11-30 12:03:06
问题 I'd like to test if an email is delivered if I call a controller method with :post. I'll use email_spec so I tried this snipped here: http://rubydoc.info/gems/email_spec/1.2.1/file/README.rdoc#Testing_In_Isolation But it doesn't work, because I pass an instance of the model-object to the delivery-method and the instance is saved before the delivery. I tried to create an other instance of the model-object, but then the id isn't the same. My controller-method looks like this: def create @params

capybara/selenium with rspec before :all hook

假装没事ソ 提交于 2019-11-30 11:39:32
In an attempt to reduce the number of page visits with selenium, I wanted to call the visit method from a before :all hook and run all my examples with a single page load. However, when I specify before :all vs before :each , the browser opens, but the url is never visited. Below is a simplified and contrived example... describe 'foobar', :js => true do before :all do Capybara.default_wait_time = 10 obj = Factory(:obj) visit obj_path(obj) end it 'should have foo' do page.should have_content('foo') end it 'should have bar' do page.should have_content('bar') end end When I set it to before :each

Rails: Good Rspec2 example usage? (Also: Cucumber, Pickle, Capybara) [closed]

这一生的挚爱 提交于 2019-11-30 10:16:59
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I'm looking for a rather recent open source application that uses Rspec 2 as test library. I'd like to see how an experienced developer utilizes the library properly to test the full stack, since I'm constantly in doubt concerning my own knowledge (coming from testunit and partly due to the rather sparse

RSpec: describe, context, feature, scenario?

落爺英雄遲暮 提交于 2019-11-30 10:15:11
问题 describe , context , feature , scenario : What is the difference(s) among the four and when do I use each one? 回答1: The context is an alias for describe , so they are functionally equivalent. You can use them interchangeably, the only difference is how your spec file reads. There is no difference in test output for example. The RSpec book says: "We tend to use describe() for things and context() for context". Personally I like to use describe , but I can see why people prefer context .

RunTimeError: ActionController::RackDelegation in rspec 2.10.1 for rails 3.1.4 application controller

只谈情不闲聊 提交于 2019-11-30 09:24:32
In our rails 3.1.4 app, rspec is used to test the public method require_signin in application controller. Here is the method require_signin: def require_signin if !signed_in? flash.now.alert = "Log in first!" redirect_to signin_path end end Here is the rspec code: it "should invoke require_signin for those without login" do controller.send(:require_signin) controller {should redirect_to signin_path} end The above rspec generates gigantic multi pages error starting like the below: RuntimeError:←[0m ←[31mActionController::RackDelegation#status= delegated to @_response.status=, but @_response is

Factory Girl sequences not incrementing

泪湿孤枕 提交于 2019-11-30 07:27:25
问题 I'm trying to get FactoryGirl to generate some names for me, but the sequence doesn't seem to increment. # spec/factories/vessel.rb require 'factory_girl' FactoryGirl.define do sequence :vessel_name do |n| "TK42#{n}" end factory :vessel do name FactoryGirl.generate(:vessel_name) vessel_type 'fermenter' volume_scalar 100.0 volume_units 'bbl' end end # spec/models/vessel_spec.rb require 'spec_helper' describe Vessel do context 'working in the factory' do it 'makes a valid vessel' do vessel =