ruby on rails - Why is RSpec giving "Attempt to unlock a mutex which is not locked" error when attempting to click_button? -
I am trying to test the links that should be seen / not logged in, but the RSPEC Throwing error:
Failure / Error: first {sign_in user} ThreadError: 2 :: `click_button '# ./spec/support/utilities in a mutex which is not blocked # (eval ) Attempt to unlock .rb: 5: `sign_in '# ./spec/views/header_spec.rb: 19: in` block (3 level) & lt; Top (required) & gt; My test block looks like this:
Describe "when signed in" (user :) {FactoryGirl.create (: user)} First {sign_in user} should {have_link} ("sign out")} {should_not has_link ("sign up")} {should_not has_link ("sign in")} end And my sign_in function:
def sign_in (user) click_link FILL_IN "username" "with", with: "password" FILL_IN user.username, with: user.password click_button "Sign me in!" Cookies [: remember_ Token] = user.remember_token end I tried to change it
click_button "Login me!" with
(find the button: "Log me!"). Click and in the following error:
Note: After '[# & lt; Nokogiri :: CSS :: Node: 0x00000003645778 @ type =: DESCENDANT_SELECTOR, @value = [# & LT; Nokogiri :: CSS :: Node: 0x000000036464e8 @ type =: ELEMENT_NAME, @value = ["log"]>, # & lt; Nokogiri :: CSS :: Node: 0x000000036458b8 @ type =: DESCENDANT_SELECTOR, @value = [# & LT; Nokogiri :: CSS :: Node: 0x00000003645f98 @ type =: ELEMENT_NAME, @value = ["me"]], # & lt; Nokogiri :: CSS :: Node: 0x000000036459f8 @ type =: ELEMENT_NAME, @value = ["in"]> gt]] gt;]] # (eval): 3: `_racc_do_parse_c '# (eval ): 3: in `two-parse '# (eval): 2: in' search '# ./spec/support/utilities.rbitter:in` sign_in' # ./spec/views/header_spec RB: 19: `Block (level 3) & lt; Top (required) & gt; Then I tried to change my button text with "exclamation me" without an exclamation point, and Capepara throws Element Notfoud error: < Pre> Failure / Error: {sign_in user} CAPBARA :: Element notofted: CSS "I LOG IN" "Unable to find # (aval): 2: Find '#' in ./spec/support/utilities .rbitter: in `sign_in '# ./spec/views/header_spec.rb:19:in' at the top (block) (3 levels) & lt; Top (required) & gt; I am still quite new to RSPC and Rail, but I have so far been successful in finding my way very well. It has stumped me completely.
Then after closing a bit last night, I finally found the solution and immediately began to face . I am using sessions with my session controller, and I included my included statement outside the classroom: Include sessions in session Class session session controller & lt; ApplicationController def new end ... ... end By transferring the statement contained within the class:
Class session controller & lt; ApplicationController sessions include Helper DEF new end ... ... ... end All my tests begin to pass. While my tests were unsuccessful with the statements contained outside the class block, the actual functionality was working fine. I can sign in / out, the cookie was being stored with the right information, and I did not get any errors in the server console.
Comments
Post a Comment