Rspec Testing issues -- Beginner Coder and not sure where to start in troubleshooting this.

45 views
Skip to first unread message

Shawn Wilson

unread,
Mar 22, 2015, 2:02:13 PM3/22/15
to rubyonra...@googlegroups.com
Im a noob to ROR and programming in general. i know enough to be dangerous but not enough to figure out where the hell i'm going wrong here.  so this is what ive done so far. 

- wrote test: 
- tried to run test to enter text into 2 string fields (see below for errors)

thanks for your help with this!  

Testing with Rspec and Capybara

Testing Code used to run: 

require 'spec_helper'

describe "Create User lists" do
    it "redirects to the users list index page on success" do
        visit "/users"
        click_link "New User"
        expect(page).to have_content("New User")
        
        fill_in "First_Name", with: "Shawn"
        fill_in "Last_Name", with: "Wilson"
        click_button "Create User"
        
        expect(page).to have_content("Shawn")
        end
    end

error returned to console when run: 

Shawns-MacBook-Pro:SafeReporAPP TaurenLTD1$ bin/rspec spec/features/users/create_spec.rb
F

Failures:

  1) Create User lists redirects to the users list index page on success
     Failure/Error: fill_in "First_Name", with: "Shawn"
     Capybara::ElementNotFound:
       Unable to find field "First_Name"
     # ./spec/features/users/create_spec.rb:9:in `block (2 levels) in <top (required)>'

Deprecation Warnings:

--------------------------------------------------------------------------------
RSpec::Core::ExampleGroup#example is deprecated and will be removed
in RSpec 3. There are a few options for what you can use instead:

  - rspec-core's DSL methods (`it`, `before`, `after`, `let`, `subject`, etc)
    now yield the example as a block argument, and that is the recommended
    way to access the current example from those contexts.
  - The current example is now exposed via `RSpec.current_example`,
    which is accessible from any context.
  - If you can't update the code at this call site (e.g. because it is in
    an extension gem), you can use this snippet to continue making this
    method available in RSpec 2.99 and RSpec 3:

      RSpec.configure do |c|
        c.expose_current_running_example_as :example
      end

(Called from /Users/TaurenLTD1/.rvm/gems/ruby-2.2.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:20:in `block (2 levels) in <top (required)>')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
RSpec::Core::ExampleGroup#example is deprecated and will be removed
in RSpec 3. There are a few options for what you can use instead:

  - rspec-core's DSL methods (`it`, `before`, `after`, `let`, `subject`, etc)
    now yield the example as a block argument, and that is the recommended
    way to access the current example from those contexts.
  - The current example is now exposed via `RSpec.current_example`,
    which is accessible from any context.
  - If you can't update the code at this call site (e.g. because it is in
    an extension gem), you can use this snippet to continue making this
    method available in RSpec 2.99 and RSpec 3:

      RSpec.configure do |c|
        c.expose_current_running_example_as :example
      end

(Called from /Users/TaurenLTD1/.rvm/gems/ruby-2.2.0/gems/capybara-2.1.0/lib/capybara/rspec.rb:21:in `block (2 levels) in <top (required)>')
--------------------------------------------------------------------------------


If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
`config.raise_errors_for_deprecations!`, and it will turn the
deprecation warnings into errors, giving you the full backtrace.

2 deprecation warnings total

Finished in 0.06536 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/features/users/create_spec.rb:4 # Create User lists redirects to the users list index page on success

Randomized with seed 27327

Hassan Schroeder

unread,
Mar 22, 2015, 4:36:25 PM3/22/15
to rubyonrails-talk
On Sun, Mar 22, 2015 at 9:41 AM, Shawn Wilson <sbwil...@gmail.com> wrote:

> 1) Create User lists redirects to the users list index page on success
> Failure/Error: fill_in "First_Name", with: "Shawn"
> Capybara::ElementNotFound:
> Unable to find field "First_Name"

The message seems pretty straightforward: are you absolutely sure
that "First_Name" is a label on the page? I would normally expect
human-readable text like e.g. "First name".

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Consulting Availability : Silicon Valley or remote

dasibre

unread,
Mar 23, 2015, 1:00:01 PM3/23/15
to rubyonra...@googlegroups.com
Can you passte your html/view code???

bacrossland

unread,
Mar 24, 2015, 10:28:46 AM3/24/15
to rubyonra...@googlegroups.com
Hassan is correct. I would check the value used in the name property of the field. First_Name is not the same as first_name. 
Reply all
Reply to author
Forward
0 new messages