[rspec-users] Display Rspec output in an html file

Matt Wynne matt at mattwynne.net
Mon Nov 9 16:46:30 EST 2009


On 9 Nov 2009, at 11:13, Amit Kulkarni wrote:

> Hello,
> I had written some model scenarios.
> Now i want to generate that output in an html file.
> i am executing the models using rake i.e. rake spec:models from spec
> directory.
> But the html file is not getting generated.
>
> Following is the error trace:
> ** Invoke spec:models (first_time)
> ** Invoke db:test:prepare (first_time)
> ** Invoke db:abort_if_pending_migrations (first_time)
> ** Invoke environment (first_time)
> ** Execute environment
> ** Execute db:abort_if_pending_migrations
> ** Execute db:test:prepare
> ** Invoke db:test:load (first_time)
> ** Invoke db:test:purge (first_time)
> ** Invoke environment
> ** Execute db:test:purge
> ** Execute db:test:load
> ** Invoke db:schema:load (first_time)
> ** Invoke environment
> ** Execute db:schema:load
> ** Execute spec:models
> ./spec/models/forum_spec.rb:43: warning: don't put space before  
> argument
> parentheses
> ./spec/models/forum_spec.rb:50: warning: don't put space before  
> argument
> parentheses
> #<Forum id: 3, name: "Forum2", description: "Desc", topics_count: 0,
> posts_count: 0, position: nil, description_html: "<p>Desc</p>",
> idiom_id: nil, permalink: "forum2">
> #<Poll id: nil, title: " ", published: false, channel_feature_id: nil,
> created_at: nil, updated_at: nil>
> rake aborted!
> Command /usr/local/bin/ruby
> -I"/usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib"
> "/usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.4/bin/spec"
> "spec/models/forum_spec.rb" "spec/models/attachment_spec.rb"
> "spec/models/channel_detail_spec.rb" "spec/models/whatwewant_spec.rb"
> "spec/models/channel_spec.rb" "spec/models/question_spec.rb"
> "spec/models/rating_spec.rb" "spec/models/topic_spec.rb"
> "spec/models/channel_feature_spec.rb" "spec/models/idea_spec.rb"
> "spec/models/user_channel_spec.rb" "spec/models/promotion_spec.rb"
> "spec/models/product_spec.rb" "spec/models/poll_spec.rb"
> "spec/models/bb_post_spec.rb" "spec/models/channel_category_spec.rb"
> "spec/models/survey_spec.rb" --format html:result.html failed
> /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/rake/ 
> spectask.rb:174:in
> `define'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1112:in
> `verbose'
> /usr/local/lib/ruby/gems/1.8/gems/rspec-1.2.4/lib/spec/rake/ 
> spectask.rb:150:in
> `define'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
> `execute'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
> `execute'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
> `invoke_with_call_chain'
> /usr/local/lib/ruby/1.8/monitor.rb:242:in `synchronize'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
> `invoke_with_call_chain'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in  
> `invoke'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
> `invoke_task'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
> `top_level'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in  
> `each'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
> `top_level'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
> `standard_exception_handling'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in
> `top_level'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
> `standard_exception_handling'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
> /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
> /usr/local/bin/rake:19:in `load'
> /usr/local/bin/rake:19
>
> I had tried various options:
> 1:Under lib/tasks/rspec file i had added a line
> "t.spec_opts = ['--format' , 'html:result.html' ]" under the
>
> [:models, :controllers, :views, :helpers, :lib, :integration].each do
> |sub|
>    desc "Run the code examples in spec/#{sub}"
>    Spec::Rake::SpecTask.new(sub => spec_prereq) do |t|
>      t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
>      t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
>      t.spec_opts = ['--format' , 'html:result.html' ]
>    end
>  end
> but when i run the rake command above error is generated.
>
> 2:I also tried updating spec.opts file by adding --format
> html:spec/a.html.
> After adding this code i ran the spec using rake spec:models
> RAILS_ENV=test but what i think that if we add something in spec.opts
> then running command for models is different.
>
> Please suggest how to display output in html using rake command rake
> spec:models
> -- 
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

Do you get an error message? I don't see one here.

cheers,
Matt

http://mattwynne.net
+447974 430184



More information about the rspec-users mailing list