On Mar 25, 1:50 pm, Phillip Koebbe <phillipkoe...@gmail.com> wrote: > Right after I sent that message, I discovered I could set a variable > before the initial describe statement and reuse it. This works: > > base_path = 'web/admin/merchants' > describe "#{base_path}/show.html.haml" do > ... > partial_path = call_some_method(:details, base_path) > ... > end > > But I'd really rather have the value coming from somewhere else. This > method depends on me creating a variable, which I don't like.
On Mar 25, 1:50 pm, Phillip Koebbe <phillipkoe...@gmail.com> wrote: > Right after I sent that message, I discovered I could set a variable > before the initial describe statement and reuse it. This works: > > base_path = 'web/admin/merchants' > describe "#{base_path}/show.html.haml" do > ... > partial_path = call_some_method(:details, base_path) > ... > end > > But I'd really rather have the value coming from somewhere else. This > method depends on me creating a variable, which I don't like. I've been looking over the available methods and I discovered that I can get the base path via File.dirname(self.description) That got me thinking about various things, and I eventually wound up adding before {ensure_that_base_view_path_is_set_correctly} def ensure_that_base_view_path_is_set_correctly @controller.template.base_path = File.dirname(self.class.description) end to lib/spec/rails/example/view_example_group.rb This accomplishes what I want, but I seriously doubt it is the right thing to do, so I created a ticket: https://rspec.lighthouseapp.com/projects/5645-rspec/tickets/973-templatebase_path-returns-nil-in-view-spec Phillip _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users