chancancode / json_expressions

JSON matchmaking for all your API testing needs.
MIT License
414 stars 38 forks source link

undefined method `get' #9

Closed anildigital closed 11 years ago

anildigital commented 11 years ago

Getting error

 λ ruby login_test.rb 
Run options: 

# Running tests:

E

Finished tests in 0.002063s, 484.7310 tests/s, 0.0000 assertions/s.

  1) Error:
test_login(LoginTest):
NoMethodError: undefined method `get' for #<LoginTest:0x007ff23a113738>
    login_test.rb:8:in `test_login'

for this code snippet https://gist.github.com/942e43ff3c050fe4e9ce

chancancode commented 11 years ago

Hi @anildigital, this is not a json_expressions error. json_expressions does not actually provide a get method - the get method in the read me is used for illustration purposes. You will need to fetch the desired page yourself (with net/http, faraday, etc).

Sorry for the confusion! I'll make that clear in the next update.

chancancode commented 11 years ago

btw, with json_expression, your code snippet could be rewritten as...

  def test_login
    server_response = get 'http://localhost:8080/myapp-demo/mobile/login/login' # Again, bring your own http library

    pattern = {
      companyId: wildcard_matcher,
      firstName: wildcard_matcher
    }.ignore_extra_keys!

    assert_match pattern, server_response.body
  end