Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reimplement subject_attributes #9

Open
hosh opened this issue Apr 23, 2010 · 3 comments
Open

Reimplement subject_attributes #9

hosh opened this issue Apr 23, 2010 · 3 comments
Labels

Comments

@hosh
Copy link
Contributor

hosh commented Apr 23, 2010

Remarkable 3.3:

describe Post do
  subject_attributes { :title => "Post" }
  describe :title => "New Post" do
    it { should do_something }
  end
end

This does not exist in Remarkable 4.0.0.alpha1. Rspec2 has a metadata system that lets you do this:

describe Post, :extra_fields => whatever do
describe "when pending", :pending => true
end

describe "when focused", :focus => true
end

end

So there is some conflict with this system. At the minimum, subject_attributes would have to be implemented through metadata.

I've cut this out from Remarkable::ActiveRecord, but I'm noticing this is the heart of the Remarkable::Rails macros.

So folks, suggestions from people who use these features are definitely welcomed.

@hosh
Copy link
Contributor Author

hosh commented Apr 23, 2010

I think I found a solution. Instead of trying to override describe, I think introducing a new example-group level semantics would work:

describe Post do
  with_attributes :published => true do
    it { should act_in_a_different_way }
  end
end

While it adds to the namespace, I think that was where Rspec2 was going, with the pending example groups and metadata.

@justinko
Copy link

I like this much much better. I never used describe :title => 'Blah' because it felt dirty to use a method that overrides an RSpec core method.

I would, however, use with_attributes.

@hosh
Copy link
Contributor Author

hosh commented Jun 16, 2010

I've been playing with something like this with using only let() and Rspec2 metadata with Rack-level specs. https://gist.github.com/741657dae42ae9706672 It works pretty well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants