Giter Club home page Giter Club logo

deadweight's People

Contributors

aanand avatar avdgaag avatar jamesarosen avatar mojodna avatar tadast avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deadweight's Issues

Result list not a list

Having trouble getting the result list to show as a list. Matched elements show up correctly, but when displaying the unused selectors, it displays all as 1 item strung together, plus it is showing the name of the element, and parts of the attributes - (for instance span.a might display as span.acolor: #000..... and so on) See http://pastie.org/651957 for a clip of the output I'm getting. Any ideas?

pseudo selectors :nth-child(x) and so on

I have a problem with nth-child(x) pseudo selector

Nokogiri is complaining about Invalid expresion:

nokogiri/xml/node.rb:159:in `evaluate': Invalid expression: //[@id = 'main']//[@id = 'goals']//p(., 2) (Nokogiri::XML::XPath::SyntaxError)

its all have to do with regular expression in strip method.

Why this can't be merged in?? Support more CSS3/CSS4 selectors

or if you are not happy about /:.*/ reg exp maybe something more relaxed like:
/::?[\w-]+(([1-9]+))?/
just for nth-child brackets and number??

Nokogiri parse error when hijacking rails

Hi-

I'm getting parse errors from cucumber / nokogiri (pretty much all tests failing), when trying to hijack rails and run deadweight with my cucumber test suite.

The environment is Rails 3.0.4, Ruby 1.9.2, Cucumber 1.0.2, capybara 1.0.0, nokogiri 1.4.4. I'm looking into it now, but thought I'd post in case there were any easy fixes I should look at:

unexpected '$' after 'DESCENDANT_SELECTOR' (Nokogiri::CSS::SyntaxError)
/Users/arun/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/racc/parser.rb:99:in `_racc_do_parse_c'
/Users/arun/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/racc/parser.rb:99:in `do_parse'
./features/step_definitions/web_steps.rb:20:in `/^(?:|I )am on (.+)$/'
features/registration/register_account.feature:26:in `Given I am on the registration page'

HTTP Basic Authentication

Hello.
Thank you for this gemful gem.

One question. How can I login to the hidden sections of the site behind authenticate_or_request_with_http_basic?

Thank you.

deadweight finds zero selectors when using rspec

Deadweight works as expected when I run it as a rake task. However, when I try to run it with rspec, it finds no selectors:

$ DEADWEIGHT=true rspec spec/features/surveys_index_spec.rb
No DRb server is running. Running in local process instead ...

found 0 unused selectors out of 0 total

Is there some way to make this work? Piggybacking on integration tests seems way better than trying to manually specify every page of my site.

Something in w3.org's CSS is breaking Deadweight

/Users/aanand/.rvm/gems/ruby-1.9.2-p136/gems/nokogiri-1.4.4/lib/nokogiri/xml/node.rb:158:in `evaluate': Invalid expression: //*[contains(concat(' ', @class, ' '), ' data ')]//tbody//tr(., #) (Nokogiri::XML::XPath::SyntaxError)
    from /Users/aanand/.rvm/gems/ruby-1.9.2-p136/gems/nokogiri-1.4.4/lib/nokogiri/xml/node.rb:158:in `block in xpath'
    from /Users/aanand/.rvm/gems/ruby-1.9.2-p136/gems/nokogiri-1.4.4/lib/nokogiri/xml/node.rb:150:in `map'
    from /Users/aanand/.rvm/gems/ruby-1.9.2-p136/gems/nokogiri-1.4.4/lib/nokogiri/xml/node.rb:150:in `xpath'
    from /Users/aanand/.rvm/gems/ruby-1.9.2-p136/gems/nokogiri-1.4.4/lib/nokogiri/xml/node.rb:111:in `search'
    from /Users/aanand/src/deadweight/lib/deadweight.rb:42:in `block in analyze'
    from /Users/aanand/src/deadweight/lib/deadweight.rb:39:in `collect'
    from /Users/aanand/src/deadweight/lib/deadweight.rb:39:in `analyze'
    from /Users/aanand/src/deadweight/lib/deadweight.rb:133:in `process!'
    from /Users/aanand/src/deadweight/lib/deadweight.rb:120:in `block in run'
    from /Users/aanand/src/deadweight/lib/deadweight.rb:97:in `each'
    from /Users/aanand/src/deadweight/lib/deadweight.rb:97:in `run'
    from /Users/aanand/src/deadweight/lib/deadweight/cli.rb:113:in `process'
    from /Users/aanand/src/deadweight/lib/deadweight/cli.rb:88:in `execute!'
    from /Users/aanand/src/deadweight/lib/deadweight/cli.rb:19:in `execute'
    from bin/deadweight:4:in `'

Getting Error 'block in <top (required)>'

I am using Ubuntu, I did all required configuration, still getting Error while running 'rake deathweight'

Error :-

WARN -- : ** [Bugsnag] No API key configured, couldn't notify
rake aborted!
EOFError: end of file reached
/home/saurabh/.rvm/gems/ruby-2.2.0-preview1@luxola/gems/deadweight-0.2.2/lib/deadweight.rb:161:in fetch' /home/saurabh/.rvm/gems/ruby-2.2.0-preview1@luxola/gems/deadweight-0.2.2/lib/deadweight.rb:72:inblock in reset!'
/home/saurabh/.rvm/gems/ruby-2.2.0-preview1@luxola/gems/deadweight-0.2.2/lib/deadweight.rb:71:in each' /home/saurabh/.rvm/gems/ruby-2.2.0-preview1@luxola/gems/deadweight-0.2.2/lib/deadweight.rb:71:inreset!'
/home/saurabh/.rvm/gems/ruby-2.2.0-preview1@luxola/gems/deadweight-0.2.2/lib/deadweight.rb:93:in run' /home/saurabh/luxola/lib/tasks/deadweight.rake:8:inblock in <top (required)>'
/home/saurabh/.rvm/gems/ruby-2.2.0-preview1@luxola/gems/bugsnag-2.7.1/lib/bugsnag/rake.rb:36:in block in bugsnag_define_task' /home/saurabh/.rvm/gems/ruby-2.2.0-preview1@luxola/bin/ruby_executable_hooks:15:ineval'
/home/saurabh/.rvm/gems/ruby-2.2.0-preview1@luxola/bin/ruby_executable_hooks:15:in `

'
Tasks: TOP => deadweight
(See full trace by running task with --trace)

Testing Workflow?

I think that this is an excellent gem and a fantastic idea; especially for static sites.

Unfortunately when you have to deal with multiple user login types that can see certain pages but not others, you would seem to be recreating a bunch of that logic in deadweight configurations which is also in your tests. And what if you add a page? Now you have to remember to add it to your Deadweight configurations.

After a few minutes of thinking about it, here's the implementation that I thought might be valuable:

In Cucumber's before all run:

Deadweight.start

In Cucumber's after all section:

Deadweight.stop

It will keep track of all CSS being used by every page load that Cucumber performs. Since us Ruby folk are typically test-crazy, this should hit all the possible scenarios that the app/site would go through.

This would include flash error messages, form error messages, etc which would almost never get caught by a standard page load.

By default it drops a file called deadweight.log in the tmp directory of the app.

There are tons of possibilities of creating formatters... maybe an HTML format that shows all the styles in their styles for easy reference.

I'm fully prepared to help out so let me know what you think.

This is very interesting. But...

Seems to me that it would be much more useful with a couple of changes/additions.

First, I would like it to use the rails testing get/post stuff instead of having to go to a web server to fetch pages.

Second, I would like it to find the css files by looking at what css files the page is including.

Third, I am sort of thinking that I want to be able to just pipe html into this tool rather than have it get the page.

Fourth, I don't want to create a rake task to do this, I want to put it into an integration test. Then I can run it in my cruisecontrol.rb easily, and have it notify developers after making a change and running tests.

I would be happy to contribute, but I was not sure if I should fork it or if you have some way of letting people contribute.

Please let me know if there is something I can do.

Doesn't look past 'yield'

Using dw.pages to set Deadweight to look at just one page, it's clear that it doesn't look past 'yield'. It found the CSS tags in a partial, but not in the template yielded to in the layout.

unexpected '$' after 'CHILD_SELECTOR' (Nokogiri::CSS::SyntaxError)

How do I debug this?

/Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/nokogiri-1.6.2.1/lib/nokogiri/css/parser_extras.rb:87:in `on_error': unexpected '$' after 'CHILD_SELECTOR' (Nokogiri::CSS::SyntaxError)
    from /Users/benwoodward/.rbenv/versions/2.1.2/lib/ruby/2.1.0/racc/parser.rb:258:in `_racc_do_parse_c'
    from /Users/benwoodward/.rbenv/versions/2.1.2/lib/ruby/2.1.0/racc/parser.rb:258:in `do_parse'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/nokogiri-1.6.2.1/lib/nokogiri/css/parser_extras.rb:62:in `parse'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/nokogiri-1.6.2.1/lib/nokogiri/css/parser_extras.rb:79:in `xpath_for'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/nokogiri-1.6.2.1/lib/nokogiri/css.rb:23:in `xpath_for'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/nokogiri-1.6.2.1/lib/nokogiri/xml/node.rb:106:in `block in search'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/nokogiri-1.6.2.1/lib/nokogiri/xml/node.rb:104:in `map'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/nokogiri-1.6.2.1/lib/nokogiri/xml/node.rb:104:in `search'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/deadweight-0.2.2/lib/deadweight.rb:40:in `block in analyze'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/deadweight-0.2.2/lib/deadweight.rb:33:in `collect'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/deadweight-0.2.2/lib/deadweight.rb:33:in `analyze'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/deadweight-0.2.2/lib/deadweight.rb:131:in `process!'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/deadweight-0.2.2/lib/deadweight.rb:118:in `block in run'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/deadweight-0.2.2/lib/deadweight.rb:95:in `each'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/deadweight-0.2.2/lib/deadweight.rb:95:in `run'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/deadweight-0.2.2/lib/deadweight/cli.rb:113:in `process'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/deadweight-0.2.2/lib/deadweight/cli.rb:88:in `execute!'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/deadweight-0.2.2/lib/deadweight/cli.rb:19:in `execute'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/gems/deadweight-0.2.2/bin/deadweight:4:in `<top (required)>'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/bin/deadweight:23:in `load'
    from /Users/benwoodward/.rbenv/versions/2.1.2/gemsets/global/bin/deadweight:23:in `<main>'

Nokogiri selector error

The following test produces Nokogiri selector errors using deadweight 0.2.1:

dw = Deadweight.new
dw.root = "http://seeclickint.com"  #  Integration server
dw.stylesheets = ["/stylesheets/base_packaged.css"]
dw.pages = ["/citizens"]
puts dw.run

I'm new to the tool. Is there something I'm doing wrong?

Thank you

Browsers insert a <tbody>, but Deadweight does not

Given the following HTML

<table class="foo">
  <tr>
    <td>Some Foo data</td>
  </tr>
</table>

and the following CSS

table.foo tbody tr td {
  color: green;
}

browsers will insert a virtual <tbody> and apply the rule. Deadweight should also insert this element so it acts like browsers do.

How to use this in Turnip (instead of Cucumber)?

Your gem looks very promising. Sadly it doesn't seem to do anything when using Turnip instead of Cucumber, although it gives some output:

rake spec DEADWEIGHT=true
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
/Users/josh/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -S rspec ./spec/acceptance/members/confirm_registration.feature ./spec/acceptance/members/member_edit.feature ./spec/acceptance/members/member_show.feature ./spec/acceptance/members/sign_in.feature ./spec/acceptance/members/sign_out.feature ./spec/acceptance/members/sign_up.feature ./spec/cells/mini_hub_cell_spec.rb ./spec/controllers/dashboards_controller_spec.rb ./spec/models/member_spec.rb ./spec/routing/members_routing_spec.rb

found 0 unused selectors out of 0 total

The specs are successfully run, and I added some unused CSS selectors to my code so Deadweight could find them, but nothing happens.

Any hint on how to debug this? I have activated @js, @chrome and @selenium for some of the feature tests, so the CSS is definitely compiled and available.

Thanks for help.

Ignores @import url CSS

If presented with @import url(), deadweight ignores the given stylesheets. Example:

@import url(reset.css);

Deadweight will not read the styles from reset.css

Error in xpath query when using dynamic fonts

src: url('/webfonts/eot/style_190749.eot?#iefix') format('embedded-opentype'), url('/webfonts/woff/style_190749.woff') format('woff'), url('/webfonts/ttf/style_190749.ttf') format('truetype'), url('/webfonts/svg/style_190749.svg#Livory-Regular') format('svg');

causes:

/Users/ryan/.gem/sandboxes/deadweight/gems/nokogiri-1.5.5/lib/nokogiri/xml/node.rb:159:in `evaluate': Invalid expression: //svg(.) (Nokogiri::XML::XPath::SyntaxError)
    from /Users/ryan/.gem/sandboxes/deadweight/gems/nokogiri-1.5.5/lib/nokogiri/xml/node.rb:159:in `xpath'
    from /Users/ryan/.gem/sandboxes/deadweight/gems/nokogiri-1.5.5/lib/nokogiri/xml/node.rb:150:in `map'
    from /Users/ryan/.gem/sandboxes/deadweight/gems/nokogiri-1.5.5/lib/nokogiri/xml/node.rb:150:in `xpath'
    from /Users/ryan/.gem/sandboxes/deadweight/gems/nokogiri-1.5.5/lib/nokogiri/xml/node.rb:111:in `search'
    from /Users/ryan/.gem/sandboxes/deadweight/gems/deadweight-0.2.1/lib/deadweight.rb:42:in `analyze'
...

Support for Rails 2.3.x?

At my office we're late to the Rails 3 party. Is there an easy way to use the hijack/rails thing with Rails 2?

Any help (even just some hints) would be greatly appreciated.
Thanks!

Weird behavior when nokogiri fails (deadweight not failing when it should as well)

Earlier, I was trying to troubleshoot an issue with rake deadweight, which turns out to be related to: sparklemotion/nokogiri#581 - There was indeed a css file (normalize.css) that happens to fail nokogiri parsing, likely with the following block:

1.9.3p194 :004 > Nokogiri::CSS.parse "audio:not([controls]) { display: none; }"
Nokogiri::CSS::SyntaxError: unexpected '{' after 'DESCENDANT_SELECTOR'
    from /home/prusswan/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/lib/nokogiri/css/parser_extras.rb:87:in `on_error'
    from (eval):3:in `_racc_do_parse_c'
    from (eval):3:in `do_parse'
    from /home/prusswan/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/lib/nokogiri/css/parser_extras.rb:62:in `parse'
    from /home/prusswan/.rvm/gems/ruby-1.9.3-p194/gems/nokogiri-1.5.5/lib/nokogiri/css.rb:17:in `parse'
    from (irb):4
    from /home/prusswan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
    from /home/prusswan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
    from /home/prusswan/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

The issue I am reporting here however, is sort of a false-positive when certain configurations allow rake deadweight to execute without the parsing error (despite the issue above), as shown below:

** Invoke deadweight (first_time)
** Execute deadweight
/assets/application.css
  found 175 selectors
/assets/normalize.css
  found 0 selectors
/assets/layout.css
  found 0 selectors
/assets/sidebar.css
  found 0 selectors
/assets/navigation.css
  found 0 selectors
/assets/notifications.css
  found 0 selectors
/assets/creations.css
  found 0 selectors

/creations/index
retrieving http://localhost:3000/creations/index raised an HTTP error: 404 Not Found

/creations/1
retrieving http://localhost:3000/creations/1 raised an HTTP error: 500 Internal Server Error

found 175 unused selectors out of 175 total

Those HTTP errors are normal because the views happen to be incomplete, but the selectors found messages seem to disregard the parsing error and only pick up selectors from application.css.

Deprecated warning for line 7 of css_parser.rb file

Getting a deprecated warning for this css_parser.rb file. Here is the message:

$HOME/.rvm/gems/ruby-1.9.3-p194@rails326/gems/deadweight-0.2.1/vendor/gems/css_parser-1.1.5/lib/css_parser.rb:7:in `<top (required)>': iconv will be deprecated in the future, use String#encode instead.

Could not find a valid gem 'aanand-deadweight'

FYI: Ryan's Railscast has

sudo gem install aanand-deadweight

but I get

ERROR:  Could not find a valid gem 'aanand-deadweight' (>= 0) in any repository

So could you add install instructions? This is what worked for me

sudo gem install deadweight

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.