Search Results

Search found 177 results on 8 pages for 'bdd'.

Page 4/8 | < Previous Page | 1 2 3 4 5 6 7 8  | Next Page >

  • Testing a scoped find in a Rails controller with RSpec

    - by Joseph DelCioppio
    I've got a controller called SolutionsController whose index action is different depending on the value of params[:user_id]. If its nil, then it simply displays all of the solutions on my site, but if its not nil, then it displays all of the solutions for the given user id. Here it is: def index if(params[:user_id]) @solutions = @user.solutions.find(:all) else @solutions = Solution.find(:all) end end and @user is determined like this: private def load_user if(params[:user_id ]) @user = User.find(params[:user_id]) end end I've got an Rspec test to test the index action if the user is nil: describe "GET index" do context "when user_id is nil" do it "should find all of the solutions" do Solution.should_receive(:find).with(:all).and_return(@solutions) get :index end end end however, can someone tell me how I write a similar test for the other half of my controller, when the user id isn't nil? Something like: describe "GET index" do context "when user_id isn't nil" do before(:each) do @user = Factory.create(:user) @solutions = 7.times{Factory.build(:solution, :user => @user)} @user.stub!(:solutions).and_return(@solutions) end it "should find all of the solutions owned by a user" do @user.should_receive(:solutions).and_return(@solutions) get :index, :user_id => @user.id end end end But that doesn't work. Can someone help me out? Joe

    Read the article

  • how to test or describe endless possibilities?

    - by koen
    Example class in pseudocode: class SumCalculator method calculate(int1, int2) returns int What is a good way to test this? In other words how should I describe the behavior I need? test1: canDetermineSumOfTwoIntegers or test2: returnsSumOfTwoIntegers or test3: knowsFivePlusThreeIsEight Test1 and Test2 seem vague and it would need to test a specific calculation, so it doesn't really describe what is being tested. Yet test3 is very limited. What is a good way to test such classes?

    Read the article

  • Cucumber and Silverlight 4

    - by weijiajun
    So I am wondering if anyone is familiar or has done any work with cucumber and Silverlight. I currently have a template directory and build file that will create RSpec tests using Bacon (light weight RSpec). I have been looking into SpecFlow and Cuke2Nuke but almost everything I have seen works with general .net code not silverlight code. Thanks.

    Read the article

  • Cucumber : Size of features

    - by David Lyod
    Im new to testing with cucumber and have a question regarding the size of a 'Feature'. Assume you can add a collection of items to a list and do the usual CRUD , is it preferred to create one feature for this complete set of CRUD actions or a feature for each? What is the preferred/accepted method ? At what point does an action become a feature itself ?

    Read the article

  • Checking ActiveRecord Associations in RSpec.

    - by alokswain
    I am learning how to write test cases using Rspec. I have a simple Post Comments Scaffold where a Post can have many Comments. I am testing this using Rspec. How should i go about checking for Post :has_many :comments. Should I stub Post.comments method and then check this with by returning a mock object of array of comment objects? Is testing for AR associations really required ?

    Read the article

  • Trouble mocking on cucumber + rails

    - by Lucas d. Prim
    I'm having a lot of trouble trying to define a mock for a rails models on cucumber. It seems like the method is creating a bunch of message expectations and i keep getting errors like these: Given I have only a product named "Sushi de Pato" # features/step_definitions/product_ steps.rb:19 unexpected invocation: #<Mock:ProductCategory_1001>.__mock_proxy() unsatisfied expectations: - expected exactly once, not yet invoked: #<Mock:ProductCategory_1001>.errors(any_pa rameters) - expected exactly once, not yet invoked: #<Mock:ProductCategory_1001>.id(any_parame ters) - expected exactly once, not yet invoked: #<Mock:ProductCategory_1001>.to_param(any_ parameters) - expected exactly once, not yet invoked: #<Mock:ProductCategory_1001>.new_record?(a ny_parameters) - expected exactly once, not yet invoked: #<Mock:ProductCategory_1001>.destroyed?(an y_parameters) satisfied expectations: - allowed any number of times, not yet invoked: #<Mock:errors>.count(any_parameters) (Mocha::ExpectationError) I haven't yet implemented the ProductCategory class and I just want it to return an ID and a 'name' attribute. This is my step definition: Given /^I have only a product named "([^\"]*)"$/ do |name| @product = Product.create!(:name => name, :description => 'Foo', :price => 100, :points => 100, :category => mock_model(ProductCategory)) end And this is my env.rb file: $: << File.join(File.dirname(__FILE__),"..") require 'spec\spec_helper I am using RSPec 1.3.0, cucumber 0.6.3 and webrat 0.7.0 I've tried to use stubs as well but got some other errors instead...

    Read the article

  • Writing a spec for helper with Ruby on Rails and RSpec

    - by TK
    I have been writing specs for controllers and models, but I have never written a helper spec. I have no idea where I start. I have the following snippet in application_helper.rb def title(page_title) content_for(:title) { page_title } end How should I write a helper spec on the code? Also if there's any open-source Rails app to show good helper testing/specing, do let me know.

    Read the article

  • How to run SpecFlow tests in Visual Studio 2010?

    - by testerboy
    Trying to get SpecFlow running with a fresh VS2010 Professional install. Created a new console application and added references to NUnit and SpecFlow. Created a SpecFlow feature. The .feature with the default template code is created. Now I try to run this test, but I don't understand how. When I right-click the project (at the top-level), there is no "Run test(s)" option in the mouse drop down menu. Didn't the SpecFlow install correctly, am I missing some references or some other tool I need to install?

    Read the article

  • Default Values Specflow Step Definitions

    - by Gavin Osborn
    I'm starting out in the world of SpecFlow and I have come across my first problem. In terms of keeping my code DRY I'd like to do the following: Have two scenarios: Given I am on a product page And myfield equals todays date Then... Given I am on a product page And myfield equals todays date plus 4 days Then... I was hoping to use the following Step Definition to cover both variants of my And clause: [Given(@"myfield equals todays date(?: (plus|minus) (\d+) days)?")] public void MyfieldEqualsTodaysDate(string direction, int? days) { //do stuff } However I keep getting exceptions when SpecFlow tries to parse the int? param. I've checked the regular expression and it definitely parses the scenario as expected. I'm aware that I could so something as crude as method overloading etc, I was just wondering if SpecFlow supported the idea of default parameter values, or indeed another way to achieve the same effect. Many Thanks

    Read the article

  • How can I test a form that requires the entry of two random characters from a security phrase?

    - by lawm
    I need to test a two-stage login system which first asks for your email address and password and then presents the user with two select lists containing [a-zA-Z0-9]. The labels beside the drop down's are of the form 'Select character X from your security phrase', where X is a random character index from a known security phrase. I'd rather not stub the code for an acceptance test, so is it possible to write a matcher in cucumber which will, given that we know the whole phrase, select the required character in each of the two lists? Here is the scenario I have so far and the steps involved: Scenario: valid login email, password and secret phrase takes me to the dashboard Given I am not logged in When I log in as "[email protected]" Then I should be on the dashboard page And I should see "Your Dashboard" When /^I log in as "([^\"]*)"$/ do |login| visit path_to('Login page') fill_in "Email", :with => login fill_in "Password", :with => "Password123" click_button "Log in" response.should contain("Please verify some characters from your security phrase") select "a", :from => "Select character X of your security phrase" select "b", :from => "Select character Y of your security phrase" click_button "Submit" end For example, if the security phrase is 'Secret123', X = 3 and Y = 8, the above would have to produce the equivalent of: select "c", :from => "Select character 3 of your security phrase" select "2", :from => "Select character 8 of your security phrase" The numbers X and Y in the actual page are inside span#svc_1 and span#svc_2 respectively. Thanks,

    Read the article

  • finding download box element with capybara in cucumber test

    - by a5his
    Hi, I have a link that downloads a file. As I click the link it displays dialog box with "save" and "open" option and "Cancel" and "OK" button. I want to find "OK" and "Cancel" button for cucumber test. I took help from below link but didn't helped much. How to test a confirm dialog with Cucumber? **features code** And I want to click "OK" **steps code** Then /^I want to click "([^\"]*)"$/ do |option| retval = (option == "OK") ? "true" : "false" page.evaluate_script('window.confirm = function() { return true; }') page.click("OK") end

    Read the article

  • How to mock/stub a directory of files and their contents using RSpec?

    - by John Topley
    A while ago I asked "How to test obtaining a list of files within a directory using RSpec?" and although I got a couple of useful answers, I'm still stuck, hence a new question with some more detail about what I'm trying to do. I'm writing my first RubyGem. It has a module that contains a class method that returns an array containing a list of non-hidden files within a specified directory. Like this: files = Foo.bar :directory => './public' The array also contains an element that represents metadata about the files. This is actually a hash of hashes generated from the contents of the files, the idea being that changing even a single file changes the hash. I've written my pending RSpec examples, but I really have no idea how to implement them: it "should compute a hash of the files within the specified directory" it "shouldn't include hidden files or directories within the specified directory" it "should compute a different hash if the content of a file changes" I really don't want to have the tests dependent on real files acting as fixtures. How can I mock or stub the files and their contents? The gem implementation will use Find.find, but as one of the answers to my other question said, I don't need to test the library. I really have no idea how to write these specs, so any help much appreciated!

    Read the article

  • Refactoring Rspec specs

    - by Steve Weet
    I am trying to cleanup my specs as they are becoming extremely repetitive. I have the following spec describe "Countries API" do it "should render a country list" do co1 = Factory(:country) co2 = Factory(:country) result = invoke :GetCountryList, "empty_auth" result.should be_an_instance_of(Api::GetCountryListReply) result.status.should be_an_instance_of(Api::SoapStatus) result.status.code.should eql 0 result.status.errors.should be_an_instance_of Array result.status.errors.length.should eql 0 result.country_list.should be_an_instance_of Array result.country_list.first.should be_an_instance_of(Api::Country) result.country_list.should have(2).items end it_should_behave_like "All Web Services" it "should render a non-zero status for an invalid request" end The block of code that checks the status will appear in all of my specs for 50-60 APIs. My first thought was to move that to a method and that refactoring certainly makes things much drier as follows :- def status_should_be_valid(status) status.should be_an_instance_of(Api::SoapStatus) status.code.should eql 0 status.errors.should be_an_instance_of Array status.errors.length.should eql 0 end describe "Countries API" do it "should render a country list" do co1 = Factory(:country) co2 = Factory(:country) result = invoke :GetCountryList, "empty_auth" result.should be_an_instance_of(Api::GetCountryListReply) status_should_be_valid(result.status) result.country_list.should be_an_instance_of Array result.country_list.first.should be_an_instance_of(Api::Country) result.country_list.should have(2).items end end This works however I can not help feeling that this is not the "right" way to do it and I should be using shared specs, however looking at the method for defining shared specs I can not easily see how I would refactor this example to use a shared spec. How would I do this with shared specs and without having to re-run the relatively costly block at the beginning namely co1 = Factory(:country) co2 = Factory(:country) result = invoke :GetCountryList, "empty_auth"

    Read the article

  • Is it possible to use the ScalaTest BDD syntax in a JUnit environment?

    - by ebruchez
    I would like to describe tests in BDD style e.g. with FlatSpec but keep JUnit as a test runner. The ScalaTest Quick Start does not seem to show any example of this: http://www.scalatest.org/getting_started_with_junit_4 I first tried naively to write tests within @Test methods, but that doesn't work and the assertion is never tested: @Test def foobarBDDStyle { "The first name control" must "be valid" in { assert(isValid("name·1")) } // etc. } Is there any way to achieve this? It would be even better if regular tests can be mixed and matched with BDD-style tests.

    Read the article

  • Learn Behavior-Driven Development

    - by Ben Griswold
    In this presentation, I provided a brief introduction into TDD and talked about the confusion and misconceptions around the discipline. I, of course, shared a bit about Dan North, the father of BDD and touched upon some crazy hypothesis dreamed up by Sapir and Whorf. I then gave a Behavior Driven Development overview (my impressions of the implementation and lifecycle) and then touched upon available tools, how to get started and I threw in a number of reference and reading materials which you will find below. As an added bonus, I demonstrated how easy it is to include/exclude hyphens and alter the spelling of “behavior” at will.   Introducing BDD, Dan North Oredev 2007 – Behaviour-Driven Development, Dan North Behavior-Driven Development, Scott Bellware Behavior Driven Development, Wikipedia BDD Wiki A New Look at Test-Driven Development, Dave Astels Behavior Driven Development – An Evolution in Testing, Bob Cotton The Truth about BDD, Uncle Bob Martin Language and Thought, Wikipedia Sapir-Whorf Hypothesis, Wikipedia What’s in a Story?, Dan North

    Read the article

  • switch linq syntax

    - by scrat789
    var folders = from r in this.bdd.Rights join f in this.bdd.Folders on r.RightFolderId equals f.FolderId join rs in this.bdd.RightSpecs on r.RightSpecId equals rs.SpecIdRight where r.RightUserId == userId where rs.SpecRead == true where rs.SpecWrite == true select f; How transform this linq query in the other syntax? var folders = this.bdd.Rights.Where(r => r.....

    Read the article

  • What approach to take for SIMD optimizations

    - by goldenmean
    Hi, I am trying to optimize below code for SIMD operations (8way/4way/2way SIMD whiechever possible and if it gives gains in performance) I am tryin to analyze it first on paper to understand the algorithm used. How can i optimize it for SIMD:- void idct(uint8_t *dst, int stride, int16_t *input, int type) { int16_t *ip = input; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; int A, B, C, D, Ad, Bd, Cd, Dd, E, F, G, H; int Ed, Gd, Add, Bdd, Fd, Hd; int i; /* Inverse DCT on the rows now */ for (i = 0; i < 8; i++) { /* Check for non-zero values */ if ( ip[0] | ip[1] | ip[2] | ip[3] | ip[4] | ip[5] | ip[6] | ip[7] ) { A = M(xC1S7, ip[1]) + M(xC7S1, ip[7]); B = M(xC7S1, ip[1]) - M(xC1S7, ip[7]); C = M(xC3S5, ip[3]) + M(xC5S3, ip[5]); D = M(xC3S5, ip[5]) - M(xC5S3, ip[3]); Ad = M(xC4S4, (A - C)); Bd = M(xC4S4, (B - D)); Cd = A + C; Dd = B + D; E = M(xC4S4, (ip[0] + ip[4])); F = M(xC4S4, (ip[0] - ip[4])); G = M(xC2S6, ip[2]) + M(xC6S2, ip[6]); H = M(xC6S2, ip[2]) - M(xC2S6, ip[6]); Ed = E - G; Gd = E + G; Add = F + Ad; Bdd = Bd - H; Fd = F - Ad; Hd = Bd + H; /* Final sequence of operations over-write original inputs. */ ip[0] = (int16_t)(Gd + Cd) ; ip[7] = (int16_t)(Gd - Cd ); ip[1] = (int16_t)(Add + Hd); ip[2] = (int16_t)(Add - Hd); ip[3] = (int16_t)(Ed + Dd) ; ip[4] = (int16_t)(Ed - Dd ); ip[5] = (int16_t)(Fd + Bdd); ip[6] = (int16_t)(Fd - Bdd); } ip += 8; /* next row */ } ip = input; for ( i = 0; i < 8; i++) { /* Check for non-zero values (bitwise or faster than ||) */ if ( ip[1 * 8] | ip[2 * 8] | ip[3 * 8] | ip[4 * 8] | ip[5 * 8] | ip[6 * 8] | ip[7 * 8] ) { A = M(xC1S7, ip[1*8]) + M(xC7S1, ip[7*8]); B = M(xC7S1, ip[1*8]) - M(xC1S7, ip[7*8]); C = M(xC3S5, ip[3*8]) + M(xC5S3, ip[5*8]); D = M(xC3S5, ip[5*8]) - M(xC5S3, ip[3*8]); Ad = M(xC4S4, (A - C)); Bd = M(xC4S4, (B - D)); Cd = A + C; Dd = B + D; E = M(xC4S4, (ip[0*8] + ip[4*8])) + 8; F = M(xC4S4, (ip[0*8] - ip[4*8])) + 8; if(type==1){ //HACK E += 16*128; F += 16*128; } G = M(xC2S6, ip[2*8]) + M(xC6S2, ip[6*8]); H = M(xC6S2, ip[2*8]) - M(xC2S6, ip[6*8]); Ed = E - G; Gd = E + G; Add = F + Ad; Bdd = Bd - H; Fd = F - Ad; Hd = Bd + H; /* Final sequence of operations over-write original inputs. */ if(type==0){ ip[0*8] = (int16_t)((Gd + Cd ) >> 4); ip[7*8] = (int16_t)((Gd - Cd ) >> 4); ip[1*8] = (int16_t)((Add + Hd ) >> 4); ip[2*8] = (int16_t)((Add - Hd ) >> 4); ip[3*8] = (int16_t)((Ed + Dd ) >> 4); ip[4*8] = (int16_t)((Ed - Dd ) >> 4); ip[5*8] = (int16_t)((Fd + Bdd ) >> 4); ip[6*8] = (int16_t)((Fd - Bdd ) >> 4); }else if(type==1){ dst[0*stride] = cm[(Gd + Cd ) >> 4]; dst[7*stride] = cm[(Gd - Cd ) >> 4]; dst[1*stride] = cm[(Add + Hd ) >> 4]; dst[2*stride] = cm[(Add - Hd ) >> 4]; dst[3*stride] = cm[(Ed + Dd ) >> 4]; dst[4*stride] = cm[(Ed - Dd ) >> 4]; dst[5*stride] = cm[(Fd + Bdd ) >> 4]; dst[6*stride] = cm[(Fd - Bdd ) >> 4]; }else{ dst[0*stride] = cm[dst[0*stride] + ((Gd + Cd ) >> 4)]; dst[7*stride] = cm[dst[7*stride] + ((Gd - Cd ) >> 4)]; dst[1*stride] = cm[dst[1*stride] + ((Add + Hd ) >> 4)]; dst[2*stride] = cm[dst[2*stride] + ((Add - Hd ) >> 4)]; dst[3*stride] = cm[dst[3*stride] + ((Ed + Dd ) >> 4)]; dst[4*stride] = cm[dst[4*stride] + ((Ed - Dd ) >> 4)]; dst[5*stride] = cm[dst[5*stride] + ((Fd + Bdd ) >> 4)]; dst[6*stride] = cm[dst[6*stride] + ((Fd - Bdd ) >> 4)]; } } else { if(type==0){ ip[0*8] = ip[1*8] = ip[2*8] = ip[3*8] = ip[4*8] = ip[5*8] = ip[6*8] = ip[7*8] = ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20); }else if(type==1){ dst[0*stride]= dst[1*stride]= dst[2*stride]= dst[3*stride]= dst[4*stride]= dst[5*stride]= dst[6*stride]= dst[7*stride]= cm[128 + ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20)]; }else{ if(ip[0*8]){ int v= ((xC4S4 * ip[0*8] + (IdctAdjustBeforeShift<<16))>>20); dst[0*stride] = cm[dst[0*stride] + v]; dst[1*stride] = cm[dst[1*stride] + v]; dst[2*stride] = cm[dst[2*stride] + v]; dst[3*stride] = cm[dst[3*stride] + v]; dst[4*stride] = cm[dst[4*stride] + v]; dst[5*stride] = cm[dst[5*stride] + v]; dst[6*stride] = cm[dst[6*stride] + v]; dst[7*stride] = cm[dst[7*stride] + v]; } } } ip++; /* next column */ dst++; } }

    Read the article

  • How to grant write permissions in Samba?

    - by Eric Fossum
    I'm having trouble with read/write permissions on my Samba server, how do I fix my smb.conf and file permissions to have a more unified access? smb.conf [global] workgroup = workgroup netbios name = LnxNAS server string = %h wins support = no dns proxy = no security = user encrypt passwords = yes panic action = /usr/share/samba/panic-action %d [homes] comment = Home Directories [Video] path = /data/eric/Videos [Music] path = /data/eric/Music [Pictures] path = /data/eric/Pictures [data] path = /data my ls -l of /data/eric/Pictures drwxrwxrwx 2 ericfoss root 4096 2011-03-13 22:09 Android Projs drwxrwxrwx 3 ericfoss root 4096 2011-03-13 22:09 Automotive -rwxrwxrwx 1 ericfoss root 2439 2010-12-17 17:03 BDD reduction.png -rwxrwxrwx 1 ericfoss root 2722 2010-12-17 16:55 BDD Tree.png -rwxrwxrwx 1 ericfoss root 7341 2010-12-17 16:46 BDD Tree.xcf -rwxrwxrwx 1 ericfoss root 72421 2007-11-22 22:59 Bum Ninja.jpg -rwxrwxrwx 1 ericfoss root 32152 2010-12-17 21:25 cell transition.png -rwxrwxrwx 1 ericfoss root 40212 2010-12-17 17:55 control graph.png drwxrwxrwx 2 ericfoss root 4096 2011-03-13 22:09 Crap -rwxrwxrwx 1 ericfoss root 82 2010-09-20 17:18 desktop.ini ericfoss@SERVER:~$ If I try to delete \Server\Pictures\Crap it says permission denied, but \Server\data\eric\Pictures\crap can be deleted... I thought security = user took care of this?

    Read the article

  • How should I go about implementing a points-to analysis in Maude?

    - by reprogrammer
    I'm going to implement a points-to analysis algorithm. I'd like to implement this analysis mainly based on the algorithm by Whaley and Lam. Whaley and Lam use a BDD based implementation of Datalog to represent and compute the points-to analysis relations. The following lists some of the relations that are used in a typical points-to analysis. Note that D(w, z) :- A(w, x),B(x, y), C(y, z) means D(w, z) is true if A(w, x), B(x, y), and C(y, z) are all true. BDD is the data structure used to represent these relations. Relations input vP0 (variable : V, heap : H) input store (base : V, field : F, source : V) input load (base : V, field : F, dest : V) input assign (dest : V, source : V) output vP (variable : V, heap : H) output hP (base : H, field : F, target : H) Rules vP(v, h) :- vP0(v, h) vP(v1, h) :- assign(v1, v2), vP(v2, h) hP(h1, f,h2) :- store(v1, f, v2), vP(v1, h1), vP(v2, h2) vP(v2, h2) :- load(v1, f, v2), vP(v1, h1), hP(h1, f, h2) I need to understand if Maude is a good environment for implementing points-to analysis. I noticed that Maude uses a BDD library called BuDDy. But, it looks like that Maude uses BDDs for a different purpose, i.e. unification. So, I thought I might be able to use Maude instead of a Datalog engine to compute the relations of my points-to analysis. I assume Maude propagates independent information concurrently. And this concurrency could potentially make my points-to analysis faster than sequential processing of rules. But, I don't know the best way to represent my relations in Maude. Should I implement BDD in Maude myself, or Maude's internal unification based on BDD has the same effect?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8  | Next Page >