rspec-rails

Multiple Rails engine rspec controller test not work

徘徊边缘 提交于 2019-12-14 01:10:03
问题 I have multiple Rails engines in my Rails 4 beta1 application. I'm installed rspec-rails gem to every engines. And I created my engine following command: rails plugin new store_frontend --dummy-path=spec/dummy -d postgresql --skip-test-unit --mountable In my engine's dummy application I configured database and routes. Here is example routes.rb file: Rails.application.routes.draw do mount StoreFrontend::Engine => "/store" end When I run rspec inside first engine I get following errors: 1)

Undefined method accept_modal for Capybara::Webkit::Driver

て烟熏妆下的殇ゞ 提交于 2019-12-13 17:19:00
问题 In a Rails app, I'm using RSpec (with Capybara Webkit) to test that a Delete link is working. In my Rails template I have: <%= link_to 'Delete', movie_path(@movie), method: :delete, data: { confirm: 'Are you sure?' } %> And this is my spec: require 'rails_helper' describe "Deleting a movie", js: true do it "destroys the movie and shows the movie listing without the deleted movie" do movie = Movie.create(movie_attributes) visit movie_path(movie) page.accept_confirm do click_link 'Delete' end

Zeus fails when testing with Rspec

纵然是瞬间 提交于 2019-12-13 13:01:13
问题 When I run this command: rspec spec/controllers/messages_controller_spec.rb I get this: Finished in 0.54446 seconds 2 examples, 0 failures Randomized with seed 6226 It's good. However when I run this command: zeus rspec spec/controllers/messages_controller_spec.rb I get this: Finished in 0.5356 seconds 2 examples, 0 failures Randomized with seed 0 This is not a problem, but then immediately I get also this: F. Failures: 1) MessagesController POST #create create a message with an HTTP 200

RSPEC erros on Chapter 9 of Ruby Tutorial

微笑、不失礼 提交于 2019-12-13 05:48:51
问题 I'm using ruby 1.8.7 on mac osx10.8. I have no idea what these errors mean. I am currently at the end of chapter 9 of the ruby on rails tutorial. Any help is greatly appreciated! 1) Authentication signin with invalid information Failure/Error: before { click_button "Sign in" } NoMethodError: undefined method `[]' for nil:NilClass # ./app/controllers/sessions_controller.rb:8:in `create' # (eval):2:in `send' # (eval):2:in `click_button' # ./spec/requests/authentication_pages_spec.rb:21 2)

Why would RSpec report multiple validation errors of the same type?

二次信任 提交于 2019-12-13 05:43:12
问题 The following code: describe Task do let(:task) { Task.new } subject { task } before(:each) do task.valid? p task.errors.full_messages end it { should have(1).error_on(:title) } it { should have(1).error_on(:description) } end outputs: ["Title can't be blank", "Title can't be blank", "Title can't be blank"] and I can't figure out any specific reason this would happen but the way I experiencing things is that let and subject don't work very well lol Even the following code produces the same

Rspec generated spec failing

心已入冬 提交于 2019-12-13 05:23:41
问题 I've added the following to my application.rb file config.generators do |g| g.test_framework :rspec, :fixtures => true, :view_specs => false, :helper_specs => false, :routing_specs => false, :controller_specs => true, :request_specs => true g.fixture_replacement :factory_girl, :dir => "spec/factories" end Then I generated a controller with $rails g controller home index This generated the specification in spec/controllers/home_controller_spec.rb which looks like this describe HomeController

Ruby on Rails Tutorial Chapter 10 Exercise RSpec Failures

余生颓废 提交于 2019-12-13 02:35:43
问题 I'm working on the exercises from Chapter 10 of the Rails Tutorial and ran in to a snag with the exercise that has me ensure that an admin user can't delete themselves. My initial idea was to simply check the id of the current user and compare it against params[:id] to make sure that they're not equal. My destroy action in my Users controller looked like this: def destroy if current_user.id == params[:id].to_i flash[:notice] = "You cannot delete yourself." else User.find(params[:id]).destroy

Rspec - RuntimeError: Called id for nil, which would mistakenly be 4

那年仲夏 提交于 2019-12-13 00:45:37
问题 I'm now making Rspec test for create action of ItemsController , however I'm in trouble about the error. (There are models as Item , Auction , Bid , User ) The create method is as follow # POST /items # POST /items.json def create @item = Item.new(params[:item]) @item.user_id = current_user.id respond_to do |format| if @item.save format.html { redirect_to @item, notice: 'Item was successfully created.' } format.json { render json: @item, status: :created, location: @item } else format.html {

Set headers before each request in RSpec request spec

北城以北 提交于 2019-12-12 23:49:09
问题 How do I set headers within before each like below? RSpec.describe "Users API", type: :request do before :each do host! "example.org" // set a header for all requests here ?? end end Possible duplicate: How to set request headers in rspec request spec? But above didn't answer my question. 回答1: Found one solution. Include the Rack::Test::Methods module. I don't know why request specs doesn't provide this feature. RSpec.describe "Users API", type: :request do include Rack::Test::Methods before

rails 5 capybara test.log

廉价感情. 提交于 2019-12-12 12:23:59
问题 I'm having trouble with a few test and I would like to see in test.log the requests there're being done. There's a config that I can change to register the requests in log like below? Started GET "/carts" for 127.0.0.1 at 2017-07-25 19:09:55 -0300 Processing by CartsController#show as HTML Rendering carts/show.html.erb within layouts/application Rendered layouts/_header.html.erb (1.5ms) Rendered layouts/_notice_modal.html.erb (1.2ms) Rendered carts/show.html.erb within layouts/application (8