W konsoli próbuję coś takiego:
ruby-1.9.2-p290 :022 > c.login
I, [2012-02-15T23:12:09.681772 #12908] INFO -- : post https://www.soup.io/login
D, [2012-02-15T23:12:09.681854 #12908] DEBUG -- request: Content-Type: "application/x-www-form-urlencoded"
I, [2012-02-15T23:12:10.157908 #12908] INFO -- Status: 302
D, [2012-02-15T23:12:10.158054 #12908] DEBUG -- response: server: "nginx/0.7.67"
...
content-length: "94"
status: "302"
...
content-length: "0"
status: "302"
I, [2012-02-15T23:12:10.262702 #12908] INFO -- : get http://soup-client.soup.io/?sessid=995f610405f8afe029b9038da6c22132
...
status: "200"
vary: "Accept-Encoding"
content-length: "16024"
A następnie:
ruby-1.9.2-p290 :025 > c.login["status"]
...
status: "200"
vary: "Accept-Encoding"
content-length: "15700"
NoMethodError: undefined method `[]' for nil:NilClass
from (irb):25
from /home/rege/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>'
Jak sprawdzić w takim razie status z tej odpowiedzi??
Metoda login poniżej :
def login
post = { login: @login, password: @password, commit: 'Log in' }
get_session_id(@agent.post('/login', post))
get_session_id(@agent.get(redirect_session))
end