rspec-rails

Hide the list of files when running rspec?

柔情痞子 提交于 2019-11-28 03:39:20
问题 When running rake spec on the command line for a large Rails project, I get a giant list of every rspec file that will be run. Is there a way to hide that by default? ruby-1.9.3-p448/bin/ruby -S rspec ./spec/acceptance/replicators/activity_replicator_spec.rb ./spec/acceptance/replicators/template_replicator_spec.rb ./spec/authorization_rules/admin_authorization_rules_spec.rb ... When I run just rspec (no rake call) I don't get this console output. EDIT 1 Working from phoet's answer, I tried

Testing Rails 3.1 mountable engine with Rspec

三世轮回 提交于 2019-11-28 03:12:09
I started making a Rails 3.1 engine, and I'm having a hard time testing it using rspec. First of all, if I run rails g integration_test whatever it creates a regular integration test in tests/integration instead of spec/requests (the rspec-rails gem is installed and required as a development dependency in the gemspec file) Also, when I run a spec test I get an error saying the table corresponding to the model I'm testing has not been created. I tried rake engine_name:install:migrations and running rake db:migrate from inside the dummy app, and I get a "table already exists" error. Everything

How to rspec mock open-uri?

萝らか妹 提交于 2019-11-28 02:42:31
问题 I have this simple code where I am sending http request and reading all the response. Here is my rails code open("http://stackoverflow.com/questions/ask") How can I write spec for this line of code. I dont have the option to use mocha and webmock. I can only use mocking framework of Rpsec. I have tried to use this statement OpenURI.stub!(:open_uri).should_receive(:open).with("http://stackoverflow.com/questions/ask") but i keep getting this error RSpec::Mocks::MockExpectationError: (#<RSpec:

save_and_open_page (capybara / launchy) stopped working in a project - error

坚强是说给别人听的谎言 提交于 2019-11-28 01:59:23
问题 Trying to debug a section of specs that I cannot get to work when merging Rails two projects. I have deleted my Gemfile.lock and re-installed from scratch, I have run bundle update on specific gems, and the whole lot but am getting an error when I try to use in my request spec save_and_open_page railsdev$ bin/rspec spec/requests/authentication_pages_spec.rb No DRb server is running. Running in local process instead ... /Users/rb/Repos/Genie/spec/requests/authentication_pages_spec.rb:33:in

Cookies do not persist in Rspec on rails 3.1

淺唱寂寞╮ 提交于 2019-11-27 23:52:45
This is a problem with the cookies collection in a controller spec in the following environment: rails 3.1.0.rc4 rspec 2.6.0 rspec-rails 2.6.1 I have a simple controller spec that creates a Factory user, calls a sign in method which sets a cookie, and then tests to see if the signed in user may access a page. The problem is that all cookies seem to disappear between the authentication cookie being set and the "show" action being called on my controller. My code works fine when run in a browser on the rails dev server. The even stranger behavior while running the spec is that everything set

Rspec/Capybara loading in progress, circular require considered harmful

别来无恙 提交于 2019-11-27 21:00:48
Unsure if this is a Capybara issue, but I just did a fresh install of Rails (4.1.1) and Rspec Rails (3.0.1) and I would like to use Capybara (2.3.0), but having never used it I'm running into issues. I created a "spec" in spec/features and the spec itself runs and passes as expected, but I get the following "warnings" when rspec is run. Any ideas? Do I just need to disable warnings at the ruby level or something? /Users/typeoneerror/.rvm/gems/ruby-2.1.2@doki/gems/mail-2.5.4/lib/mail/network/delivery_methods/sendmail.rb:53: warning: shadowing outer local variable - to /Users/typeoneerror/.rvm

Controller spec unknown keyword: id

こ雲淡風輕ζ 提交于 2019-11-27 19:57:48
I have simple action show def show @field = Field.find_by(params[:id]) end and i want write spec for it require 'spec_helper' RSpec.describe FieldsController, type: :controller do let(:field) { create(:field) } it 'should show field' do get :show, id: field expect(response.status).to eq(200) end end but I have got an error Failure/Error: get :show, id: field ArgumentError: unknown keyword: id How to fix it? HTTP request methods will accept only the following keyword arguments params, headers, env, xhr, format According to the new API, you should use keyword arguments, params in this case: it

Why is my RSpec not loading Devise::Test::ControllerHelpers?

南楼画角 提交于 2019-11-27 11:53:12
问题 I'm using Rails 5, and Devise 3.5.1. Going through a nice (older) book about creating/testing an API, which uses Devise authentication. It was written before Rails 5, so I chose not to use the new api-only version. Here's my test... #/spec/controllers/api/v1/users_controller_spec.rb require 'rails_helper' describe Api::V1::UsersController, :type => :controller do before(:each) { request.headers['Accept'] = "application/vnd.marketplace.v1" } describe "GET #show" do before(:each) do @user =

How is spec/rails_helper.rb different from spec/spec_helper.rb? Do I need it?

青春壹個敷衍的年華 提交于 2019-11-27 10:42:58
I am doing the Rails Tutorial for the second time. When I enter this rails generate integration_test static_pages I get spec/rails_helper.rb and spec/spec_helper.rb instead of just spec/spec_helper.rb Now when I run my tests, they are longer (more "verbose") and slower than when I did this last time. I am wondering what the difference between the two files is, and if I did something wrong. Also, is there a way to get rid of the rails_helper.rb file without messing everything up? Dave Schweisguth rspec-rails 3 generates spec_helper.rb and rails_helper.rb . spec_helper.rb is for specs which don

Unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055)

妖精的绣舞 提交于 2019-11-27 06:56:40
While testing scenario by cucumber i'm getting the following error when running rspec tests unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError) Using ruby (1.9.2) selenium-webdriver (2.27.2) and firefox (19.0) Using rspec-rails (2.12.1) , capybara (2.0.2) and several other gems, Also i have added launchy gem but they don't seem to be a problem. And i am using Windows 7 . I had the same problem (on Linux). Fixed with: gem update selenium-webdriver Now I am using ruby 1.9.3-p286, selenium-webdriver 2.29.0, firefox 18.0 As well as