Giter VIP home page Giter VIP logo

Comments (8)

jhnvz avatar jhnvz commented on July 4, 2024

You can setup Guard like so:

guard :alfred, :all_on_start => false do
  watch(%r{^app/controllers/(.+)\.rb$}) { |m| "spec/alfreds/#{m[1]}.rb" }
  watch(%r{^spec/alfreds/(.+)\.rb$})    { |m| "spec/alfreds/#{m[1]}.rb" }
end

from guard-alfred.

Arjeno avatar Arjeno commented on July 4, 2024

Yes you're right. How about when running all specs, it re-generates fixtures also. Is there a way to not re-generate a fixture when the controller hasn't changed or been saved?

from guard-alfred.

jhnvz avatar jhnvz commented on July 4, 2024

I think it's impossible to track all files that influence the controller response (Models, Serializers etc.) I think it would be a better solution to stub the method that generates the dynamic value:

Alred.define do
  controller SomeController do
    scenario 'foo' do
      setup do { current_user.stub(:dynamic).and_return(:static)
    end
  end
end

from guard-alfred.

Arjeno avatar Arjeno commented on July 4, 2024

I suppose. But what about timestamp values, such as created_at and updated_at? These are pretty standard in API responses. To stub those on each request would be a pain.

Could we somehow check if the fixture needs to be re-generated? Such as checking the source file, if it has changed?

from guard-alfred.

jhnvz avatar jhnvz commented on July 4, 2024

I think it's a good idea to re-render fixtures before running a whole suite. For instance when you change the behavior of String#some_method in lib/core_ext/string.rb this change could influence almost every response in your application.

from guard-alfred.

Arjeno avatar Arjeno commented on July 4, 2024

Hmm true. You're right about that. A lot of code outside of controllers can alter the response. There's no solution to that.

from guard-alfred.

jhnvz avatar jhnvz commented on July 4, 2024

Maybe we can implement a prompt for re-rendering all fixtures in the Guard::Alfred#run_all method. This method is invoked when you run the whole suite with guard. Something like 'Do you want to render all fixtures?'. I think it's pretty easy to implement with https://github.com/JEG2/highline.

from guard-alfred.

Arjeno avatar Arjeno commented on July 4, 2024

An alternative could be to simply add the fixtures folder to your .gitignore. It wouldn't matter if there are fixtures changes.

from guard-alfred.

Related Issues (1)

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.