spockframework / spockframework/spock

XML.parse(string) on single instance results causes No such property: applicationContext for class

Open
#307 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Module-Core Type-Defect
Dominant language
Java
Stars
3.6k
Forks
483
PR merge metrics
No merged PRs in 30d

Description

Originally reported on Google Code with ID 185

1. A controller that embodies the following code:
def getById = {
  Style style = Style.get(params.id)
  render style as XML
}

2. A spec method that looks as follows:
void "get by id action returns a single style"() {
    given:
    mockParams.id = style3.id

    when:
    controller.getById()
    def xmlString = controller.response.contentAsString
    def result = XML.parse(xmlString)

    then:
    result.id == style3.id
    result.name == style3.name
    result.shortDescription == style3.shortDescription
    result.longDescription == style3.longDescription
}   



3. Causes Errors with the following stacktrace:
No such property: applicationContext for class: com.burberry.apps.catalogue.StyleControllerSpec
groovy.lang.MissingPropertyException: No such property: applicationContext for class:
com.burberry.apps.catalogue.StyleControllerSpec
    at grails.plugin.spock.UnitSpec.addConverters_closure6(UnitSpec.groovy:221)
    at com.burberry.apps.catalogue.StyleControllerSpec.get all action returns consistent
style elements(StyleControllerSpec.groovy:22)


What version of Spock and Groovy are you using?
I'm using Grails 1.3.7 with spock 0.6-SNAPSHOT

Please provide any additional information below. You can also assign
labels.
The strange thing here is that when the controller returns multiple results the XML
class has no problems parsing, this only happens when parsing single entity results.

Reported by vermeulen.mp on 2011-06-07 10:42:31

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported StyleControllerSpec reproduction and the stack trace location in UnitSpec.groovy:221. Recreate it with Grails 1.3.7 and Spock 0.6-SNAPSHOT, comparing single-entity and multiple-result XML.parse cases. Done means the single-result case no longer raises MissingPropertyException and the regression is covered by the shown spec.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.