Skip to content
Browse files

set request options on frill rspec helper

  • Loading branch information...
1 parent 5c00705 commit 15cceac1bfc141a8f32e92f778cfe37d578b9108 @moonmaster9000 committed Sep 4, 2012
Showing with 20 additions and 8 deletions.
  1. +3 −3 lib/frill/rspec.rb
  2. +8 −2 readme.markdown
  3. +9 −3 test_frill_rails/spec/frills/bold_title_frill_spec.rb
View
6 lib/frill/rspec.rb
@@ -1,9 +1,9 @@
module Frill
module RSpec
module Helpers
- def frill model
+ def frill model, options={}
view_context = ApplicationController.new.view_context.tap do |context|
- context.controller.request ||= ActionController::TestRequest.new
+ context.controller.request ||= ActionController::TestRequest.new options
context.request ||= context.controller.request
context.params ||= {}
end
@@ -29,4 +29,4 @@ def self.included(base)
config.include Frill::RSpec::ExampleGroup, :type => :frill, :example_group => {
:file_path => /spec[\\\/]frills/
}
-end
+end
View
10 readme.markdown
@@ -294,9 +294,15 @@ describe HtmlTimestampFrill do
end.new
end
- subject { frill model }
+ context "html request" do
+ subject { frill model }
+ its(:created_at) { should == "<b>January 01, 2012 00:00<b>" }
+ end
- its(:created_at) { should == "<b>January 01, 2012 00:00<b>" }
+ context "non-html request" do
+ subject { frill model, "HTTP_ACCEPT" => "application/json" }
+ its(:created_at) { should == "January 01, 2012 00:00" }
+ end
end
```
View
12 test_frill_rails/spec/frills/bold_title_frill_spec.rb
@@ -7,7 +7,13 @@ def title; "foo"; end
end.new
}
- subject { frill model }
+ context "html request" do
+ subject { frill model }
+ its(:title) { should == "<b>Decorated foo is Pretty http://test.host/</b>" }
+ end
- its(:title) { should == "<b>Decorated foo is Pretty http://test.host/</b>" }
-end
+ context "json request" do
+ subject { frill model, "HTTP_ACCEPT" => "application/json" }
+ its(:title) { should == "Decorated foo is Pretty" }
+ end
+end

0 comments on commit 15cceac

Please sign in to comment.
Something went wrong with that request. Please try again.