Rspec / Capybara测试带来sass错误(页面上没有错误)

时间:2015-08-13 16:43:53

标签: ruby-on-rails rspec devise capybara

首先,我在测试时非常新,所以这可能是也可能不是一个糟糕的问题。所以我一直在测试我创建的应用程序,以便学习设计。我的第一个测试是发现如果我能在我的页面上找到注册单词。这是测试:

require 'rails_helper'
require 'spec_helper'

describe "devise sign up" do
    describe "Sign up content" do
      it "Should have the content 'Sign up'" do
        visit '/users/sign_up'
        page.should have_content("Sign up")
      end
    end
end

现在这是我为这次测试得到的输出......这很长

1) devise sign up Sign up content Should have the content 'Sign up'
 Failure/Error: page.should have_content("Sign up")
   expected to find text "Sign up" in "Sass::SyntaxError at /users/sign_up =================================== > Invalid CSS after \" outline: none\": expected \"{\", was \";\" app/views/layouts/application.html.haml, line 6 ----------------------------------------------- ``` ruby 1 !!! 2 %html 3 %head 4 %meta{:content => \"text/html; charset=UTF-8\", \"http-equiv\" => \"Content-Type\"}/ 5 %title Cairai > 6 = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true 7 = javascript_include_tag 'application', 'data-turbolinks-track' => true 8 //%link{:href => \"//fonts.googleapis.com/css?family=Open+Sans:400,600,700,300|Titillium+Web:200,300,400\", :rel => \"stylesheet\", :type => \"text/css\"} 9 = csrf_meta_tags 10 %body.theme-blue 11 #theme-wrapper ``` App backtrace ------------- - app/views/layouts/application.html.haml:6:in `_app_views_layouts_application_html_haml__3968601281956987024_48552360' - app/controllers/registrations_controller.rb:11:in `new' - spec/features/devise/registrations/new.html.haml_spec.rb:7:in `block (3 levels) in ' Full backtrace -------------- - sass (3.4.16) lib/sass/scss/parser.rb:1162:in `expected' - sass (3.4.16) lib/sass/scss/parser.rb:1098:in `expected' - sass (3.4.16) lib/sass/scss/parser.rb:1093:in `tok!' - sass (3.4.16) lib/sass/scss/parser.rb:638:in `block' - sass (3.4.16) lib/sass/scss/parser.rb:708:in `declaration_or_ruleset' - sass (3.4.16) lib/sass/scss/parser.rb:658:in `block_child' - sass (3.4.16) lib/sass/scss/parser.rb:650:in `block_contents' - sass (3.4.16) lib/sass/scss/parser.rb:639:in `block' - sass (3.4.16) lib/sass/scss/parser.rb:632:in `ruleset' - sass (3.4.16) lib/sass/scss/parser.rb:657:in `block_child' - sass (3.4.16) lib/sass/scss/parser.rb:650:in `block_contents' - sass (3.4.16) lib/sass/scss/parser.rb:117:in `stylesheet' - sass (3.4.16) lib/sass/scss/parser.rb:42:in `parse' - sass (3.4.16) lib/sass/engine.rb:403:in `_to_tree' - sass (3.4.16) lib/sass/engine.rb:278:in `render' - sprockets (3.2.0) lib/sprockets/sass_compressor.rb:48:in `call' - sprockets (3.2.0) lib/sprockets/sass_compressor.rb:28:in `call' - sprockets (3.2.0) lib/sprockets/processor_utils.rb:75:in `call_processor' - sprockets (3.2.0) lib/sprockets/processor_utils.rb:57:in `block in call_processors' - sprockets (3.2.0) lib/sprockets/processor_utils.rb:56:in `call_processors' - sprockets (3.2.0) lib/sprockets/loader.rb:86:in `load_asset_by_uri' - sprockets (3.2.0) lib/sprockets/loader.rb:45:in `block in load' - sprockets (3.2.0) lib/sprockets/loader.rb:155:in `fetch_asset_from_dependency_cache' - sprockets (3.2.0) lib/sprockets/loader.rb:38:in `load' - sprockets (3.2.0) lib/sprockets/cached_environment.rb:20:in `block in initialize' - sprockets (3.2.0) lib/sprockets/cached_environment.rb:47:in `load' - sprockets (3.2.0) lib/sprockets/base.rb:63:in `find_asset' - sprockets (3.2.0) lib/sprockets/base.rb:89:in `[]' - sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:123:in `asset_digest_path' - sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:76:in `compute_asset_path' - actionview (4.2.3) lib/action_view/helpers/asset_url_helper.rb:135:in `asset_path' - sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:91:in `asset_path' - actionview (4.2.3) lib/action_view/helpers/asset_url_helper.rb:267:in `stylesheet_path' - actionview (4.2.3) lib/action_view/helpers/asset_tag_helper.rb:100:in `block in stylesheet_link_tag' - actionview (4.2.3) lib/action_view/helpers/asset_tag_helper.rb:96:in `stylesheet_link_tag' - sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:170:in `stylesheet_link_tag' - app/views/layouts/application.html.haml:6:in `_app_views_layouts_application_html_haml__3968601281956987024_48552360' - actionview (4.2.3) lib/action_view/template.rb:145:in `block in render' - activesupport (4.2.3) lib/active_support/notifications.rb:166:in `instrument' - actionview (4.2.3) lib/action_view/template.rb:333:in `instrument' - actionview (4.2.3) lib/action_view/template.rb:143:in `render' - actionview (4.2.3) lib/action_view/renderer/template_renderer.rb:66:in `render_with_layout' - actionview (4.2.3) lib/action_view/renderer/template_renderer.rb:52:in `render_template' - actionview (4.2.3) lib/action_view/renderer/template_renderer.rb:14:in `render' - actionview (4.2.3) lib/action_view/renderer/renderer.rb:42:in `render_template' - actionview (4.2.3) lib/action_view/renderer/renderer.rb:23:in `render' - actionview (4.2.3) lib/action_view/rendering.rb:100:in `_render_template' - actionpack (4.2.3) lib/action_controller/metal/streaming.rb:217:in `_render_template' - actionview (4.2.3) lib/action_view/rendering.rb:83:in `render_to_body' - actionpack (4.2.3) lib/action_controller/metal/rendering.rb:32:in `render_to_body' - actionpack (4.2.3) lib/action_controller/metal/renderers.rb:37:in `render_to_body' - actionpack (4.2.3) lib/abstract_controller/rendering.rb:25:in `render' - actionpack (4.2.3) lib/action_controller/metal/rendering.rb:16:in `render' - actionpack (4.2.3) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render' - activesupport (4.2.3) lib/active_support/core_ext/benchmark.rb:12:in `block in ms' - /home/jakxna360/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/benchmark.rb:303:in `realtime' - activesupport (4.2.3) lib/active_support/core_ext/benchmark.rb:12:in `ms' - actionpack (4.2.3) lib/action_controller/metal/instrumentation.rb:44:in `block in render' - actionpack (4.2.3) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime' - activerecord (4.2.3) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime' - actionpack (4.2.3) lib/action_controller/metal/instrumentation.rb:43:in `render' - actionpack (4.2.3) lib/action_controller/metal/implicit_render.rb:10:in `default_render' - responders (2.1.0) lib/action_controller/responder.rb:236:in `default_render' - responders (2.1.0) lib/action_controller/responder.rb:170:in `to_html' - responders (2.1.0) lib/action_controller/responder.rb:163:in `respond' - responders (2.1.0) lib/action_controller/responder.rb:156:in `call' - responders (2.1.0) lib/action_controller/respond_with.rb:203:in `respond_with' - devise (3.5.1) app/controllers/devise/registrations_controller.rb:10:in `new' - app/controllers/registrations_controller.rb:11:in `new' - actionpack (4.2.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action' - actionpack (4.2.3) lib/abstract_controller/base.rb:198:in `process_action' - actionpack (4.2.3) lib/action_controller/metal/rendering.rb:10:in `process_action' - actionpack (4.2.3) lib/abstract_controller/callbacks.rb:20:in `block in process_action' - activesupport (4.2.3) lib/active_support/callbacks.rb:115:in `call' - activesupport (4.2.3) lib/active_support/callbacks.rb:553:in `block (2 levels) in compile' - activesupport (4.2.3) lib/active_support/callbacks.rb:503:in `call' - activesupport (4.2.3) lib/active_support/callbacks.rb:88:in `run_callbacks' - actionpack (4.2.3) lib/abstract_controller/callbacks.rb:19:in `process_action' - actionpack (4.2.3) lib/action_controller/metal/rescue.rb:29:in `process_action' - actionpack (4.2.3) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action' - activesupport (4.2.3) lib/active_support/notifications.rb:164:in `block in instrument' - activesupport (4.2.3) lib/active_support/notifications/instrumenter.rb:20:in `instrument' - activesupport (4.2.3) lib/active_support/notifications.rb:164:in `instrument' - actionpack (4.2.3) lib/action_controller/metal/instrumentation.rb:30:in `process_action' - actionpack (4.2.3) lib/action_controller/metal/params_wrapper.rb:250:in `process_action' - activerecord (4.2.3) lib/active_record/railties/controller_runtime.rb:18:in `process_action' - actionpack (4.2.3) lib/abstract_controller/base.rb:137:in `process' - actionview (4.2.3) lib/action_view/rendering.rb:30:in `process' - actionpack (4.2.3) lib/action_controller/metal.rb:196:in `dispatch' - actionpack (4.2.3) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' - actionpack (4.2.3) lib/action_controller/metal.rb:237:in `block in action' - actionpack (4.2.3) lib/action_dispatch/routing/route_set.rb:76:in `dispatch' - actionpack (4.2.3) lib/action_dispatch/routing/route_set.rb:45:in `serve' - actionpack (4.2.3) lib/action_dispatch/routing/mapper.rb:49:in `serve' - actionpack (4.2.3) lib/action_dispatch/journey/router.rb:43:in `block in serve' - actionpack (4.2.3) lib/action_dispatch/journey/router.rb:30:in `serve' - actionpack (4.2.3) lib/action_dispatch/routing/route_set.rb:821:in `call' - warden (1.2.3) lib/warden/manager.rb:35:in `block in call' - warden (1.2.3) lib/warden/manager.rb:34:in `call' - rack (1.6.4) lib/rack/etag.rb:24:in `call' - rack (1.6.4) lib/rack/conditionalget.rb:25:in `call' - rack (1.6.4) lib/rack/head.rb:13:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/params_parser.rb:27:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/flash.rb:260:in `call' - rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context' - rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/cookies.rb:560:in `call' - activerecord (4.2.3) lib/active_record/query_cache.rb:36:in `call' - activerecord (4.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' - activesupport (4.2.3) lib/active_support/callbacks.rb:84:in `run_callbacks' - actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/remote_ip.rb:78:in `call' - better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call' - better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call' - better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' - web-console (2.2.1) lib/web_console/middleware.rb:39:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' - railties (4.2.3) lib/rails/rack/logger.rb:38:in `call_app' - railties (4.2.3) lib/rails/rack/logger.rb:20:in `block in call' - activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `block in tagged' - activesupport (4.2.3) lib/active_support/tagged_logging.rb:26:in `tagged' - activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `tagged' - railties (4.2.3) lib/rails/rack/logger.rb:20:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/request_id.rb:21:in `call' - rack (1.6.4) lib/rack/methodoverride.rb:22:in `call' - rack (1.6.4) lib/rack/runtime.rb:18:in `call' - activesupport (4.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' - rack (1.6.4) lib/rack/lock.rb:17:in `call' - actionpack (4.2.3) lib/action_dispatch/middleware/static.rb:116:in `call' - rack (1.6.4) lib/rack/sendfile.rb:113:in `call' - railties (4.2.3) lib/rails/engine.rb:518:in `call' - railties (4.2.3) lib/rails/application.rb:165:in `call' - rack (1.6.4) lib/rack/urlmap.rb:66:in `block in call' - rack (1.6.4) lib/rack/urlmap.rb:50:in `call' - rack-test (0.6.3) lib/rack/mock_session.rb:30:in `request' - rack-test (0.6.3) lib/rack/test.rb:244:in `process_request' - rack-test (0.6.3) lib/rack/test.rb:58:in `get' - /home/jakxna360/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/forwardable.rb:183:in `get' - capybara (2.4.4) lib/capybara/rack_test/browser.rb:60:in `process' - capybara (2.4.4) lib/capybara/rack_test/browser.rb:35:in `process_and_follow_redirects' - capybara (2.4.4) lib/capybara/rack_test/browser.rb:21:in `visit' - capybara (2.4.4) lib/capybara/rack_test/driver.rb:42:in `visit' - capybara (2.4.4) lib/capybara/session.rb:227:in `visit' - capybara (2.4.4) lib/capybara/dsl.rb:51:in `block (2 levels) in ' - rspec-rails (3.3.3) lib/rspec/rails/example/feature_example_group.rb:28:in `visit' - spec/features/devise/registrations/new.html.haml_spec.rb:7:in `block (3 levels) in ' - rspec-core (3.3.2) lib/rspec/core/example.rb:206:in `block in run' - rspec-core (3.3.2) lib/rspec/core/example.rb:430:in `block in with_around_and_singleton_context_hooks' - rspec-core (3.3.2) lib/rspec/core/example.rb:388:in `block in with_around_example_hooks' - rspec-core (3.3.2) lib/rspec/core/hooks.rb:478:in `block in run' - rspec-core (3.3.2) lib/rspec/core/hooks.rb:618:in `block in run_around_example_hooks_for' - rspec-core (3.3.2) lib/rspec/core/example.rb:273:in `call' - rspec-rails (3.3.3) lib/rspec/rails/adapters.rb:127:in `block (2 levels) in ' - rspec-core (3.3.2) lib/rspec/core/example.rb:378:in `instance_exec' - rspec-core (3.3.2) lib/rspec/core/hooks.rb:389:in `execute_with' - rspec-core (3.3.2) lib/rspec/core/hooks.rb:620:in `block (2 levels) in run_around_example_hooks_for' - rspec-core (3.3.2) lib/rspec/core/example.rb:273:in `call' - rspec-core (3.3.2) lib/rspec/core/hooks.rb:621:in `run_around_example_hooks_for' - rspec-core (3.3.2) lib/rspec/core/hooks.rb:478:in `run' - rspec-core (3.3.2) lib/rspec/core/example.rb:388:in `with_around_example_hooks' - rspec-core (3.3.2) lib/rspec/core/example.rb:430:in `with_around_and_singleton_context_hooks' - rspec-core (3.3.2) lib/rspec/core/example.rb:203:in `run' - rspec-core (3.3.2) lib/rspec/core/example_group.rb:559:in `block in run_examples' - rspec-core (3.3.2) lib/rspec/core/example_group.rb:555:in `run_examples' - rspec-core (3.3.2) lib/rspec/core/example_group.rb:521:in `run' - rspec-core (3.3.2) lib/rspec/core/example_group.rb:522:in `block in run' - rspec-core (3.3.2) lib/rspec/core/example_group.rb:522:in `run' - rspec-core (3.3.2) lib/rspec/core/runner.rb:115:in `block (3 levels) in run_specs' - rspec-core (3.3.2) lib/rspec/core/runner.rb:115:in `block (2 levels) in run_specs' - rspec-core (3.3.2) lib/rspec/core/configuration.rb:1627:in `with_suite_hooks' - rspec-core (3.3.2) lib/rspec/core/runner.rb:114:in `block in run_specs' - rspec-core (3.3.2) lib/rspec/core/reporter.rb:77:in `report' - rspec-core (3.3.2) lib/rspec/core/runner.rb:113:in `run_specs' - rspec-core (3.3.2) lib/rspec/core/runner.rb:89:in `run' - rspec-core (3.3.2) lib/rspec/core/runner.rb:73:in `run' - rspec-core (3.3.2) lib/rspec/core/runner.rb:41:in `invoke' - rspec-core (3.3.2) exe/rspec:4:in `' - () home/jakxna360/.rvm/gems/ruby-2.2.1/bin/rspec:23:in `' - () home/jakxna360/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `'"
 # ./spec/features/devise/registrations/new.html.haml_spec.rb:8:in `block (3 levels) in <top (required)>'

所以我得到了一个sass错误但是当我访问该页面时没有错误显示...我错过了什么或者我输入了rspec / capybara错了吗?非常感谢任何帮助:)

1 个答案:

答案 0 :(得分:0)

bootstrap.scss文件中有一个错误(我正在运行一个旧版本,因此可能会在较新的版本中修复)。错误是:

Color: #ff;f
Outline: none;

我把它修改为:

Color: #fff;
Outline: none;

之后测试通过